jawj / OverlappingMarkerSpiderfier-Leaflet

Deals with overlapping markers in the Leaflet maps API, Google Earth-style
253 stars 68 forks source link

keepSpiderfied does nothing #41

Closed ultimate-tester closed 4 years ago

ultimate-tester commented 6 years ago

I'm expecting keepSpiderfied to keep all the spiderfied markers to be expanded, instead it changes nothing to the behaviour, I still have to click a markergroup to expand them, and when I click another group, the old one collapses again.

I want functionality that a user does not have to click at all, all groups are expanded by default. Is this possible? Isn't this what the keepSpiderfied option is supposed to do?

magicmb commented 4 years ago

Looked at this topic by chance & my impression is that the behaviour works as it should.

The default keepSpiderfied: false won't allow you to click / select other markers after expanding the spiderfield nor click again to hide your current marker while keeping everything "spiderfied". Setting it to keepSpiderfied: true will

The default closes the spiderfield upon selecting and displaying the popup of the marker in question as can be seen in the demo: OverlappingMarkerSpiderfier-Leaflet/demo.html

To be honest the functionality you're expecting would be a right nightmare from my point of view if it were the default behaviour which might explain why it's not available.

​ Suspect you probably wrote a bit of code yourself to expand each marker along the lines of:

getMarkers().forEach(marker => ... if (marker['_omsData'] != null) ... trigger('click', marker)

... or whatever actual code is req to expand all the markers. However if the triggering 'click' on a marker affects the previous selections then in all probability you'll have to tweak / rewrite oms.js code to create new functionality which is nowhere to be found in the docs.

Documentation:

keepSpiderfied (default: false)

By default, the OverlappingMarkerSpiderfier works like Google Earth, in that when you click a spiderfied marker, the markers unspiderfy before any other action takes place.

Since this can make it tricky for the user to work through a set of markers one by one, you can override this behaviour by setting the keepSpiderfied option to true.

ultimate-tester commented 4 years ago

I misused the library for my use case, which lead to this issue report. I simply wanted the markers not at the precise coordinate, but an offset image and a line pointing to the coordinate instead to prevent overlaps.

Since the behaviour is as intended, I'll close the issue. Thanks!