Wildhoney / Leaflet.FreeDraw

:earth_asia: FreeDraw allows the free-hand drawing of shapes on your Leaflet.js map layer – providing an intuitive and familiar UX for creating geospatial boundaries similar to Zoopla and others. Included out-of-the-box is the concaving of polygons, polygon merging and simplifying, as well as the ability to add edges and modify existing shapes.
https://freedraw.herokuapp.com/
MIT License
544 stars 103 forks source link

TypeError: Cannot read properties of undefined (reading 'x') #184

Closed gmarshall56 closed 3 years ago

gmarshall56 commented 3 years ago

I am using this Leaflet.FreeDraw library in a React application. This is what I have coded: ` import leaflet-freedraw/dist/leaflet-freedraw.iife; ... const freeDraw = new FreeDraw();

const toggleFreeDraw = () => {
    if(freeDrawEnabled){
        geomanIsDrawing.current= false;
        freeDraw.mode(FreeDraw.NONE);
    }else{
        geomanIsDrawing.current= true;
        freeDraw.mode(FreeDraw.CREATE | FreeDraw.EDIT | FreeDraw.DELETE);
    }
    freeDrawEnabled = !freeDrawEnabled;
}

map.addLayer(freeDraw);
freeDraw.mode(FreeDraw.NONE);
map.pm.Toolbar.createCustomControl(
{name: 'myFreeDrawer2',
    block: 'draw',
    title: 'Draw Freehand Polygons',
    onClick: toggleFreeDraw,
    className: 'icon-freedraw'
    });

`

When I finish drawing a freehand polygon on my map I get this error:

leafletFreeDrawError

Can you please advise? Thank you for your time.

gmarshall56 commented 3 years ago

Never mind.. I think I figured this one out...

MaciejGL commented 2 years ago

Could You describe what was the problem and how did you solve it? Thanks

ccxh505398633 commented 9 months ago

我也碰到一样的问题,使用已下方式解决,在leaflet创建实例时设置属性preferCanvas为false