Skip to content

Add a delete button for markers in popups when using a local HTML file in Folium #2099

Closed
@dhyanKaro

Description

@dhyanKaro

I’m working with Folium and generating a map saved as a local HTML file using save(). I’d like to add functionality where each marker in the popup has a delete button (such as a trash icon) that allows the user to remove the marker from the map permanently. Something like this for the trash icon:

html = f"""<div><a href="#" class="delete-marker" data-marker-id="{marker_id}" title="Remove this marker">
                <i class="fa fa-trash"></i>
              </a></div>"""
marker = folium.Marker(location=[lat, lon], popup=html, ...)

However, I’m not sure how to implement the functionality to actually remove the marker from the map after the button is clicked, especially when working with a static, locally saved HTML file. Is there a way to achieve this with Folium, or would I need to implement custom JavaScript for this behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions