Changeset 10585 in osm for applications/editors/josm/plugins
- Timestamp:
- 2008-09-09T16:30:45+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/resources/ymap.html
r10382 r10585 2 2 <head> 3 3 <script type="text/javascript"> 4 var bbox = "";5 var width = 800;6 var height = 800;4 //var bbox = ""; 5 //var width = 800; 6 //var height = 800; 7 7 8 8 // Parse query string and set variables … … 27 27 28 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);29 //width = Math.min(width, screen.width); 30 //height = Math.min(height, screen.height); 31 31 32 32 </script> 33 <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3. 4&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>33 <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script> 34 34 </head> 35 35 … … 43 43 else 44 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; 45 // Resize map container to parameter dimension 46 var mapDiv = document.getElementById("map"); 49 47 50 51 52 var tllon = coords[0], tllat = coords[1];53 var brlon = coords[2], brlat = coords[3];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]); 54 52 55 56 57 53 var points = new Array(); 54 points[0] = new YGeoPoint(tllat, tllon); 55 points[1] = new YGeoPoint(brlat, brlon); 58 56 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); 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--; 70 66 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)); 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 83 93 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); 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 */ 98 104 } 99 105 </script>
Note:
See TracChangeset
for help on using the changeset viewer.