Skip to content

Commit

Permalink
Merge pull request #713 from Esri/patch691
Browse files Browse the repository at this point in the history
make sure features stop drawing when layer is removed
  • Loading branch information
patrickarlt committed Dec 31, 2015
2 parents a3e010e + c146424 commit eb1f20b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Layers/FeatureLayer/FeatureLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ EsriLeaflet.Layers.FeatureLayer = EsriLeaflet.Layers.FeatureManager.extend({
map.on('zoomstart zoomend', function(e){
this._zooming = (e.type === 'zoomstart');
}, this);
this._removed = false;

return EsriLeaflet.Layers.FeatureManager.prototype.onAdd.call(this, map);
},

onRemove: function(map){
this._removed = true;
for (var i in this._layers) {
map.removeLayer(this._layers[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/FeatureLayer/FeatureManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
}

// no error, features
if(!error && featureCollection && featureCollection.features.length){
if(!error && featureCollection && featureCollection.features.length && !this._removed){
// schedule adding features until the next animation frame
EsriLeaflet.Util.requestAnimationFrame(L.Util.bind(function(){
this._addFeatures(featureCollection.features, coords);
Expand Down

0 comments on commit eb1f20b

Please sign in to comment.