-
There's a ton of excellent documentation, but I still seem unable to find the trick to replicate this code below using "pure" ipyleaflet in leafmap's ipyleaflet. Essentially I'd like to use a callback to access some GeoJSON properties when hovering over the respective features in order to do use this information somewhere else. If I can't find it it's because it is too simple, right? ;-) import requests
from ipyleaflet import GeoJSON, Map
def handle_geojson_hover(event=None, id=None, properties=None, **kwargs):
print(properties)
url = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson"
data = requests.get(url).json()
m = Map(center=(0, 0), zoom=2)
gj_layer = GeoJSON(data=data, hover_style={"color": "red", "fillColor": "red"})
gj_layer.on_hover(handle_geojson_hover)
m += gj_layer
m |
Beta Was this translation helpful? Give feedback.
Answered by
giswqs
Mar 23, 2023
Replies: 1 comment 1 reply
-
Would this be acceptable? import requests
from ipyleaflet import GeoJSON
from leafmap import Map
def handle_geojson_hover(event=None, id=None, properties=None, **kwargs):
print(properties)
url = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson"
data = requests.get(url).json()
m = Map(center=(0, 0), zoom=2)
gj_layer = GeoJSON(data=data, hover_style={"color": "red", "fillColor": "red"})
gj_layer.on_hover(handle_geojson_hover)
m += gj_layer
m |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
deeplook
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would this be acceptable?