Sunday, 8 March 2015

arcgis javascript api - what is the right way to delete all features from featureLayer


I have a featureLayer and I don't want to kill it and create another one. I want to delete all features from the current featureLayer. I found that I can use applyEdits method but in order to use it I need to have all features I want to delete. Whilst I don't want to store them separately. Do you know a better way to empty my featureLayer when using the ArcGIS Javascript API?



Answer



Use featureLayer.selectFeatures() with, as Kirk suggested, a where clause that will return all your features. Once you have all your features, pass them to applyEdits() as the deletes.


No comments:

Post a Comment