Created
May 17, 2016 15:50
-
-
Save andygup/a55636ec872bc3b4ba631de262343fb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
/* | |
* Utility library for deleting all features in a feature layer. | |
* Use this to reset demo feature layers. | |
* WARNING: this will delete EVERYTHING! | |
*/ | |
function CleanFeatureLayer(featureLayer, callback) | |
{ | |
require(["esri/request"], function (esriRequest) { | |
esriRequest({ | |
url: featureLayer.url + "/deleteFeatures", | |
content: { f: 'json', where: '1=1'}, | |
handleAs: 'json' | |
},{usePost:true}).then( function(response) | |
{ | |
callback && callback(true,response); | |
}, | |
function(error) | |
{ | |
callback && callback(false,error); | |
}); | |
}); | |
} | |
/** | |
* BE CAREFUL! :-) | |
*/ | |
function InitCleanFeatureLayer(featureLayer){ | |
CleanFeatureLayer(featureLayer, function(success){ | |
CleanFeatureLayer( featureLayer, function(success, response) | |
{ | |
console.log("FeatureLayer cleaned: " + success); | |
featureLayer.refresh(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment