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

Last change on this file since 12780 was 12780, checked in by stoecker, 16 years ago

removed tab stop usage

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-1;
53 var levels = map.getZoomValidLevels();
54 if(levels[0] > level)
55 level = levels[0];
56
57 map.drawZoomAndCenter(zac.YGeoPoint,level);
58
59 // Get the on-screen coordinates of the points
60 xy0 = map.convertLatLonXY(points[0]);
61 xy1 = map.convertLatLonXY(points[1]);
62
63 // Recenter the stuff to have exact edges
64 cx = map.convertXYLatLon(new YCoordPoint((xy0.x+xy1.x)/2.0, (xy0.y+xy1.y)/2.0));
65 map.drawZoomAndCenter(cx,level)
66
67 // Create a new size for the map. This makes the need of clipping the image unnecessary.
68 new_width = Math.abs( xy0.x - xy1.x);
69 new_height = Math.abs( xy0.y - xy1.y);
70
71 // Apply the new width-height
72 map.resizeTo( new YSize(new_width, new_height));
73 mapDiv.style.width = new_width;
74 mapDiv.style.height = new_height;
75 window.moveTo(0,0);
76 window.resizeTo(new_width, new_height);
77 }
78 </script>
79 </body>
80</html>
Note: See TracBrowser for help on using the repository browser.