]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/changeset/_map.html.erb
Wait for dom:loaded to fire before initialising the map
[rails.git] / app / views / changeset / _map.html.erb
index 6d7aa96c04fafbafcf95f971e7373b16eb524391..39906af0833925c8098555e331f972bb9b77d80f 100644 (file)
     var feature = vectors.getFeatureByFid(id);
     var bounds = feature.geometry.getBounds();
 
-    if ( highlight ) vectors.removeFeatures(highlight);
+    if (bounds.containsBounds(map.getExtent())) {
+      bounds = map.getExtent().scale(1.1);
+    }
+
+    if (highlight) vectors.removeFeatures(highlight);
 
     highlight = new OpenLayers.Feature.Vector(bounds.toGeometry(), {}, {
       strokeWidth: 2,
@@ -53,7 +57,8 @@
     var bbox = new OpenLayers.Bounds(minlon, minlat, maxlon, maxlat);
 
     bounds.extend(bbox);
-    box = addBoxToMap(bbox, "<%= edit.id %>", true);
+
+    addBoxToMap(bbox, "<%= edit.id %>", true);
     <% end %>
 
     vectors.events.on({