I have been using the L.esri.Query (Esri Leaflet) method "count" to add up the total amount of features falling within a given area. That works fine when using individual features classes at a time (so querying within one file/feature class only), but if I want to add the total features falling within my area regardless of feature class (e.g., points and polygons), I can't seem to get a correct output. Maybe my JavaScript code is wrong... Here is what I have so far:
var stops_count = L.esri.query({
url: stopsUrl
}).within(neigh_match);
var parks_count = L.esri.query({
url: parksUrl
}).within(neigh_match);
var count1 = stops_count.count(function(error, count){
});
var count2 = parks_count.count(function(error, count){
});
var total_counts = count1 + count2;
console.log("counts = " + total_counts);
But what the console actually shows is: counts = [object XMLHttpRequest][object XMLHttpRequest]
So I assume I am not using correct code to add up these counts from the two features classes, one being light rail stops and the other parks. Again, if I run the functions independently I get individual totals (2 for the stops and 14 for parks), but I want to be able to get a summary count of 16 for all the contained features in my area.
I got these examples for querying counts from https://esri.github.io/esri-leaflet/api-reference/tasks/query.html.
Any ideas?