-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
outFields values #6
Comments
That's difficult to do with the clustered graphic, but there is an array property called Thanks. |
This did indeed make stuff works! clusterLayer.on("clusters-shown", countAttributes);
I did saw that the graphics layer as a 'attributes' field which is empty, wouldn't that be a more logical place to store things, which makes it easier for coders to find? |
This actually gave me an idea to also add a new event called |
Super cool! |
To be honest i'm not completely sure if this is really a bug/issue; perhaps i'm misinterpreting something....
When the fields are outputted and grouped as a cluster, they do not get a correct value. Instead of an array of unique values or a sum of alle values (when numeric), the value of the last point that's added to the cluster is given as value.
For example, let's say in choose a extra outField called FATALITIES. When the clusters are created, and we're looping over them, the clusterCount field works perfect and shows the exact number (sum) of points that's inside the cluster. But the FATALITIES field has the value of the latest point that was added in the cluster. Therefore, and since the features are only present as graphics, it is impossible to do any calculations with the fields, other then with the clusterCount field.
So in the example below the clusterCount will return a total of almost 80.000, which equals almost 80.000 that occurred in Africa between 1997 and 2012. But the fatality count will give a very low number in the range of hundreds; unfortunalty a lot more people died due tot those 80.000 conflicts.
var ext = map.extent;
var features = [];
var conflictCount = 0;
var fatalitiesCount = 0;
for (var i = 0; i < clusterLayer.graphics.length; i++) {
var gra = clusterLayer.graphics[i];
if (ext.intersects(gra.geometry)) {
features.push(gra);
}
for (var i = 0; i< features.length; i++){
conflictCount += features[i].attributes.clusterCount;
fatalitiesCount += features[i].attributes.FATALITIES;
}
console.log(conflictCount+' '+fatalitiesCount);
}
The text was updated successfully, but these errors were encountered: