Skip to content

3d indoor mapping

image image image

Extrude polygons for 3D indoor mapping

This source code of this example is adapted from the MapLibre GL JS example - Extrude polygons for 3D indoor mapping.

Uncomment the following line to install leafmap if needed.

1
# %pip install "leafmap[maplibre]"
1
import leafmap.maplibregl as leafmap
1
2
3
data = "https://maplibre.org/maplibre-gl-js/docs/assets/indoor-3d-map.geojson"
gdf = leafmap.geojson_to_gdf(data)
gdf.explore()
1
gdf.head()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
m = leafmap.Map(
    center=(-87.61694, 41.86625), zoom=17, pitch=40, bearing=20, style="positron"
)
m.add_basemap("OpenStreetMap.Mapnik")
m.add_geojson(
    data,
    layer_type="fill-extrusion",
    name="floorplan",
    paint={
        "fill-extrusion-color": ["get", "color"],
        "fill-extrusion-height": ["get", "height"],
        "fill-extrusion-base": ["get", "base_height"],
        "fill-extrusion-opacity": 0.5,
    },
)
m.add_layer_control()
m

1