folium icon indicating copy to clipboard operation
folium copied to clipboard

Make it possible for a marker to link to another marker

Open augusto-herrmann opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. It may be a common use case that a marker might relate to other relevant makers. It would be great if a marker's popup could contain links to other markers.

Describe the solution you'd like Have a standard way to include in a popup links to other markers. The link, once activated, would:

  • deactivate its own marker's popup,
  • center the map view on the target marker,
  • and activate the target marker's popup.

Describe alternatives you've considered Just referencing the other marker by an id, with no link, but that is confusing, awkward, unwieldy, and impractical for the end user, which not only would have to keep in mind an id but also have to search for it around the map.

Additional context That would make it possible for users to easily navigate between relevant markers.

However, activating markers by links might not be a feature that leaflet.js itself supports, I haven't checked yet.

augusto-herrmann avatar Jan 15 '22 02:01 augusto-herrmann

Hello @augusto-herrmann,

I wanted to let you know that I implemented the possibility to link markers. Now, users can include links to other markers in a popup, which, when activated, closes the current popup, centers the map view on the target marker, and opens the target marker's popup. You can see the changes I made in the #1863. I hope this implementation meets your requirements. I would appreciate any feedback you may have.

Best Regards, @yschopfer19

yschopfer19 avatar Jan 23 '24 21:01 yschopfer19

Hi @yschopfer19,

thanks for the implementation! It is appreciated. I have yet to find some time to try it out in practice, but from your description and code it already does seem pretty good and useful.

It could be even better if we could define our own custom markup. That is, by just using an identifier in the link within a popup's markup (e.g. <a href="#marker-2">go to marker popup 2</a>, it would then create the navigation and activation as you've described. That way authors would have more flexibility when creating the popup content.

augusto-herrmann avatar Jan 24 '24 11:01 augusto-herrmann