| 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 | </script>
|
|---|
| 33 | <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.4&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>
|
|---|
| 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 | {
|
|---|
| 45 | // Resize map container to parameter dimension
|
|---|
| 46 | var mapDiv = document.getElementById("map");
|
|---|
| 47 | mapDiv.style.width = Math.ceil(width/258)*258;
|
|---|
| 48 | mapDiv.style.height = Math.ceil(height/258)*258;
|
|---|
| 49 |
|
|---|
| 50 | // Get the bounding box
|
|---|
| 51 | var coords = bbox.split(",");
|
|---|
| 52 | var tllon = coords[0], tllat = coords[1];
|
|---|
| 53 | var brlon = coords[2], brlat = coords[3];
|
|---|
| 54 |
|
|---|
| 55 | var points = new Array();
|
|---|
| 56 | points[0] = new YGeoPoint(tllat, tllon);
|
|---|
| 57 | points[1] = new YGeoPoint(brlat, brlon);
|
|---|
| 58 |
|
|---|
| 59 | // other map types work as well but only satellite allowed for use with OSM!
|
|---|
| 60 | var map = new YMap(document.getElementById("map"), YAHOO_MAP_SAT);
|
|---|
| 61 | map.removeZoomScale();
|
|---|
| 62 | var zac = map.getBestZoomAndCenter(points);
|
|---|
| 63 | var level = zac.zoomLevel;
|
|---|
| 64 |
|
|---|
| 65 | // funny Yahoo bug seems to return 0 if your section is too small
|
|---|
| 66 | if( level == 0 ) level = 1;
|
|---|
| 67 | if (level>1) level--;
|
|---|
| 68 |
|
|---|
| 69 | map.drawZoomAndCenter(zac.YGeoPoint,level);
|
|---|
| 70 |
|
|---|
| 71 | // Get the on-screen coordinates of the points
|
|---|
| 72 | xy0 = map.convertLatLonXY(points[0]);
|
|---|
| 73 | xy1 = map.convertLatLonXY(points[1]);
|
|---|
| 74 |
|
|---|
| 75 | // Create a new size for the map. This makes the need of clipping the image unnecesary.
|
|---|
| 76 | new_width = Math.abs( xy0.x - xy1.x);
|
|---|
| 77 | new_height = Math.abs( xy0.y - xy1.y);
|
|---|
| 78 |
|
|---|
| 79 | // Apply the new width-height
|
|---|
| 80 | mapDiv.style.width = new_width;
|
|---|
| 81 | mapDiv.style.height = new_height;
|
|---|
| 82 | map.resizeTo( new YSize(new_width, new_height));
|
|---|
| 83 |
|
|---|
| 84 | /// DEBUG: colour the interesting area
|
|---|
| 85 | var cPT2 = new YGeoPoint(tllat, tllon);
|
|---|
| 86 | var cPT3 = new YGeoPoint(tllat, brlon);
|
|---|
| 87 | var cPT4 = new YGeoPoint(brlat, brlon);
|
|---|
| 88 | var cPT5 = new YGeoPoint(brlat, tllon);
|
|---|
| 89 | // args: array of pts, color, width, alpha
|
|---|
| 90 | var poly1 = new YPolyline([cPT2,cPT3,cPT4,cPT5, cPT2],'blue',7,0.7);
|
|---|
| 91 | //map.addOverlay(poly1);
|
|---|
| 92 |
|
|---|
| 93 | var bounds = map.getBoundsLatLon();
|
|---|
| 94 |
|
|---|
| 95 | //Resizes to the actual bounding box
|
|---|
| 96 | window.moveTo(0,0);
|
|---|
| 97 | window.resizeTo(new_width,new_height);
|
|---|
| 98 | }
|
|---|
| 99 | </script>
|
|---|
| 100 | </body>
|
|---|
| 101 | </html>
|
|---|