Hi all!
based on the modified esri example for clustering points I found on GitHub at
GitHub - Esri/cluster-layer-js: One example of how to cluster many point features,
I'm trying to figure out how to update the map when the query changes.
For example, I have a map that shows all 2016 traffic accidents. Everything works fine, points are clustering, etc.. The user should have the option to show only non-injury accidents with the click of a checkbox or button. The query works, but the map still displays all points, regardless of the used (changed) query.
I can't figure out how to redraw/re-create the clusterfeaturelayer and show only non-injury accidents.
Any ideas?
Thanks for your help!!
Marc Seliger
Hi Marc, how are you updating the query? I've only found that it can be done by setting the private attribute "_where" like for a layer definition query and then the cluster graphics layer does not respond to the redraw() function like it should but updates on a map extent change event. It also does not want to respond to setting the layer definition query back to the original where clause.
It seems that it works now for me, but I ended up with a slightly different version of the clustering. Basically, I have a bunch of check boxes that determine the query and pass the queryText to the runQuery function. I also declared the clusterLayer as a global variable. The key was to remove the clusterLayer from the map
map.removeLayer(clusterLayer);
and then call the runQuery function again. This might not be the most elegant coding, but at least it works now. More fine tuning is required regarding icons, map layout, etc...
All files are attached in the zip file.
Cheers!
Marc
..and something is still screwy with the pop-ups (can't close it), I'm still working on it....
ok, after changing all esri file versions to 3.19, the pop-ups are now behaving as they should. Initially, the versions differed (3.19 and 3.11)
And let's tag the developer alaframboise-esristaff
here's a working example:
however, if you look at the console, i get the error
svg.js:43 Error: <circle> attribute cx: Expected length, "NaN".
this is because the map draws over 1000 features. If I take out the non-injury accidents, the error disappears, but I have no idea how to fix it.
any ideas?
Marc