How to apply specific marker click function in Overlapping Marker Spiderfier for Leaflet?

225 Views Asked by At

I have a map and some markers on that map. I have used leaflet js. Sometimes multiple markers are in the same geo location. And for this reason some markers are hidden. So to prevent that I am using Overlapping Marker Spiderfier for Leaflet. And that hidden issue if fixed.

I added my start marker to oms as follows,

oms.addMarker(startMarker);

But actually my markers are connected markers. That means one marker for start location and one marker for stop location. So there are always will be start-strop indicating markers. So there is a function whenever I click the start marker it is going to the stop marker. Since I have to user the overlapping marker spiderfier I had to remove that function.

Before removing the functions it was like this,

startMarker = L.marker(latitude, longitude], {
        icon: icon,
      }).addTo(this.map).on("click", (event) => {
        this.map.flyTo(L.latLng([stopLat, stopLong]),
          15);
      });

In oms there is a click event so I added the above code inside the following,

oms.addListener('click', (marker: any) => {

});

But it is not working. What it does is when I click any start marker, every start marker is going to the same stop marker. But it should go to their respective stop markers. So what I need to know is how can do that with oms.addListener?

0

There are 0 best solutions below