Py.Cafe

RGT1143022/

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
38
39
40
41
42
43
import solara
import leafmap


#明明設定好了,打開還是常常跑掉不知道原因
zoom = solara.reactive(16) 
center = solara.reactive(([22.34910336230622, 120.38834500512858]))

class Map(leafmap.Map):

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

        # self.add_basemap("ROADMAP")
        #上次作業的檔案,自行上傳到github
        SATELLITE = "https://github.com/RGT1143022/homework20241120/releases/download/v1.0.0/image.tif"
        seaGOEJSON =  "https://github.com/RGT1143022/homework20241120/releases/download/v1.0.0/sea.geojson"
        sea ="https://github.com/RGT1143022/homework20241120/releases/download/v1.0.0/sea.tif"

        self.add_cog_layer(SATELLITE, name="SATELLITE")
        self.add_cog_layer(sea, name="sea")
        self.add("layer_manager")
        #tif檔
        #self.split_map(SATELLITE, sea, left_label="SATELLITE", right_label="sea", add_close_button=True)
        
        #geojson
        self.split_map(SATELLITE, seaGOEJSON, left_label="SATELLITE", right_label="sea", 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}")