]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/export.js
Preserve in progress note comments when the map is moved
[rails.git] / app / assets / javascripts / index / export.js
index e1b079607fed9e301e7d78f74fdf055a9386143f..31a981ec9a15b34ff87d183e9b3f91b58b6ce676 100644 (file)
@@ -15,10 +15,11 @@ $(document).ready(function () {
 
     var locationFilter = new L.LocationFilter({
       enableButton: false,
-      adjustButton: false,
-      onChange: filterChanged
+      adjustButton: false
     }).addTo(map);
 
+    locationFilter.on("change", filterChanged);
+
     map.on("moveend", mapMoved);
     map.on("baselayerchange", htmlUrlChanged);
 
@@ -37,7 +38,7 @@ $(document).ready(function () {
 
     openSidebar();
 
-    if (map.hasLayer(layers[0].layer)) {
+    if (getMapBaseLayer().keyid == "mapnik") {
       $("#format_mapnik").prop("checked", true);
     }
 
@@ -54,6 +55,7 @@ $(document).ready(function () {
 
       map.off("moveend", mapMoved);
       map.off("baselayerchange", htmlUrlChanged);
+      locationFilter.off("change", filterChanged);
     });
 
     function getBounds() {
@@ -81,15 +83,18 @@ $(document).ready(function () {
       var bounds = getBounds();
 
       map.fitBounds(bounds);
-
-      enableFilter();
       locationFilter.setBounds(bounds);
 
+      enableFilter();
       validateControls();
       mapnikSizeChanged();
     }
 
     function enableFilter() {
+      if (!locationFilter.getBounds().isValid()) {
+        locationFilter.setBounds(map.getBounds().pad(-0.2));
+      }
+
       $("#drag_box").hide();
       locationFilter.enable();
     }