Spaces:
Runtime error
Runtime error
File size: 1,162 Bytes
fd8d58e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import geodev
import solara
zoom = solara.reactive(4)
center = solara.reactive((40, -100))
bounds = solara.reactive(None)
class Map(geodev.Map):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.add_basemap("Esri.WorldImagery")
self.add_basemap_gui()
@solara.component
def Page():
# Isolation is required to prevent the map from overlapping navigation (when screen width < 960px)
with solara.Column(
style={"width": "100%", "height": "500px", "isolation": "isolate"}
):
# solara components support reactive variables
solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
# using 3rd party widget library require wiring up the events manually
# using zoom.value and zoom.set
Map.element( # type: ignore
zoom=zoom.value,
on_zoom=zoom.set,
center=center.value,
on_center=center.set,
on_bounds=bounds.set,
scroll_wheel_zoom=True,
)
solara.Text(f"Zoom: {zoom.value}")
solara.Text(f"Center: {center.value}")
solara.Text(f"Bounds: {bounds.value}")
|