Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ArcGIS JSAPI: Query Distinct, the old fashion way.
require([..., "esri/tasks/query", "esri/tasks/QueryTask", "dojo/_base/array",...],
function (..., Query, QueryTask, arrayUtils,...) {
...
// urls faked to protect the innocent kitties
var qTask = new QueryTask("http://www.cat-hurders.com:6080/arcgis/rest/services/CatSightings/MapServer/"),
query = new Query();
// set up the parameters to query for the breeds
query.where = "1=1";
query.outFields = ["breed"];
query.returnGeometry = false;
// execute the query
qTask.execute(query).then(function (featureSet) {
var features, i;
// collect the list of breeds
features = arrayUtils.map(featureSet.features, function (feature) {
return feature.attributes.breed;
});
// sort the list
features.sort();
// pick through each item in the list, and if it matches the item before, remove it.
for (i = features.length - 1; i > 0; i--) {
if (features[i] === features[i-1]) {
features.splice(i, 1);
}
}
// do something with the list.
...
});
...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.