source: osm/applications/editors/josm/plugins/wmsplugin/resources/ymap.html@ 11085

Last change on this file since 11085 was 11085, checked in by petrdlouhy, 17 years ago

removed unneded dimps from the ymap.html, so webkit-image could work
properly

File size: 3.5 KB
Line 
1<html>
2 <head>
3 <script type="text/javascript">
4 //var bbox = "";
5 //var width = 800;
6 //var height = 800;
7
8 // Parse query string and set variables
9 var url = location.href;
10 var queryStringPos = url.indexOf("?");
11 if( queryStringPos != -1 )
12 {
13 url = url.substring(queryStringPos + 1);
14 var variables = url.split ("&");
15 for (i = 0; i < variables.length; i++)
16 {
17 if( !variables[i] )
18 continue;
19 var keyValue = variables[i].split("=");
20 eval ('var '+keyValue[0].toLowerCase()+'="'+keyValue[1]+'"');
21 }
22 }
23 else
24 {
25 dump("YWMS ERROR: no queryString\n");
26 }
27
28 // Limit size to current window's, to avoid memory problems
29 //width = Math.min(width, screen.width);
30 //height = Math.min(height, screen.height);
31
32 </script>
33 <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>
34 </head>
35
36 <body style="margin: 0px">
37 <div id="map"></div>
38 <script type="text/javascript">
39 if( !bbox || !width || !height)
40 {
41 alert("YWMS ERROR: invalid parameters\n");
42 }
43 else
44 {
45 // Resize map container to parameter dimension
46 var mapDiv = document.getElementById("map");
47
48 // Get the bounding box
49 var coords = bbox.split(",");
50 var tllon = Number(coords[0]), tllat = Number(coords[1]);
51 var brlon = Number(coords[2]), brlat = Number(coords[3]);
52
53 var points = new Array();
54 points[0] = new YGeoPoint(tllat, tllon);
55 points[1] = new YGeoPoint(brlat, brlon);
56
57 // other map types work as well but only satellite allowed for use with OSM!
58 var map = new YMap(document.getElementById("map"), YAHOO_MAP_SAT, new YSize(width, height));
59 map.removeZoomScale();
60 var zac = map.getBestZoomAndCenter(points);
61 var level = zac.zoomLevel;
62
63 // funny Yahoo bug seems to return 0 if your section is too small
64 if( level == 0 ) level = 1;
65 if (level>1) level--;
66
67 map.drawZoomAndCenter(zac.YGeoPoint,level);
68
69 // Get the on-screen coordinates of the points
70 xy0 = map.convertLatLonXY(points[0]);
71 xy1 = map.convertLatLonXY(points[1]);
72
73 // This is hack to bug in getBestZoomAndCenter function
74 cx = map.convertXYLatLon(new YCoordPoint((xy0.x+xy1.x)/2, (xy0.y+xy1.y)/2));
75 map.drawZoomAndCenter(cx,level)
76
77 // Create a new size for the map. This makes the need of clipping the image unnecessary.
78 new_width = Math.abs( xy0.x - xy1.x);
79 new_height = Math.abs( xy0.y - xy1.y);
80
81 // Apply the new width-height
82 mapDiv.style.width = new_width;
83 mapDiv.style.height = new_height;
84 map.resizeTo( new YSize(new_width, new_height));
85 window.moveTo(0,0);
86 window.resizeTo(new_width, new_height);
87
88
89
90 /*
91 /// DEBUG: colour the interesting area
92 var cPT2 = new YGeoPoint(tllat, tllon);
93 var cPT3 = new YGeoPoint(tllat, brlon);
94 var cPT4 = new YGeoPoint(brlat, brlon);
95 var cPT5 = new YGeoPoint(brlat, tllon);
96 // args: array of pts, color, width, alpha
97 var poly1 = new YPolyline([cPT2,cPT3,cPT4,cPT5, cPT2],'blue',7,0.7);
98 map.addOverlay(poly1);
99 */
100 }
101 </script>
102 </body>
103</html>
Note: See TracBrowser for help on using the repository browser.