]> git.openstreetmap.org Git - rails.git/blobdiff - public/javascripts/map.js
More cleanup work on the notes javascript
[rails.git] / public / javascripts / map.js
index 272913d203c2ae8462888ff84ae1e85b748d2f7e..58950a1ffa14b724e3a8296d3b3b2c89e3a52ae5 100644 (file)
@@ -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, id, outline) {
    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,12 +157,20 @@ function addBoxToMap(boxbounds) {
      });
      map.addLayer(vectors);
    }
-   var geometry = boxbounds.toGeometry().transform(epsg4326, map.getProjectionObject());
+   var geometry;
+   if (outline) {
+     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, {}, {
       strokeWidth: 2,
       strokeColor: '#ee9900',
       fillOpacity: 0
    });
+   box.fid = id;
 
    vectors.addFeatures(box);
 
@@ -242,20 +251,8 @@ function setMapLayers(layerConfig) {
 
          if (c == "B") {
             map.setBaseLayer(layers[i]);
-         }
-      }
-
-      while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") {
-         l++;
-      }
-
-      for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
-         var c = layerConfig.charAt(l++);
-
-         if (c == "T") {
-            layers[i].setVisibility(true);
-         } else if(c == "F") {
-            layers[i].setVisibility(false);
+         } else {
+            map.layers[i].setVisibility(false);
          }
       }
    } else {
@@ -265,7 +262,7 @@ function setMapLayers(layerConfig) {
                if (map.layers[i].isBaseLayer) {
                   map.setBaseLayer(map.layers[i]);
                } else {
-                   map.layers[i].setVisibility(true);
+                  map.layers[i].setVisibility(true);
                }
             } else {
                map.layers[i].setVisibility(false);