---
title: "MapboxBufferLine"
description: "Line buffer that expands outward from both sides of a line by a given meter width to form a corridor polygon."
canonical_url: "https://mapbox.mhaibaraai.cn/en/docs/layers/buffer-line"
---
# MapboxBufferLine

> Line buffer that expands outward from both sides of a line by a given meter width to form a corridor polygon.

## Introduction

`MapboxBufferLine` expands outward from both sides of a line by `width` meters to generate a corridor polygon. The `line` prop accepts a line feature, geometry, or coordinate array. Common uses include road setbacks and pipeline protection zones.

## Usage

Generate a 600m-wide corridor along a polyline:

```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](https://mapbox.mhaibaraai.cn/sitemap.md) for all pages.
