geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

Cannot read properties of undefined (reading 'slice') upon finishing rotating polygon #1391

Closed rrsouzza closed 1 year ago

rrsouzza commented 1 year ago

image

So, this error is happening every time I click to Finish rotating. Note that this does not happen once I finish drawing/rotating the polygon, but once I click on the control button (or it's action) to disable the rotating mode (therefore calling toggleGlobalRotateMode(), disableGlobalRotateMode() and so on).

Below is a screenshot of my map after clicking to Finish rotating. My polygon is left with all 4 markers still displayed, and I can still rotate the polygon if I click and drag the markers. Even though the "Finish" action button disappears (which should happen once you disable whatever mode was active), the rotateMode still seems to be active since I can still rotate and therefore edit the polygon (pm:create continues to be triggered).

image Chrome

image Firefox

I have tried to reproduce this error on JSFiddle, but I was not successfull. I replicated almost every aspect of my own component, but nothing caused this error to happen.

A few more details:

Falke-Design commented 1 year ago

I'm sorry but we can't help you until you share a reproducable demo.

Try to check if you are listening on a event like pm:update, pm:change, pm:rotate, ... where you maybe modify the coordinates.

Or maybe you have a polyline with empty coordinates? You can try to find the problem layer with:

L.PM.Utils.findLayers(this.map).filter(
      (l) => l instanceof L.Polyline
    ).forEach((layer) => {
      console.log(layer, layer.getLatLngs());
      layer.pm.disableRotate();
    });