Hide search marker/object when closing sidebar
authorJohn Firebaugh <john.firebaugh@gmail.com>
Tue, 6 Aug 2013 17:32:38 +0000 (10:32 -0700)
committerTom Hughes <tom@compton.nu>
Tue, 6 Aug 2013 19:23:13 +0000 (20:23 +0100)
Fixes #417

app/assets/javascripts/index/search.js
app/assets/javascripts/leaflet.extend.js.erb

index 936cc1e0e98913d4610eb160ee7353d8393f3433..486c9b36bbc521f3551635c34a755141365bd235 100644 (file)
@@ -30,6 +30,11 @@ function initializeSearch(map) {
     });
 
     openSidebar();
+
+    $("#sidebar").one("closed", function () {
+      map.removeLayer(marker);
+      map.removeObject();
+    });
   }
 
   function clickSearchResult(e) {
index 8aa9c70ec88de82e40e6d3673d31b14bbfc58290..0df6fd381280eedbe7ac10ed2045938d22fe6c12 100644 (file)
@@ -146,6 +146,12 @@ L.extend(L.Map.prototype, {
         map._objectLayer.addTo(map);
       }
     });
+  },
+
+  removeObject: function() {
+    this._object = null;
+    if (this._objectLoader) this._objectLoader.abort();
+    if (this._objectLayer) this.removeLayer(this._objectLayer);
   }
 });