From 93dae65764d323f15ab29bebf88f1e63234ca92e Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Sat, 26 Mar 2016 11:37:41 +0100 Subject: [PATCH] Fixes the moveend event removal --- dist/OverPassLayer.js | 2 +- dist/OverPassLayer.min.js | 2 +- src/OverPassLayer.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/OverPassLayer.js b/dist/OverPassLayer.js index aeef43e..63aa31f 100644 --- a/dist/OverPassLayer.js +++ b/dist/OverPassLayer.js @@ -654,7 +654,7 @@ this._requestInProgress = false; this._zoomControl._removeLayer(this); - map.off('moveend', this.onMoveEnd, this); + map.off('moveend', this._prepareRequest, this); this._map = null; }, diff --git a/dist/OverPassLayer.min.js b/dist/OverPassLayer.min.js index f364a9c..7dfc677 100644 --- a/dist/OverPassLayer.min.js +++ b/dist/OverPassLayer.min.js @@ -1 +1 @@ -!function(e,t){"function"==typeof define&&define.amd?define(["leaflet"],e):"object"==typeof exports&&(module.exports=e(require("leaflet"))),"undefined"!=typeof t&&t.L&&(t.L.Control.MinZoomIndicator=e(L))}(function(e){var t=e.Control.extend({options:{},_layers:{},initialize:function(t){e.Util.setOptions(this,t),this._layers={}},_addLayer:function(e){var t=15;e.options.minZoom&&(t=e.options.minZoom),this._layers[e._leaflet_id]=t,this._updateBox(null)},_removeLayer:function(e){this._layers[e._leaflet_id]=null,this._updateBox(null)},_getMinZoomLevel:function(){var e,t=-1;for(e in this._layers)null!==this._layers[e]&&this._layers[e]>t&&(t=this._layers[e]);return t},_updateBox:function(t){var o=this._getMinZoomLevel();null!==t&&e.DomEvent.preventDefault(t),this._container.innerHTML=-1==o?this.options.minZoomMessageNoLayer:this.options.minZoomMessage.replace(/CURRENTZOOM/,this._map.getZoom()).replace(/MINZOOMLEVEL/,o),this._container.style.display=this._map.getZoom()>=o?"none":"block"},onAdd:function(t){return this._map=t,this._map.zoomIndicator=this,this._container=e.DomUtil.create("div","leaflet-control-minZoomIndicator"),this._map.on("moveend",this._updateBox,this),this._updateBox(null),this._container},onRemove:function(t){e.Control.prototype.onRemove.call(this,t),t.off({moveend:this._updateBox},this),this._map=null}});return t},window),function(e,t){"function"==typeof define&&define.amd?define(["leaflet"],e):"object"==typeof exports&&(module.exports=e(require("leaflet"))),"undefined"!=typeof t&&t.L&&(t.L.OverPassLayer=e(L))}(function(e){var t=require("js-clipper"),o=e.FeatureGroup.extend({options:{debug:!1,minZoom:15,endPoint:"http://overpass-api.de/api/",query:"(node({{bbox}})[organic];node({{bbox}})[second_hand];);out qt;",timeout:3e4,retryOnTimeout:!1,noInitialRequest:!1,beforeRequest:function(){},afterRequest:function(){},onSuccess:function(t){for(var o=0;o=200&&e.status<400?(this.options.onSuccess(JSON.parse(e.response)),this._onRequestLoadCallback(t)):(this._onRequestErrorCallback(t),this.options.onError(e)),this._onRequestCompleteCallback(t)},_onRequestTimeout:function(e,t,o){this.options.onTimeout(e),this.options.retryOnTimeout?this._sendRequest(t):(this._onRequestErrorCallback(o),this._onRequestCompleteCallback(o))},_onRequestLoadCallback:function(e){this._setLoadedBounds(e),this.options.debug&&this._addResponseBoxes(this._getRequestBoxes())},_onRequestErrorCallback:function(e){this.options.debug&&this._removeRequestBox(this._buildRequestBox(e))},_onRequestCompleteCallback:function(e){if(this.options.afterRequest(),this._hasNextRequest()){var t=this._getNextRequest();this._removeNextRequest(),t()}else this._setRequestInProgress(!1)},onAdd:function(t){this._map=t,this._map.zoomIndicator?(this._zoomControl=this._map.zoomIndicator,this._zoomControl._addLayer(this)):(this._zoomControl=new e.Control.MinZoomIndicator(this.options.minZoomIndicatorOptions),this._map.addControl(this._zoomControl),this._zoomControl._addLayer(this)),this.options.debug&&(this._requestBoxes=e.featureGroup().addTo(this._map),this._responseBoxes=e.featureGroup().addTo(this._map)),this.options.noInitialRequest||this._prepareRequest(),-1!==this.options.query.indexOf("({{bbox}})")&&this._map.on("moveend",this._prepareRequest,this)},onRemove:function(t){e.LayerGroup.prototype.onRemove.call(this,t),this._ids={},this._loadedBounds=[],this._requestInProgress=!1,this._zoomControl._removeLayer(this),t.off("moveend",this.onMoveEnd,this),this._map=null},getData:function(){return this._data}});return o},window); \ No newline at end of file +!function(e,t){"function"==typeof define&&define.amd?define(["leaflet"],e):"object"==typeof exports&&(module.exports=e(require("leaflet"))),"undefined"!=typeof t&&t.L&&(t.L.Control.MinZoomIndicator=e(L))}(function(e){var t=e.Control.extend({options:{},_layers:{},initialize:function(t){e.Util.setOptions(this,t),this._layers={}},_addLayer:function(e){var t=15;e.options.minZoom&&(t=e.options.minZoom),this._layers[e._leaflet_id]=t,this._updateBox(null)},_removeLayer:function(e){this._layers[e._leaflet_id]=null,this._updateBox(null)},_getMinZoomLevel:function(){var e,t=-1;for(e in this._layers)null!==this._layers[e]&&this._layers[e]>t&&(t=this._layers[e]);return t},_updateBox:function(t){var o=this._getMinZoomLevel();null!==t&&e.DomEvent.preventDefault(t),-1==o?this._container.innerHTML=this.options.minZoomMessageNoLayer:this._container.innerHTML=this.options.minZoomMessage.replace(/CURRENTZOOM/,this._map.getZoom()).replace(/MINZOOMLEVEL/,o),this._map.getZoom()>=o?this._container.style.display="none":this._container.style.display="block"},onAdd:function(t){return this._map=t,this._map.zoomIndicator=this,this._container=e.DomUtil.create("div","leaflet-control-minZoomIndicator"),this._map.on("moveend",this._updateBox,this),this._updateBox(null),this._container},onRemove:function(t){e.Control.prototype.onRemove.call(this,t),t.off({moveend:this._updateBox},this),this._map=null}});return t},window),function(e,t){"function"==typeof define&&define.amd?define(["leaflet"],e):"object"==typeof exports&&(module.exports=e(require("leaflet"))),"undefined"!=typeof t&&t.L&&(t.L.OverPassLayer=e(L))}(function(e){var t=require("js-clipper"),o=e.FeatureGroup.extend({options:{debug:!1,minZoom:15,endPoint:"http://overpass-api.de/api/",query:"(node({{bbox}})[organic];node({{bbox}})[second_hand];);out qt;",timeout:3e4,retryOnTimeout:!1,noInitialRequest:!1,beforeRequest:function(){},afterRequest:function(){},onSuccess:function(t){for(var o=0;o=200&&e.status<400?(this.options.onSuccess(JSON.parse(e.response)),this._onRequestLoadCallback(t)):(this._onRequestErrorCallback(t),this.options.onError(e)),this._onRequestCompleteCallback(t)},_onRequestTimeout:function(e,t,o){this.options.onTimeout(e),this.options.retryOnTimeout?this._sendRequest(t):(this._onRequestErrorCallback(o),this._onRequestCompleteCallback(o))},_onRequestLoadCallback:function(e){this._setLoadedBounds(e),this.options.debug&&this._addResponseBoxes(this._getRequestBoxes())},_onRequestErrorCallback:function(e){this.options.debug&&this._removeRequestBox(this._buildRequestBox(e))},_onRequestCompleteCallback:function(e){if(this.options.afterRequest(),this._hasNextRequest()){var t=this._getNextRequest();this._removeNextRequest(),t()}else this._setRequestInProgress(!1)},onAdd:function(t){this._map=t,this._map.zoomIndicator?(this._zoomControl=this._map.zoomIndicator,this._zoomControl._addLayer(this)):(this._zoomControl=new e.Control.MinZoomIndicator(this.options.minZoomIndicatorOptions),this._map.addControl(this._zoomControl),this._zoomControl._addLayer(this)),this.options.debug&&(this._requestBoxes=e.featureGroup().addTo(this._map),this._responseBoxes=e.featureGroup().addTo(this._map)),this.options.noInitialRequest||this._prepareRequest(),-1!==this.options.query.indexOf("({{bbox}})")&&this._map.on("moveend",this._prepareRequest,this)},onRemove:function(t){e.LayerGroup.prototype.onRemove.call(this,t),this._ids={},this._loadedBounds=[],this._requestInProgress=!1,this._zoomControl._removeLayer(this),t.off("moveend",this._prepareRequest,this),this._map=null},getData:function(){return this._data}});return o},window); \ No newline at end of file diff --git a/src/OverPassLayer.js b/src/OverPassLayer.js index dd14ec3..a95f937 100644 --- a/src/OverPassLayer.js +++ b/src/OverPassLayer.js @@ -524,7 +524,7 @@ this._requestInProgress = false; this._zoomControl._removeLayer(this); - map.off('moveend', this.onMoveEnd, this); + map.off('moveend', this._prepareRequest, this); this._map = null; },