jupyter-widgets / ipyleaflet

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

mousemove event does not report correct coordinates when over a marker #1217

Closed charliedaly closed 3 months ago

charliedaly commented 3 months ago

Mouse events can be captured using the on interaction method of map. One of these events is mousemove. This reports the coordinates of the mouse but if the mouse is over a marker, it reports the coordinates of the marker instead.

charliedaly commented 3 months ago

The following code shows the problem.

import ipyleaflet

m = ipyleaflet.Map(center = (52, -8))

def handler(**kwargs):
    print(kwargs)

m.add(ipyleaflet.CircleMarker(location = (52, -8), radius = 40))

m.on_interaction(handler)
m

It prints out the mouse position. But when the mouse is over the marker, it doesn't show the mouse coordinates, only the location of the marker.

charliedaly commented 3 months ago

It seems to work for CircleMarker! I should have checked before submitting. It doesn't work with DivIcon.