Skip to content

Geoman plugin event handlers on layers are not preserved after a cut. #2165

Open
@hansthen

Description

@hansthen

Describe the bug
The geoman plugin allows users to add event handlers to newly created layers. After a making a cut using the scissor tool, these event handlers are lost.

To Reproduce

    m = folium.Map(
        location=[40.73, -73.94],
        zoom_start=12,
    )

    click = JsCode("""
      (e) => {
          console.log(e.target.toGeoJSON());
      }
      """
    )

    gm = GeoMan(
        on={
            "click": click,
        }
    ).add_to(m)

Expected behavior
I expect the event handlers to still exist after cutting.

Additional context
On the Geoman forum, I discovered that the "cut" action creates a new layer object. Easiest would be to add the event handler also on the "pm:cut" event.

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