[10382] | 1 | <html>
|
---|
| 2 | <head>
|
---|
| 3 | <script type="text/javascript">
|
---|
[10585] | 4 | //var bbox = "";
|
---|
| 5 | //var width = 800;
|
---|
| 6 | //var height = 800;
|
---|
[10382] | 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
|
---|
[10585] | 29 | //width = Math.min(width, screen.width);
|
---|
| 30 | //height = Math.min(height, screen.height);
|
---|
[10382] | 31 |
|
---|
| 32 | </script>
|
---|
[10585] | 33 | <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>
|
---|
[10382] | 34 | </head>
|
---|
| 35 |
|
---|
| 36 | <body style="margin: 0px">
|
---|
| 37 | <div id="map"></div>
|
---|
| 38 | <script type="text/javascript">
|
---|
| 39 | if( !bbox || !width || !height)
|
---|
| 40 | {
|
---|
| 41 | alert("YWMS ERROR: invalid parameters\n");
|
---|
| 42 | }
|
---|
| 43 | else
|
---|
| 44 | {
|
---|
[10585] | 45 | // Resize map container to parameter dimension
|
---|
| 46 | var mapDiv = document.getElementById("map");
|
---|
[10382] | 47 |
|
---|
[10585] | 48 | // Get the bounding box
|
---|
| 49 | var coords = bbox.split(",");
|
---|
| 50 | var tllon = Number(coords[0]), tllat = Number(coords[1]);
|
---|
| 51 | var brlon = Number(coords[2]), brlat = Number(coords[3]);
|
---|
[10382] | 52 |
|
---|
[10585] | 53 | var points = new Array();
|
---|
| 54 | points[0] = new YGeoPoint(tllat, tllon);
|
---|
| 55 | points[1] = new YGeoPoint(brlat, brlon);
|
---|
[10382] | 56 |
|
---|
[10585] | 57 | // other map types work as well but only satellite allowed for use with OSM!
|
---|
| 58 | var map = new YMap(document.getElementById("map"), YAHOO_MAP_SAT, new YSize(width, height));
|
---|
| 59 | map.removeZoomScale();
|
---|
| 60 | var zac = map.getBestZoomAndCenter(points);
|
---|
| 61 | var level = zac.zoomLevel;
|
---|
| 62 |
|
---|
| 63 | // funny Yahoo bug seems to return 0 if your section is too small
|
---|
| 64 | if( level == 0 ) level = 1;
|
---|
| 65 | if (level>1) level--;
|
---|
[10382] | 66 |
|
---|
[10585] | 67 | map.drawZoomAndCenter(zac.YGeoPoint,level);
|
---|
| 68 |
|
---|
| 69 | // Get the on-screen coordinates of the points
|
---|
| 70 | xy0 = map.convertLatLonXY(points[0]);
|
---|
| 71 | xy1 = map.convertLatLonXY(points[1]);
|
---|
| 72 |
|
---|
| 73 | // This is hack to bug in getBestZoomAndCenter function
|
---|
| 74 | cx = map.convertXYLatLon(new YCoordPoint((xy0.x+xy1.x)/2, (xy0.y+xy1.y)/2));
|
---|
| 75 | map.drawZoomAndCenter(cx,level)
|
---|
| 76 |
|
---|
| 77 | dump(xy0.x + " " + xy0.y + " " + xy1.x + " " + xy1.y + "\n");
|
---|
| 78 | dump(tllat + " " + tllon + " " + brlat + " " + brlon + "\n");
|
---|
| 79 | dump((brlat + tllat)/2 + " " + (brlon + tllon)/2 + "\n");
|
---|
| 80 |
|
---|
| 81 | // Create a new size for the map. This makes the need of clipping the image unnecessary.
|
---|
| 82 | new_width = Math.abs( xy0.x - xy1.x);
|
---|
| 83 | new_height = Math.abs( xy0.y - xy1.y);
|
---|
| 84 |
|
---|
| 85 | // Apply the new width-height
|
---|
| 86 | mapDiv.style.width = new_width;
|
---|
| 87 | mapDiv.style.height = new_height;
|
---|
| 88 | map.resizeTo( new YSize(new_width, new_height));
|
---|
| 89 | window.moveTo(0,0);
|
---|
| 90 | window.resizeTo(new_width, new_height);
|
---|
| 91 |
|
---|
| 92 |
|
---|
[10382] | 93 |
|
---|
[10585] | 94 | /*
|
---|
| 95 | /// DEBUG: colour the interesting area
|
---|
| 96 | var cPT2 = new YGeoPoint(tllat, tllon);
|
---|
| 97 | var cPT3 = new YGeoPoint(tllat, brlon);
|
---|
| 98 | var cPT4 = new YGeoPoint(brlat, brlon);
|
---|
| 99 | var cPT5 = new YGeoPoint(brlat, tllon);
|
---|
| 100 | // args: array of pts, color, width, alpha
|
---|
| 101 | var poly1 = new YPolyline([cPT2,cPT3,cPT4,cPT5, cPT2],'blue',7,0.7);
|
---|
| 102 | map.addOverlay(poly1);
|
---|
| 103 | */
|
---|
[10382] | 104 | }
|
---|
| 105 | </script>
|
---|
| 106 | </body>
|
---|
| 107 | </html>
|
---|