diff --git a/spec/Layers/FeatureLayer/FeatureLayerSpec.js b/spec/Layers/FeatureLayer/FeatureLayerSpec.js index 0815f3046..e41e23ac9 100644 --- a/spec/Layers/FeatureLayer/FeatureLayerSpec.js +++ b/spec/Layers/FeatureLayer/FeatureLayerSpec.js @@ -143,10 +143,30 @@ describe('L.esri.FeatureLayer', function () { }); it('should add features back to a map', function () { - layer.removeLayers([1]); + layer = L.esri.featureLayer({ + url: 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', + timeField: 'time', + pointToLayer: function (feature, latlng) { + return L.circleMarker(latlng, { + color: 'green' + }); + } + }).addTo(map); + + var createSpy = sinon.spy(); + layer.on('createfeature', createSpy); + + var removeSpy = sinon.spy(); + layer.on('removefeature', removeSpy); + + layer.createLayers(features); + layer.removeLayers([1, 2]); layer.addLayers([1]); + expect(map.hasLayer(layer.getFeature(1))).to.equal(true); - expect(map.hasLayer(layer.getFeature(2))).to.equal(true); + expect(map.hasLayer(layer.getFeature(2))).to.equal(false); + expect(createSpy.callCount).to.equal(2); + expect(removeSpy.callCount).to.equal(2); }); it('should fire a addfeature event', function () { diff --git a/src/Layers/FeatureLayer/FeatureLayer.js b/src/Layers/FeatureLayer/FeatureLayer.js index 84e6fe9f3..e674838ce 100644 --- a/src/Layers/FeatureLayer/FeatureLayer.js +++ b/src/Layers/FeatureLayer/FeatureLayer.js @@ -120,9 +120,6 @@ export var FeatureLayer = FeatureManager.extend({ // add the layer if the current zoom level is inside the range defined for the layer, it is within the current time bounds or our layer is not time enabled if (this._visibleZoom() && (!this.options.timeField || (this.options.timeField && this._featureWithinTimeRange(geojson)))) { - this.fire('addfeature', { - feature: newLayer.feature - }, true); this._map.addLayer(newLayer); } } @@ -133,9 +130,6 @@ export var FeatureLayer = FeatureManager.extend({ for (var i = ids.length - 1; i >= 0; i--) { var layer = this._layers[ids[i]]; if (layer) { - this.fire('addfeature', { - feature: layer.feature - }, true); this._map.addLayer(layer); } }