Hello. i'm using arcgis api 4.10 where i want to show the total num of count, let's suppose i have a Map Server service (http://...:.../...//MapServer/13) of customers so i want to show the total number of customers by using service and relevant field like (Number_of_SUM) of this service, how can i do this!!
Irtiza,
Have you looked into StatisticDefintion? This class is for exactly what you are wanting to do.
Thanks Robert,
Can you show some working examples of this!! as it is difficult to understand for me.
Irtiza,
Here is a snipit of code for that:
var statisticDefinition2 = new StatisticDefinition({
statisticType: "count",
onStatisticField: "Muni",
outStatisticFieldName: "muniCount"
});
query.where = "1=1";
query.outStatistics = [statisticDefinition2];
query.groupByFieldsForStatistics = ["Muni"];
query.outFields = ["Muni"];
featureLayer.queryFeatures(query).then(function(results){
...
var count = feat.attributes.muniCount;
...
});
Hi there,
What Robert suggested. You can also use queryFeatureCount on FeatureLayer or FeatureLayerView if you have created a FeatureLayer.
Use FeatureLayerView.queryFeatureCount, if you want to get the total count of features available on the client (fast and performant).
User FeatureLayer.queryFeatureCount, if you want to get the exact number of features that meet your requirements. This will issue a network request to the server.
Thanks Undral,
Can you show some working samples of this!! as it is difficult to understand for me.