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

The pm: snapdrag event does not fire after clicking at the moment of intersection #800

Closed
CodeXiD opened this issue Mar 1, 2021 · 25 comments
Labels
bug fixed Issues that are fixed in develop or in a PR

Comments

@CodeXiD
Copy link

CodeXiD commented Mar 1, 2021

Good day, I ran into a problem, the solution to which I cannot find.
I have a tooltip that shows the area of ​​a plot, changing it is called on the pm: snapdrag event. But the problem is that if you make an intersection and click on the mouse button to save the area, then the pm: snapdrag event stops generating exactly until I let’s say I do not create a new point for the site. I am attaching a video with a demo. I would be grateful for your help!

20210301-130824-598.mp4
@Falke-Design
Copy link
Collaborator

@jCodeX1 I fixed this, it will be in the next Release. Thx for reporting.

But I think that for your use pm:markerdrag would be the correct event.

@Falke-Design Falke-Design added bug fixed Issues that are fixed in develop or in a PR labels Mar 1, 2021
@CodeXiD
Copy link
Author

CodeXiD commented Mar 1, 2021

@Falke-Design thx )

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design I'm sorry, but I tried pm:markerdrag, and unfortunately for me this event does not fire when the marker is dragged.
Here is my code:

this.editLayer
        .on('pm:enable', (e) => {
          this.onEditModeEnabledHook(e);
        })
        .on('pm:snapdrag', (e) => {
          console.log('snapdrag', e);
          this.onEditVertexMoved(e);
        })
        .on('pm:markerdrag', (e) => {
          console.log('markerdrag', e);
        })
        .on('pm:vertexremoved', (e) => {
          this.onEditVertexRemoved(e);
        })
        .pm
        .enable({ allowSelfIntersection: false });

@Falke-Design
Copy link
Collaborator

@jCodeX1 look into this example: https://jsfiddle.net/falkedesign/6z1f83L5/

Are you using the latest version of Geoman? 2.9.0 console.log(L.PM.version)

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design version 2.7.0 🤔

@Falke-Design
Copy link
Collaborator

I suggest you to update, we implemented this in the latest version

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design what should I update? if I don't have a geoman, I understand that it is included in the leaflet package

@Falke-Design
Copy link
Collaborator

You need to update Geoman. This has nothing to do with Leaflet core.

Update npm: npm install @geoman-io/leaflet-geoman-free@2.9.0
or
Update Html Script: <script src="https://unpkg.com/@geoman-io/leaflet-geoman-free@latest/dist/leaflet-geoman.min.js"></script>

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design yes i did it but the version (L.PM.version) hasn't changed

@Falke-Design
Copy link
Collaborator

Are you using NPM?

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design

Yes, the addiction has appeared, but the version has not changed

Снимок экрана 2021-03-02 в 10 26 17

My code:

console.log(L.PM.version);
      this.editLayer
        .on('pm:enable', (e) => {
          this.onEditModeEnabledHook(e);
        })
        .on('pm:snapdrag', (e) => {
          this.onEditVertexMoved(e);
        })
        .on('pm:markerdrag', (e) => {
          console.log('markerdrag', e);
        })
        .on('pm:vertexremoved', (e) => {
          this.onEditVertexRemoved(e);
        })
        .pm
        .enable({ allowSelfIntersection: false });

@Falke-Design
Copy link
Collaborator

This is weird ...

Maybe it is one of the following points:

  • Call npm install to update the npm-packages local
  • Have you regenerated / rebuild your code?
  • Restart your server

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design Unfortunately, yes, I did all the options listed many times, but this did not solve my problem (

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design

This is my L.PM object, maybe it can help somehow

Снимок экрана 2021-03-02 в 10 39 12

@Falke-Design
Copy link
Collaborator

Maybe you are using Geoman twice ... have you included in your html Geoman directly? Or have you downloaded it anywhere instead of using npm? Maybe you can search through your complete project, search for geoman or pm

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design I performed the following operations, and then I wrote npm install, and that's it, I expected it to work

Снимок экрана 2021-03-02 в 10 49 57

@Falke-Design
Copy link
Collaborator

So it is working now?

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design Yes, fine, I defeated the problem 😌 it was that the geoman was connected via html in my code, I removed that and imported a new plugin, now everything is fine!)
Thank you for your help!)

@CodeXiD CodeXiD closed this as completed Mar 2, 2021
@Falke-Design
Copy link
Collaborator

Nice to hear!

I let this issue open until the fix for pm:snapdrag is fixed

@Falke-Design Falke-Design reopened this Mar 2, 2021
@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design one more question, after crossing my faces take their original form, but at the same time I do not know which hook to use to get the event after returning the figure to a valid view, is there any hook for changing the figure as a whole?

@Falke-Design
Copy link
Collaborator

You can listen on pm:edit, this event is fired, when the marker drag is finished.

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design a little wrong, when crossing, dragging ends, and I still have coordinates (for example, NN coordinates), but after dragging in the intersection, when I release the mouse button, the figure takes on a new view (with coordinates for example N1-N2), as a result, I save the coordinates NN , but about the new coordinates N1-N2, I don’t know, how can I handle this case?

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design pm:edit also does not fire after mouse release when crossing

@Falke-Design
Copy link
Collaborator

Yes you are right ...

This is the order of events, maybe this helps you:

  1. pm:markerdragstart
  2. pm:markerdrag
  3. pm:markerdragend
    3.1. With intersection pm:intersect
    3.2. Without intersection pm:edit

@CodeXiD
Copy link
Author

CodeXiD commented Mar 2, 2021

@Falke-Design The problem is that pm: intersect only fires when I made an intersection (after releasing the mouse button, it won't work), and pm:markerdragend just fires when the mouse is released, and I don't know the final state of the shape. So my guess is that this will no longer be a problem when the snapdrag hook works.

codeofsumit pushed a commit that referenced this issue Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed Issues that are fixed in develop or in a PR
Projects
None yet
Development

No branches or pull requests

2 participants