---
title: "MapboxBufferLine"
description: "线缓冲区，沿线两侧扩展指定米宽生成走廊面。"
seo_title: "MapboxBufferLine Component"
seo_description: "MapboxBufferLine builds a corridor polygon by buffering a line outward by a meter width, rendered as fill and line layers via Turf.js."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/layers/buffer-line"
---
# MapboxBufferLine

> 线缓冲区，沿线两侧扩展指定米宽生成走廊面。

## 简介

`MapboxBufferLine` 沿线两侧扩展 `width` 米生成走廊面，`line` 接受线要素、几何或坐标数组。常用于道路红线、管线保护范围等。

## 用法

沿折线生成 600m 宽走廊：

```vue [BufferLineExample.vue]
<script setup lang="ts">
const line: [number, number][] = [
  [116.34, 39.88],
  [116.40, 39.92],
  [116.46, 39.90],
  [116.50, 39.94]
]
</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.42, 39.91], zoom: 11 }">
      <!-- 沿线两侧扩展 width 米的走廊面 -->
      <MapboxBufferLine :line="line" :width="600" color="#10b981" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxBufferLine component
 */
interface MapboxBufferLineProps {
  /**
   * 线要素、几何或坐标数组
   */
  line: GeoJSON.LineString | GeoJSON.Feature<GeoJSON.LineString, GeoJSON.GeoJsonProperties> | [number, number][];
  /**
   * 缓冲宽度（米）
   */
  width: number;
  /**
   * 图层 id 前缀；省略时自动生成
   */
  layerId?: string | undefined;
  /**
   * 主色（快捷样式）
   */
  color?: string | undefined;
  /**
   * 整体覆盖填充 paint
   */
  fillPaint?: Record<string, unknown> | undefined;
  /**
   * 整体覆盖描边 paint
   */
  linePaint?: Record<string, unknown> | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

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


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
