Py.Cafe

yitinglu071/

leafmap-solara

Libya flooding maps

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
import solara
import leafmap

zoom = solara.reactive(9)
center = solara.reactive(([39.463814, -0.368416]))

class Map(leafmap.Map):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # self.add_basemap("ROADMAP")
        before ="https://github.com/Peter-eating/python/raw/refs/heads/main/2024-08-18-00_00_2024-08-18-23_59_Landsat_8-9_L2_True_color(1).tif"
        after = "https://github.com/Peter-eating/python/raw/refs/heads/main/2024-10-30-00_00_2024-10-30-23_59_Landsat_8-9_L2_True_color(1).tif"

        self.add_cog_layer(before, name="Before1029")
        self.add_cog_layer(after, name="After1029")
        self.add("layer_manager")

        self.split_map(before, after, left_label="Before", right_label="After", add_close_button=True)


@solara.component
def Page():
    solara.lab.theme.dark = False

    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}")