Skip to content

Viewing Selected Polygons #834

Answered by giswqs
jmarokhovsky asked this question in Q&A
Discussion options

You must be logged in to vote

There is no direct way to get the polygon from mouse click events. One workaround is to observe the map mouse click events, and then get the clicked coordiantes to be used for intersecting a GeoDataFrame.

leafmap/leafmap/leafmap.py

Lines 1236 to 1245 in 30e52c5

def handle_interaction(**kwargs):
latlon = kwargs.get("coordinates")
if event == "click" and kwargs.get("type") == "click":
coordinates.append(latlon)
self.last_click = latlon
self.all_clicks = coordinates
if add_marker:
markers.append(ipyleaflet.Marker(location=latlon))
marker_cluster.markers = markers

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jmarokhovsky
Comment options

Answer selected by giswqs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants