Created
May 16, 2022 12:51
-
-
Save bobhaffner/697314bb7f34773ef13dec3f4045a48a to your computer and use it in GitHub Desktop.
ipyleaflet on_interaction example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ipywidgets import Label | |
from ipyleaflet import Map | |
m = Map(center=[42,-90], zoom=4) | |
label = Label() | |
display(label) | |
def handle_interaction(**kwargs): | |
if kwargs.get('type') == 'click': | |
print(str(kwargs.get('coordinates'))) | |
if kwargs.get('type') == 'mousemove': | |
label.value = str(kwargs.get('coordinates')) | |
m.on_interaction(handle_interaction) | |
m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Coordinates will print when you click and coordinates will display in label when you move the mouse over the map