1

I'm looking for a way to export the coordinates from markers on the map in folium. I know that one can get the coordinates over the current mouse position, but I would like to use this information for another problem.

Ideally I would like to be able to move a marker and get the new coordinates of this marker. At the moment my markers are defined as follows:

def add_markers(coordinates, building):
  marker = folium.Marker(
    location=coordinates,
    popup=(f"<stong>{building}</stong>"),
    draggable=True)
  marker.add_to(map_with_markers)

When I move the marker on the map this is not saved anywhere and also the coordinates of the marker stay the same. Any ideas?

1 Answer 1

0

At least at Folium v0.13 that's not seem to be possible. Check issue #1578 in folium's github repository.

If you are using Jupyter to render your maps, I suggest you to try a different library like ipyleaflet. It has a great interactive features. Check this blog post for an example of what you ask for. I paste here a resume:

# Define a callback function for an event on a marker
def handle_observe(event):
    print(event)

# Call the callback function whenever the location of the marker changes
marker.observe(handle_observe, 'location')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.