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

Last change on this file since 11990 was 11172, checked in by stoecker, 17 years ago

some fixes

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