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

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

removed tab stop usage

File size: 2.8 KB
RevLine 
[10382]1<html>
2 <head>
3 <script type="text/javascript">
[11172]4 // Parse query string and set variables
5 var url = location.href;
[10382]6 var queryStringPos = url.indexOf("?");
[11172]7 if( queryStringPos != -1 )
[10382]8 {
9 url = url.substring(queryStringPos + 1);
[11172]10 var variables = url.split ("&");
[12780]11 for (i = 0; i < variables.length; i++)
[10382]12 {
[11172]13 if( !variables[i] )
14 continue;
[10382]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>
[10585]24 <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>
[10382]25 </head>
[11172]26
[10382]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 {
[10585]36 // Resize map container to parameter dimension
37 var mapDiv = document.getElementById("map");
[10382]38
[10585]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]);
[10382]43
[10585]44 var points = new Array();
45 points[0] = new YGeoPoint(tllat, tllon);
46 points[1] = new YGeoPoint(brlat, brlon);
[10382]47
[10585]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);
[12491]52 var level = zac.zoomLevel-1;
53 var levels = map.getZoomValidLevels();
54 if(levels[0] > level)
55 level = levels[0];
[11172]56
[10585]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
[12491]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));
[10585]65 map.drawZoomAndCenter(cx,level)
[11172]66
[10585]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);
[11172]70
[10585]71 // Apply the new width-height
[11172]72 map.resizeTo( new YSize(new_width, new_height));
[10585]73 mapDiv.style.width = new_width;
74 mapDiv.style.height = new_height;
75 window.moveTo(0,0);
76 window.resizeTo(new_width, new_height);
[10382]77 }
78 </script>
79 </body>
80</html>
Note: See TracBrowser for help on using the repository browser.