Fix export location filter button
authorJohn Firebaugh <john.firebaugh@gmail.com>
Wed, 9 Oct 2013 00:24:49 +0000 (17:24 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Sun, 13 Oct 2013 21:46:10 +0000 (14:46 -0700)
Upstream pull request:
https://github.com/kajic/leaflet-locationfilter/pull/14

app/assets/javascripts/index.js
app/assets/javascripts/index/export.js
vendor/assets/leaflet/leaflet.locationfilter.js

index 77b247c10fb0c1b294a9118749b5068662a87c5d..e9e95abfef40e81eb7f3ae0be17fdc97a2735aeb 100644 (file)
@@ -292,7 +292,7 @@ $(document).ready(function () {
   });
 
   $(document).on("click", "a", function(e) {
-    if (e.isPropagationStopped()) return;
+    if (e.isDefaultPrevented() || e.isPropagationStopped()) return;
     if (this.host === window.location.host && OSM.route(this.pathname + this.search + this.hash)) e.preventDefault();
   });
 
index 51ad1e3e2e55456ef1358d1f45c3fd88605cf43a..02dcdd4402eb2676db62c1132f197dd33c0ecf33 100644 (file)
@@ -22,12 +22,12 @@ OSM.Export = function(map) {
     validateControls();
   }
 
-  function enableFilter() {
-    if (!locationFilter.getBounds().isValid()) {
-      locationFilter.setBounds(map.getBounds().pad(-0.2));
-    }
+  function enableFilter(e) {
+    e.preventDefault();
 
     $("#drag_box").hide();
+
+    locationFilter.setBounds(map.getBounds().pad(-0.2));
     locationFilter.enable();
   }
 
index a17f1a5affbc5e779be21299ef0333c543258448..9a0af4db4e59bd17215d7ddfd11029eecbaed317 100644 (file)
@@ -114,7 +114,6 @@ L.LocationFilter = L.Class.extend({
 
     onAdd: function(map) {
         this._map = map;
-        this._layer = new L.LayerGroup();
 
         if (this.options.enableButton || this.options.adjustButton) {
             this._initializeButtonContainer();
@@ -285,6 +284,8 @@ L.LocationFilter = L.Class.extend({
             return;
         }
 
+        this._layer = new L.LayerGroup();
+
         // Calculate filter bounds
         this._calculateBounds();