---
title: "MaplibreBuildingLayer"
description: "3D building layer that extrudes building polygons by a height property from a vector tile or GeoJSON source, with configurable color, opacity, and minimum zoom."
canonical_url: "https://maplibre.mhaibaraai.cn/en/docs/layers/building"
---
# MaplibreBuildingLayer

> 3D building layer that extrudes building polygons by a height property from a vector tile or GeoJSON source, with configurable color, opacity, and minimum zoom.

## Introduction

`MaplibreBuildingLayer` extrudes building polygons from `source` (plus `sourceLayer` for vector tiles) into 3D buildings. Height expressions are built in; `color`, `opacity`, and `minzoom` are available as convenience props. Height fields default to the OpenMapTiles `render_height` / `render_min_height` and can be changed with `heightProperty` / `baseProperty`.

> [!NOTE]
> 
> A source with building height properties is required (the examples use the 
> 
> openmaptiles
> 
>  source bundled with OpenFreeMap styles). 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">
// OpenFreeMap 样式自带 openmaptiles 矢量源，建筑高度字段为 render_height
</script>

<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MaplibreMap :options="{ style: 'https://tiles.openfreemap.org/styles/positron', center: [116.461, 39.909], zoom: 15.5, pitch: 60, bearing: -20 }">
      <MaplibreBuildingLayer source="openmaptiles" source-layer="building" color="#94a3b8" :opacity="0.85" />
    </MaplibreMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MaplibreBuildingLayer component
 */
interface MaplibreBuildingLayerProps {
  /**
   * 数据源 id（需已由 MaplibreSource 或样式声明）
   */
  source: string;
  /**
   * 矢量瓦片中的图层名（如 OpenMapTiles 的 'building'）；GeoJSON 源省略
   */
  sourceLayer?: string | undefined;
  /**
   * 建筑高度属性名
   * @default 'render_height'
   */
  heightProperty?: string | undefined;
  /**
   * 建筑底面高度属性名
   * @default 'render_min_height'
   */
  baseProperty?: string | undefined;
  /**
   * 图层 id；省略时自动生成，变更需配合 `:key` 重建
   */
  layerId?: string | undefined;
  /**
   * 建筑颜色
   * @default '#aaa'
   */
  color?: string | undefined;
  /**
   * 整体透明度
   * @default 0.8
   */
  opacity?: number | undefined;
  /**
   * 显示建筑的最小缩放级别
   * @default 15
   */
  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-maplibre/commits/main/src/runtime/components/layers/BuildingLayer.vue).


## Sitemap

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