---
title: "fill-extrusion"
description: "Extrude polygons into 3D volumes with MapboxLayer type=\"fill-extrusion\", with data-driven height support."
canonical_url: "https://mapbox.mhaibaraai.cn/en/docs/layers/fill-extrusion"
---
# fill-extrusion

> Extrude polygons into 3D volumes with MapboxLayer type="fill-extrusion", with data-driven height support.

## Introduction

Set `type="fill-extrusion"` on `MapboxLayer` to extrude polygons into 3D volumes. `fill-extrusion-height` reads feature properties via `['get', ...]` to set per-feature heights. A non-zero map `pitch` is required to see the 3D effect. For full 3D city buildings, see [building](https://mapbox.mhaibaraai.cn/docs/layers/building).

> [!NOTE]
> See: /docs/core/layer
> 
> Fill-extrusion layers are powered by the generic MapboxLayer component. See its documentation for full Props and events reference.

## Usage

Two volumes extruded from their `height` property, with the map pitched at 55°:

```vue [LayerFillExtrusionExample.vue]
<script setup lang="ts">
import type { FeatureCollection } from 'geojson'

const data: FeatureCollection = {
  type: 'FeatureCollection',
  features: [
    { type: 'Feature', properties: { height: 800 }, geometry: { type: 'Polygon', coordinates: [[[116.38, 39.92], [116.40, 39.92], [116.40, 39.90], [116.38, 39.90], [116.38, 39.92]]] } },
    { type: 'Feature', properties: { height: 1600 }, geometry: { type: 'Polygon', coordinates: [[[116.41, 39.93], [116.43, 39.93], [116.43, 39.91], [116.41, 39.91], [116.41, 39.93]]] } }
  ]
}
</script>

<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MapboxMap :options="{ style: 'mapbox://styles/mapbox/light-v11', center: [116.41, 39.91], zoom: 13, pitch: 55 }">
      <!-- fill-extrusion-height 读取属性挤出 3D 体块 -->
      <MapboxLayer
        layer-id="prisms"
        type="fill-extrusion"
        :source="{ type: 'geojson', data }"
        :paint="{
          'fill-extrusion-color': '#3b82f6',
          'fill-extrusion-height': ['get', 'height'],
          'fill-extrusion-opacity': 0.8
        }"
      />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxLayer component
 */
interface MapboxLayerProps {
  /**
   * 图层 id，全局唯一
   */
  layerId: string;
  /**
   * 图层类型，决定渲染方式与可用的 paint / layout 属性
   */
  type: "symbol" | "fill" | "line" | "circle" | "heatmap" | "fill-extrusion" | "building" | "raster" | "raster-particle" | "hillshade" | "model" | "background" | "sky" | "slot" | "clip";
  /**
   * source id 字符串引用，或内联 source 对象（自动创建匿名源并随图层卸载）
   */
  source?: string | mapboxgl.SourceSpecification | undefined;
  /**
   * 矢量瓦片源内的子图层名（source-layer），消费矢量源时必填
   */
  sourceLayer?: string | undefined;
  /**
   * 绘制样式属性，响应式变更经 setPaintProperty 增量下发
   */
  paint?: PropBag | undefined;
  /**
   * 布局属性，响应式变更经 setLayoutProperty 增量下发
   */
  layout?: PropBag | undefined;
  /**
   * 过滤表达式，仅渲染匹配的要素
   */
  filter?: mapboxgl.FilterSpecification | undefined;
  /**
   * 最小缩放级别，低于此级别不渲染
   */
  minzoom?: number | undefined;
  /**
   * 最大缩放级别，高于此级别不渲染
   */
  maxzoom?: number | undefined;
  /**
   * 插入到该 id 图层之前；省略则追加到图层栈顶部
   */
  beforeId?: string | undefined;
}
```

## Changelog

See commit history for [src/runtime/components/Layer.vue](https://github.com/mhaibaraai/movk-mapbox/commits/main/src/runtime/components/Layer.vue).


## Sitemap

See the full [sitemap](https://mapbox.mhaibaraai.cn/sitemap.md) for all pages.
