jawj / OverlappingMarkerSpiderfier-Leaflet

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

Programmatically trigger event #51

Closed tverilytt closed 4 years ago

tverilytt commented 4 years ago

Hi!

Love the OMS, works great :-)

Just wanted to check if it is possible to programmatically trigger e.g. the "spiderfy" event?

Use case being populating a group of related markers, where one is kind of "current", and at that marker position, another marker is also present. Desire is to show both those markers initially...

Cheers -jo

jawj commented 4 years ago

Have you tried simply programmatically 'clicking' the marker that's "current"? https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click

tverilytt commented 4 years ago

@jawj Yes...found the way to do it in comment here: https://stackoverflow.com/a/38313970/4878494

marker.getElement().click()

Cheers -jo