Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.98k stars 994 forks source link

leaflet draw not working with latest angular version 10 #1005

Open archanatiwari opened 3 years ago

archanatiwari commented 3 years ago

How to reproduce

What behaviour I'm expecting and which behaviour I'm seeing

Steps:

image

kragoth commented 3 years ago

@archanatiwari this issue is occurring for me as well when I upgraded from angular 9 to 11.

I think I know the problem too.

The readableArea function is using an undefined variable. It seems that in the upgrade to ng10/11 "strict" mode has been turned on. Thus, the use of an undeclared variable is not allowed.

Fixing this should be a matter of adding the "type" variable to the list of variable declarations in the readableArea function.

It looks like someone has already raised a PR to fix this issue here.

kragoth commented 3 years ago

It seems quite a few people have raised PRs to fix this issue but, there's no approvals going on it seems. Not sure what we need to do to get them merged so this issue can be resolved.

In the meantime my current "hack" to get around this issue is to do this:

    // This is a hack due to a bug in leaflet.draw
    // https://github.com/Leaflet/Leaflet.draw/issues/1005
    (window as any).type = undefined;

I reset the value of the variable on component destroy (in angular) so... hopefully no leaking will occur.

matkoniecz commented 3 years ago

Not sure what we need to do to get them merged so this issue can be resolved.

It is pretty clear that this plugin is abandoned, see https://github.com/Leaflet/Leaflet.draw/graphs/contributors

Not sure is there a viable replacement - alternative project or a maintained fork