source: osm/utils/josm/plugins/ywms/resources/ymap.html@ 2264

Last change on this file since 2264 was 2264, checked in by frederik, 18 years ago

New plugin by Francisco R. Santos <frsantos@…>

File size: 2.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 // Don't know how to hide the window, so resize for the user to see it loading the aerial photo
33 window.moveTo(0,0);
34 window.resizeTo(width,height);
35 </script>
36 <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=YahooDemo"></script>
37 </head>
38
39 <body style="margin: 0px">
40 <div id="map"></div>
41 <script type="text/javascript">
42 if( !bbox || !width || !height)
43 {
44 alert("YWMS ERROR: invalid parameters\n");
45 }
46 else
47 {
48 // Resize map container to parameter dimension
49 var mapDiv = document.getElementById("map");
50 mapDiv.style.width = width;
51 mapDiv.style.height = height;
52
53 // Get the bounding box
54 var coords = bbox.split(",");
55 var tllon = coords[0], tllat = coords[1];
56 var brlon = coords[2], brlat = coords[3];
57
58 var points = new Array();
59 points[0] = new YGeoPoint(tllat, tllon);
60 points[1] = new YGeoPoint(brlat, brlon);
61
62 // other map types work as well but only satellite allowed for use with OSM!
63 var map = new YMap(document.getElementById("map"), YAHOO_MAP_SAT);
64 var zac = map.getBestZoomAndCenter(points);
65 var level = zac.zoomLevel;
66
67 // funny Yahoo bug seems to return 0 if your section is too small
68 if (level==0) level=1;
69
70 map.drawZoomAndCenter(zac.YGeoPoint,level);
71 var bounds = map.getBoundsLatLon();
72
73 // Dumps the actual bounding box
74 dump("bbox=" + bounds.LonMin + "," + bounds.LatMin + "," + bounds.LonMax + "," + bounds.LatMax + "\n");
75 }
76 </script>
77 </body>
78</html>
Note: See TracBrowser for help on using the repository browser.