Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse events do not correctly report their location when they are over a marker which contains a DivIcon. #1218

Open
charliedaly opened this issue Jul 15, 2024 · 1 comment

Comments

@charliedaly
Copy link

The following code shows the problem:

from ipyleaflet import Map, Marker, DivIcon

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

def handler(**kwargs):
    if kwargs['type'] == 'mousemove':
         print(kwargs)

icon = DivIcon(icon_size = [100, 100])

marker = Marker(location = (52, -8), icon = icon)

m.add(marker)
    
m.on_interaction(handler)
m

When the mouse is over the marker, it shows the coordinates of the marker rather than the mouse.

@charliedaly
Copy link
Author

This happens even when the DivIcon is covered by another marker. In the following case, it's covered by a CircleMarker:

from ipyleaflet import Map, Marker, DivIcon, CircleMarker

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

def get_handler(m):
    m.coords = None
    def handler(**kwargs):
        if kwargs['type'] == 'mousemove':
            if m.coords == kwargs['coordinates']:
                print('.', end='')
            else:
                m.coords = kwargs['coordinates']
                print(kwargs)

    return handler

icon = DivIcon(icon_size = [100, 100])

marker = Marker(location = (52, -8), icon = icon)

cm = CircleMarker(location = (52, -8), radius = 80)

m.add(marker)
m.add(cm)
    
m.on_interaction(get_handler(m))
m

The mouse coordinates are correctly reported everywhere except where the DivIcon is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant