import sys
sys.setrecursionlimit(300)
import leafmap.maplibregl as leafmap
# import leafmap
import pycafe
# MAPTILER_KEY = leafmap.get_api_key("MAPTILER_KEY")
MAPTILER_KEY = pycafe.get_secret("MAPTILER_KEY")
print("MAPTILER_KEY", MAPTILER_KEY)
class Map(leafmap.Map):
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Add what you want below
# self.add_stac_gui()
m = self
return
m.add_basemap("Esri.WorldImagery", visible=False)
source = {
"url": f"https://api.maptiler.com/tiles/v3/tiles.json?key={MAPTILER_KEY}",
"type": "vector",
}
layer = {
"id": "3d-buildings",
"source": "openmaptiles",
"source-layer": "building",
"type": "fill-extrusion",
"min-zoom": 15,
"paint": {
"fill-extrusion-color": [
"interpolate",
["linear"],
["get", "render_height"],
0,
"lightgray",
200,
"royalblue",
400,
"lightblue",
],
"fill-extrusion-height": [
"interpolate",
["linear"],
["zoom"],
15,
0,
16,
["get", "render_height"],
],
"fill-extrusion-base": [
"case",
[">=", ["get", "zoom"], 16],
["get", "render_min_height"],
0,
],
},
}
m.add_source("openmaptiles", source)
m.add_layer(layer)
m.add_layer_control()
m
import solara
@solara.component
def Page():
waited = solara.use_reactive(False)
@solara.lab.use_task
async def wait():
import asyncio
await asyncio.sleep(1)
waited.value = True
if waited.value:
# solara.display(m)
solara.Text("before")
Map.element(
center=[-74.0066, 40.7135], zoom=16, pitch=45, bearing=-17)#, style="basic-v2"
solara.Text("after")
else:
solara.Text("waiting")