mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Support spiderfier-like functionality for clustering

Open ouya99 opened this issue 10 years ago • 13 comments

Is there an easy way to get a spiderfier for markers that share same location?

(as in https://github.com/Leaflet/Leaflet.markercluster/blob/master/example/marker-clustering-spiderfier.html)

What would you suggest to do in such a case of overlapping markers?

Thanks java99

ouya99 avatar Jun 13 '16 09:06 ouya99

Is this feasible @mourner?

lucaswoj avatar Jun 13 '16 17:06 lucaswoj

This is certainly very difficult to do and I don't think we'll be able to tackle this in the short term.

mourner avatar Jun 13 '16 17:06 mourner

This would be a really great feature!

hdrdavies avatar Nov 17 '16 09:11 hdrdavies

Basic spiderfying in mapbox clustering: https://bewithjonam.github.io/mapboxgl-spiderifier/docs/mapbox-gl-cluster-spiderfy.html

Library: https://github.com/bewithjonam/mapboxgl-spiderifier

Forks:

  • mapbox-gl-js; https://github.com/bewithjonam/mapbox-gl-js
  • mapbox-gl-style-spec: https://github.com/bewithjonam/mapbox-gl-style-spec
  • supercluster: https://github.com/bewithjonam/supercluster (sent pull request)

Right now, there is no way of tracking points involved in a cluster. These forks minimally adds support for tracking points in a cluster using a property field starting from configured zoom level.

bewithjonam avatar Nov 28 '16 09:11 bewithjonam

So is spidering points with the same coordinates possible in Mapbox GL js? Can anyone explain how to achieve this?

I'm clustering some points up till a certain zoom level, then they just overlap each other since they have the same lat/longs. Is there any way to spider them out when they come out of a cluster? Following this example: https://www.mapbox.com/mapbox-gl-js/example/cluster

Sorry to reopen this issue, let me know if I should open a new one instead.

digitaltopo avatar Mar 11 '17 22:03 digitaltopo

Same question. The current support for spiderfier is complex. New version of supercluster supports getChildren() used by spidifier, but it has not yet been merged to mapbox-gl-js (https://github.com/mapbox/mapbox-gl-js/issues/3318). There is a working demo of supercluster/mapbox-gl-js (https://bl.ocks.org/ryanbaumann/f7eb6c9fd2b8a9a2942b0ff77b2b583a) but with older version of supercluster. So it seems that we still need several forks as mentionned on https://github.com/mapbox/mapbox-gl-js/issues/2723#issuecomment-263220618.

Could this issue be reopenned?

jcisio avatar Mar 13 '18 15:03 jcisio

For those who are ReactJS lover. This is a solution to show the points at same location using spiderifier. https://github.com/thuanmb/react-mapbox-gl-spiderifier

thuanmb avatar Mar 18 '18 04:03 thuanmb

I also vote for reopening this issue. It is a very basic use case (f.i. artworks in e museum, multi-purpose buildings, etc.) so it is strange that there is no standard solution for this.

EgbertBleyenburg avatar Nov 22 '18 09:11 EgbertBleyenburg

  • getChildren
  • getLeaves Above methods are required to find features in a cluster. These methods have been exposed in recent versions of mapbox-gl-js.

Using those methods, you can get the features in a cluster. And then call spiderifier to spiderfy them. Doc for the same.

No forks are required anymore. Only mapboxgl-js and mapboxgl-spiderfier library.

bewithjonam avatar Nov 22 '18 10:11 bewithjonam

Thanx for quick reply: Maybe i do not fully understand yet: The problem is not getting the features in the cluster, but showing all underlying symbols when you zoom in and the cluster evaporates..... But I'll try and see if I can get something working with this spiderfy library....

EgbertBleyenburg avatar Nov 22 '18 12:11 EgbertBleyenburg

If anyone looks for a solution, I am working on one right here: https://github.com/mapbox/mapbox-gl-js/issues/7120

EgbertBleyenburg avatar Nov 23 '18 10:11 EgbertBleyenburg

Here is an vanilla example of spiderifier using a layer or markers if anyone needs it. Github repo, Codepen

I think this is a common issue for people using cluster. It would be nice if anyone at Mapbox could add it to examples.

FranckKe avatar Sep 21 '19 19:09 FranckKe

Sorry for late re-opening. Any standard solution available? Any Mapbox sample around? Checked last comment: thanks @FranckKe seems to be a working solution. closing again

ouya99 avatar Sep 21 '19 19:09 ouya99