Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should FeatureLayer.eachFeature() be limited to returning the current snapshot? #933

Closed
jgravois opened this issue Mar 6, 2017 · 1 comment · Fixed by #936
Closed

should FeatureLayer.eachFeature() be limited to returning the current snapshot? #933

jgravois opened this issue Mar 6, 2017 · 1 comment · Fixed by #936

Comments

@jgravois
Copy link
Contributor

jgravois commented Mar 6, 2017

or should we leave that method alone and add eachActiveFeature()?

more info:

patrickarlt [Feb 13]
@jgravois @reames Looks like eachFeature is looping over each layer in the _layer cache which will be all layers. https://github.com/Esri/esri-leaflet/blob/master/src/Layers/FeatureLayer/FeatureLayer.js#L246-L251
GitHub
Esri/esri-leaflet
esri-leaflet - A lightweight set of tools for working with ArcGIS services in Leaflet.

jgravois [Feb 13]
i see then. so if the where filter is added later...

jgravois [Feb 13]
might be worth adding a programmatic option to clear the local cache

patrickarlt [Feb 13]
@jgravois the other option would be to have an "each active layer" that used this._currentSnapshot

patrickarlt [Feb 13]
eachFeature is "do this for every feature the layer knows about ever."

patrickarlt [Feb 13]
might be easier to make a new method that is "do this for every feature that is currently shown on the map"

jgravois [Feb 13]
i know its bad to break things, but i bet everyone expects eachFeature to be _currentSnapshot

jgravois [Feb 13]
i wonder if itd be better to map it that way and add a new eachFeatureEver()

@keithpower
Copy link
Contributor

this got me, i had expected eachFeature to be _currentSnapshot. My quick fix was to expose a method called getCurrentSnapshot that just returned this._currentSnaphot and then i filtered the eachFeature results within my app code. this might expose the internals more then you'd want. so probably best to introduce a new eachActiveFeature() method, i don't like the idea of breaking someones code by changing eachFeature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants