#!/usr/bin/env python # coding: utf-8 # In[ ]: import ipyleaflet as ipyl import ipywidgets as ipyw import json # In[ ]: # Map and label widgets map = ipyl.Map(center=[53.88, 27.45], zoom=4) label = ipyw.Label(layout=ipyw.Layout(width="100%")) # geojson layer with hover handler with open("./europe_110.geo.json") as f: data = json.load(f) for feature in data["features"]: feature["properties"]["style"] = { "color": "grey", "weight": 1, "fillColor": "grey", "fillOpacity": 0.5, } layer = ipyl.GeoJSON(data=data, hover_style={"fillColor": "red"}) def hover_handler(event=None, feature=None, id=None, properties=None): label.value = properties["geounit"] layer.on_hover(hover_handler) map.add(layer) ipyw.VBox([map, label]) # In[ ]: layer.visible = False # In[ ]: layer.visible = True