X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2def7c187e32d99cd48c013ab117c463780ed45e..48929e8781f9c136a142400a7a2ef1cf994f74fd:/public/javascripts/map.js diff --git a/public/javascripts/map.js b/public/javascripts/map.js index 0668b8ab0..df9d30992 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -23,7 +23,8 @@ function createMap(divName, options) { new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoom(), - new OpenLayers.Control.PanZoomBar() + new OpenLayers.Control.PanZoomBar(), + new OpenLayers.Control.ScaleLine({geodesic: true}) ], units: "m", maxResolution: 156543.0339, @@ -148,7 +149,7 @@ function addObjectToMap(url, zoom, callback) { layer.loadGML(); } -function addBoxToMap(boxbounds) { +function addBoxToMap(boxbounds, attributes, line) { if (!vectors) { // Be aware that IE requires Vector layers be initialised on page load, and not under deferred script conditions vectors = new OpenLayers.Layer.Vector("Boxes", { @@ -156,8 +157,16 @@ function addBoxToMap(boxbounds) { }); map.addLayer(vectors); } - var geometry = boxbounds.toGeometry().transform(epsg4326, map.getProjectionObject()); - var box = new OpenLayers.Feature.Vector(geometry, {}, { + + var geometry; + if (line) { + vertices = boxbounds.toGeometry().getVertices(); + vertices.push( new OpenLayers.Geometry.Point( vertices[0].x, vertices[0].y ) ); + geometry = new OpenLayers.Geometry.LineString(vertices).transform(epsg4326, map.getProjectionObject()); + } else { + geometry = boxbounds.toGeometry().transform(epsg4326, map.getProjectionObject()); + } + var box = new OpenLayers.Feature.Vector(geometry, attributes, { strokeWidth: 2, strokeColor: '#ee9900', fillOpacity: 0