nickcam / FlareClusterLayer

ArcGIS javascript custom graphics layer. Create clusters...with flares.
https://flareclusterlayer.azurewebsites.net/index_v4.html
MIT License
134 stars 51 forks source link

Overlapping Icons #26

Closed apaleja closed 6 years ago

apaleja commented 7 years ago

Is there any way to avoid icon overlapping ? I tried increasing clusterRatio but at lower zoom levels clusters are still overlapping.

Any Guidance will be helpful.

nickcam commented 7 years ago

Hi @apaleja, just keep on making the cluster ratio bigger the lower you get. If your data is quite close together when you zoom in more you'll eventually hit a limit where multiple clusters are created where one used to be.

You may just need to add a watch to the zoom property of the view and set the cluster ratio to a different value for every zoom level so it suits your dataset...you may have done this already though. If you have a page that demonstrates the issue feel free to link it here to take a look at.

apaleja commented 6 years ago

@nickcam one of the reason I notices was on every pan it reclusters points. Rather than reclustering on every pan, is there any way to make it static for particular zoom level ? something like : leaflet cluster

nickcam commented 6 years ago

Hi @apaleja, you could do that, would require some changes though. It refreshes on pan as well by default as it only calculates the required clusters for the visible area, just to cut down on processing time if the point isn't in the current extent anyway.

You can turn it off by setting refreshOnStationary property to false in constructor options. But then it wouldn't re-cluster on a zoom change either. So you'd just have to swap out the watch on stationary with a watch on zoom or scale property instead and then use the redraw code on the handler of that watch.

Also you'd have to include all points in the draw function so they can be clustered....currently they get excluded by checking the extent. That would take some rework to then calculate clusters based on the world bounds instead of just the current extent.

Make sense?

apaleja commented 6 years ago

Hi @nickcam Thanks for quick reply. I am using 3.x and I think refreshOnStationary option is available for 4.x version. Is there any option available for 3.x version ?

As you have mentioned, FlareCluster is inspired from Esri's version, I was thinking of using clustering algorithm from esri's to swap grid based clustering to proximation based clustering. Any guidance for that ? or any better way to archive same ?

nickcam commented 6 years ago

Hi @apaleja, ok no worries. Same sort of deal applies for v3.

If you want to change the cluster ratio based on zoom set to cater for overlapping icons, just set the clusterRatio property to whatever you want based on the current zoom level at the start of the _clusterData() function.

If you really want to limit re-clustering to be on zoom only, then change the event on "extent-changed" to be a "zoom-changed" event in _setMap() function. You'd have to rework the clustering logic to do it for the whole world as discussed in the previous comment though.