---
title: "MapboxBuildingLayer"
description: "3D building layer that extrudes the official composite/building vector source with configurable color, opacity, and minimum zoom."
canonical_url: "https://mapbox.mhaibaraai.cn/en/docs/layers/building"
---
# MapboxBuildingLayer

> 3D building layer that extrudes the official composite/building vector source with configurable color, opacity, and minimum zoom.

## Introduction

`MapboxBuildingLayer` extrudes the `composite` / `building` vector source from Mapbox's official styles into 3D buildings. Height expressions are built in; `color`, `opacity`, and `minzoom` are available as convenience props.

> [!NOTE]
> 
> This component depends on the 
> 
> composite/building
> 
>  source from Mapbox's official styles and will not work with empty styles such as Tianditu. A non-zero map 
> 
> pitch
> 
>  and sufficient 
> 
> zoom
> 
>  (default minzoom 15) are required to see buildings.

## Usage

Render 3D city buildings in a pitched view:

```vue [BuildingLayerExample.vue]
<script setup lang="ts">
// MapboxBuildingLayer 默认消费官方样式的 composite/building 矢量源
</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.461, 39.909], zoom: 15.5, pitch: 60, bearing: -20 }">
      <MapboxBuildingLayer color="#94a3b8" :opacity="0.85" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxBuildingLayer component
 */
interface MapboxBuildingLayerProps {
  /**
   * 图层 id；省略时自动生成
   */
  layerId?: string | undefined;
  /**
   * 矢量数据源 id
   */
  source?: string | undefined;
  /**
   * 数据源图层名
   */
  sourceLayer?: string | undefined;
  /**
   * 建筑颜色
   */
  color?: string | undefined;
  /**
   * 整体透明度
   */
  opacity?: number | undefined;
  /**
   * 显示建筑的最小缩放级别
   */
  minzoom?: number | undefined;
  /**
   * 整体覆盖 paint（提供时忽略 color/opacity 预设）
   */
  paint?: Record<string, unknown> | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

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


## Sitemap

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