File size: 1,302 Bytes
587271e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import leafmap
import solara


# variables
zoom = solara.reactive(2)
center = solara.reactive((20, 0))

# Euromap info
eurocrops_pmtiles = "https://s3.us-west-2.amazonaws.com/us-west-2.opendata.source.coop/cholmes/eurocrops/eurocrops-all.pmtiles"
ec_style = leafmap.pmtiles_style(eurocrops_pmtiles)


class Map(leafmap.Map):
    def __init__(self, **kwargs) -> None:
        super().__init__(**kwargs)
        self.add_stac_gui()  ## TODO: make sure I need this
        self.add_pmtiles(
            eurocrops_pmtiles,
            name="Euro Crops",
            style=ec_style,
            overlay=True,
            show=True,
            zoom_to_layer=False,
        )


@solara.component
def Page():
    with solara.Column(style={"min-width": "500px"}):
        # 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,
            scroll_wheel_zoom=True,
            toolbar_ctrl=False,
            data_ctrl=False,
            height="780px",
        )