Py.Cafe

bstankov/

reminiscent-spittle

Display_BS_products

DocsPricing
  • app.py
  • requirements.txt
app.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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