jupyter-widgets / ipyleaflet

A Jupyter - Leaflet.js bridge
https://ipyleaflet.readthedocs.io
MIT License
1.48k stars 363 forks source link

Measure distances and area tool bugging? #1076

Open PennyJClarke opened 1 year ago

PennyJClarke commented 1 year ago

The measure distances and area tool appears to have a bug when used in Jupyter notebook, has anyone else experienced an issue?

When I click on the map to begin a measurement the screen shifts on each click (a uniform amount) and the start of the intended measure point shifts? This video demonstrates the issue:

https://user-images.githubusercontent.com/93473831/203305954-f5b983f5-5e24-4f00-9526-261f1b4b33e5.mp4

This error occurs on the basemap, without having added additional layers, ruling out a projection issue. I am trying to use ipyleaflet through leafmap, and so I also created a new environment containing only Leafmap, to confirm it was not a package conflict, and the error still occurs.

The use of the measure tool is integral to my use of ipyleaflet/leafmap, I thank you for any time, support and guidance you can offer.

giswqs commented 1 year ago

I can confirm this bug. Downgrading ipyleaflet to an older version (e.g., v0.15.0) still has the same issue. I used the measure tool in the past, and it worked fine. This bug is probably caused by some ipyleaflet dependencies, but I am not sure which one.

Peek 2022-11-22 14-08

PennyJClarke commented 1 year ago

Thank you @giswqs, do you think if I went further back in ipyleaflet versions this could solve the issues. The measure tool does work in Leafmap when using a Folium backend (as you suggested I try), but I need the ability to overlay raster images and to use the functions to work codeless, that come with Leafmap ipyleaflet backend.

Is anyone able to help with fixing this bug, please?

Thank you in advance for guidance and support.

Itayor commented 1 year ago

I noticed this bug on versions 0.17.1 and 0.17.2, but it work well on versions 0.16.0 and version 0.17.0

iacisme commented 1 year ago

I too am experiencing this issue.

ipyleaflet version = 0.17.2

I was using leafmap and noticed this issue. I went online and found this 311 on the leafmap github, and that lead me to here.

I was trying to measure the distance from the black pin to the outer black circle, and this is the result in leafmap:

image

One thing I've noticed is that in the lower right corner, the map attributions show up twice, is that normal?

Here's hoping someone has thoughts or ideas of how to fix? One of the reasons I switched from folium to ipyleaflet and leafmap was because folium doesn't work with ipywidgets interactive_output. If I switch to a folium backend, will that limit me in making interactive maps with ipywidgets? I'm asking because I'm going to need to make radio buttons and check boxes and don't want folium to be my limitation.

Thanks!

giswqs commented 1 year ago

The attribution issue has been fixed by the latest version of leafmap. Update it using !pip install -U leafmap. Most of the ipyleaflet controls have the same issue. Setting m = Map(attribution_control=False) will hide the attribution control, but if you use m = Map(attribution_control=True), it will show the attribution control twice, which is unexpected. I am not sure if ipyleaflet wants to take on this issue.

The measure control issue is indeed an ipyleaflet issue. There is not much leafmap can do about it. It needs to be fixed by iypleaflet.

PennyJClarke commented 1 year ago

@Itayor, thank you so much for suggesting to downgrade to 0.17.0, the measure tool does indeed now work! While the bug is not removed from newer ipyleaflet, and it would be great for ipyleaflet to look at this in the future. This suggestion allows me now to measure in Leafmap, hopefully downgrading does not compromise the rest of Leafmap's functions as it is such a great package! Thank you all for your help!

Itayor commented 9 months ago

Update - checked now ipyleaflet 0.18.0 with MeasureControl the bug still exists, but there is a workaround if you set keyboard to 'False' in Map, the glitch happens on first click only. as long as the map still draggable, you can easily go back to your location, and continue with the shape. I guess that there is some interaction between measure control and keyboard that causes this bug. did not find a way to overcome it completely, but I guess this should help.

I don't know if it would work for previous versions (like 0.17.2)