Export 3D maps as HTML files for website hosting
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import leafmap.maplibregl as leafmap
import leafmap.maplibregl as leafmap
In [3]:
Copied!
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_PRIVATE_API_KEY"
# os.environ["MAPTILER_KEY_PUBLIC"] = "YOUR_PUBLIC_API_KEY"
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_PRIVATE_API_KEY"
# os.environ["MAPTILER_KEY_PUBLIC"] = "YOUR_PUBLIC_API_KEY"
In [4]:
Copied!
m = leafmap.Map(
center=[-122.19861, 46.21168], zoom=13, pitch=60, bearing=150, style="3d-terrain"
)
m.add_layer_control(bg_layers=True)
# m.to_html("terrain.html", title="Awesome 3D Map", width="100%", height="100%", replace_key=True)
m
m = leafmap.Map(
center=[-122.19861, 46.21168], zoom=13, pitch=60, bearing=150, style="3d-terrain"
)
m.add_layer_control(bg_layers=True)
# m.to_html("terrain.html", title="Awesome 3D Map", width="100%", height="100%", replace_key=True)
m
An API key is required to use the 3D terrain feature.
In [5]:
Copied!
m = leafmap.Map(
center=[-74.0066, 40.7135], zoom=16, pitch=45, bearing=-17, style="basic-v2"
)
m.add_basemap("Esri.WorldImagery", visible=False)
m.add_3d_buildings(min_zoom=15)
m.add_layer_control()
# m.to_html("buildings.html", title="Awesome 3D Map", width="100%", height="100%", replace_key=True)
m
m = leafmap.Map(
center=[-74.0066, 40.7135], zoom=16, pitch=45, bearing=-17, style="basic-v2"
)
m.add_basemap("Esri.WorldImagery", visible=False)
m.add_3d_buildings(min_zoom=15)
m.add_layer_control()
# m.to_html("buildings.html", title="Awesome 3D Map", width="100%", height="100%", replace_key=True)
m
Failed to retrieve the MapTiler style. Defaulting to 'dark-matter' style.