Select to view content in your preferred language

Point Clustering - changing query won't update map

1593
6
01-23-2017 10:13 AM
South_JordanCity_of
Frequent Contributor

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

0 Kudos
6 Replies
FC_Basson
MVP Regular Contributor

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.

0 Kudos
South_JordanCity_of
Frequent Contributor

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

0 Kudos
South_JordanCity_of
Frequent Contributor

..and something is still screwy with the pop-ups (can't close it), I'm still working on it....

0 Kudos
South_JordanCity_of
Frequent Contributor

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)

0 Kudos
FC_Basson
MVP Regular Contributor

And let's tag the developer alaframboise-esristaff

0 Kudos
South_JordanCity_of
Frequent Contributor

here's a working example:

Cluster 

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

0 Kudos