Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fire pm:edit after drag marker end in a huge polygon #1501

Open
dvaltrick opened this issue Jul 5, 2024 · 3 comments
Open

Do not fire pm:edit after drag marker end in a huge polygon #1501

dvaltrick opened this issue Jul 5, 2024 · 3 comments

Comments

@dvaltrick
Copy link

Hi, everyone!

I am facing an interesting problem with the library.
It only happens with one specific polygon, this polygon has more than 5K points but I have polygons with 6K points that work well.
The problem is, that I am editing the polygon, and when the drag ends it returns a console.log "listener not found" for each point of the polygon and does not fire pm:edit, debugging I saw that the console message was for "dragend" event.

here we have a video showing the problem

Gravacao.de.Tela.2024-07-05.as.09.09.00.mov

image

Here how we are enabling edition and setting pm:edit listener

    map.eachLayer((layer) => {
      if (layer.options?.payload?.zoneId && layer?.options?.payload?.zoneId === zoneId) {
        layer.pm?.enable({
          allowSelfIntersection: false,
          snappable,
          limitMarkersToCount: 100,
          limitMarkersToViewport: true,
        });

        layer.on('pm:edit', (e) => {
          const { id } = e.layer.options.payload;
          const points = e.layer.getLatLngs()[0];

          editedLayers.set(id, { id, points });
          onEdited(editedLayers);
        });
      }
    });

Polygon

londrina.txt

@Falke-Design
Copy link
Collaborator

Your polygon has self-intersection. This is the reason why the vertex jumps back and no pm:edit is fired (because no edit was done). You can disable this with setting the option allowSelfIntersection to true.

You can find the intersecting points with that:

layer.on('pm:intersect', (e) => {
        L.geoJSON(e.intersection).addTo(map)
});
layer.pm.enable();

I was not able to reproduce the "listener not found" warning. Which version of Geoman and Leaflet are you using?

@dvaltrick
Copy link
Author

Thank you for being so helpful @Falke-Design
I tested in here and allowed self-intersection of the polygon edit normally.
I will understand where the intersection is to remove it.

About the versions I am using
leaflet: 1.8.0
leaflet-geoman-free: 2.14.2

@Falke-Design
Copy link
Collaborator

Then I can close the issue?

btw. I strongly suggest to update to Leaflet 1.9.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants