# check out https://solara.dev/ for documentation
# or https://github.com/widgetti/solara/
# And check out https://py.cafe/maartenbreddels for more examples
import solara
import leafmap
# reactive variables will trigger a component rerender
# when changed.
# When you change the default (now 0), hit the embedded browser
# refresh button to reset the state
zoom = solara.reactive(2)
center = solara.reactive((20,0))
class Map(leafmap.Map):
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Add what you want below
# self.add_basemap("OpenTopoMap")
# change_basemap(self)
# before = "https://github.com/opengeos/datasets/releases/download/raster/Libya-2023-07-01.tif"
before = "https://github.com/bstankov/streamlit_demo_apps/blob/master/files/Libya-2023-07-01.tif"
after = "https://github.com/opengeos/datasets/releases/download/raster/Libya-2023-09-13.tif"
# ab_fire = "https://py.cafe/files/bstankov/leafmap-satellite-comparison/baa_mwf45_z_1_3400.tif"
self.add_cog_layer(before,name="before")
self.add_cog_layer(after,name="after")
# self.add_cog_layer(ab_fire,name="mwf45_2025")
self.add("layer_manager")
@solara.component
def Page():
print("The component render function gets called")
# change this code, and see the output refresh
Map.element(
center=center.value,
zoom=zoom.value,
on_center=center.set,
on_zoom= zoom.set,
height="750px"
)
solara.Text(f'Center:{center.value}')
solara.Text(f'Zoom:{zoom.value}')
# color = "green"
# if clicks.value >= 5:
# color = "red"
# def increment():
# clicks.value += 1
# print("clicks", clicks) # noqa
# solara.Button(label=f"Clicked: {clicks}", on_click=increment, color=color)
# Solara also supports ipywidgets
# remove the Page component and assign an ipywidget to
# the page variable, e.g.
# page = mywidget