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

Last change on this file since 2283 was 2283, checked in by frsantos, 18 years ago

Keep Yahoo logo in images

File size: 3.7 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.4&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></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 map.removeZoomScale();
65 var zac = map.getBestZoomAndCenter(points);
66 var level = zac.zoomLevel;
67
68 // funny Yahoo bug seems to return 0 if your section is too small
69 if( level == 0 ) level = 1;
70 if (level>1) level--;
71
72 map.drawZoomAndCenter(zac.YGeoPoint,level);
73
74 // Get the on-screen coordinates of the points
75 xy0 = map.convertLatLonXY(points[0]);
76 xy1 = map.convertLatLonXY(points[1]);
77
78 // Create a new size for the map. This makes the need of clipping the image unnecesary.
79 new_width = Math.abs( xy0.x - xy1.x);
80 new_height = Math.abs( xy0.y - xy1.y);
81
82 // Apply the new width-height
83 mapDiv.style.width = new_width;
84 mapDiv.style.height = new_height;
85 map.resizeTo( new YSize(new_width, new_height));
86
87 /// DEBUG: colour the interesting area
88 var cPT2 = new YGeoPoint(tllat, tllon);
89 var cPT3 = new YGeoPoint(tllat, brlon);
90 var cPT4 = new YGeoPoint(brlat, brlon);
91 var cPT5 = new YGeoPoint(brlat, tllon);
92 // args: array of pts, color, width, alpha
93 var poly1 = new YPolyline([cPT2,cPT3,cPT4,cPT5, cPT2],'blue',7,0.7);
94 //map.addOverlay(poly1);
95
96 var bounds = map.getBoundsLatLon();
97
98 // Dumps the actual bounding box
99 dump("bbox=" + bounds.LonMin + "," + bounds.LatMin + "," + bounds.LonMax + "," + bounds.LatMax + "\n");
100 dump("new_width=" + new_width + "\n");
101 dump("new_height=" + new_height + "\n");
102 }
103 </script>
104 </body>
105</html>
Note: See TracBrowser for help on using the repository browser.