Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a feaureLayer 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 ot use it I need to have all features I want to delete. Whilst I don't want to store them separetly. Do you know a better way to empty my featureLayer when using the ArcGIS Javascript API?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
Won't this return a lot of features to the client? If this is a large dataset it could really be slow. –  Kirk Kuykendall Jun 17 '11 at 16:37
    
The only problem is I can't specify the right where clause - I tried "1 = 1", "OBJECTID > 0", etc. But every time I have an error "FeatureLayer::selectFeatures - query contains one or more unsupported parameters". The code var query = new esri.tasks.Query(); query.where = "1 = 1"; featureLayer.selectFeatures(query, ...); –  Kirill Lykov Jun 20 '11 at 5:46
    
Perhaps, if featurelayer is not connected with any feature service, it doen't support where clauses. What do you think? –  Kirill Lykov Jun 20 '11 at 5:57
    
"if featurelayer is not connected with any feature service, it doen't support where clauses" - that's correct, but if so it also wouldn't support editing. From the API reference: "If the underlying layer ... is from a Feature Service, its features can be edited", implying that your featureLayer IS connected to a feature service –  Stephen Lead Jun 21 '11 at 2:35
    
"it also wouldn't support editing" - I support editing even if it is not connected with service. Hovewer, I had to make some workarounds. –  Kirill Lykov Jun 21 '11 at 10:44
add comment

Try making a REST delete features call with a where clause "1 = 1" or something similar.

share|improve this answer
    
hi is there any syntax to the REST delete features call? could you provide me an example as I am attempting to do that –  jonleech Jan 10 '13 at 2:57
add comment

Use an Update Cursor, selecting all features ("*").

Use IFeature.Delete(), and store when done.

share|improve this answer
    
This question is asking for a JavaScript solution, not ArcObjects. –  Derek Swingley Jun 17 '11 at 16:21
    
Oops...my mistake! Please ignore. –  ujjwalesri Jun 20 '11 at 11:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.