---
title: "MapboxBufferCircle"
description: "圆形缓冲区，基于 turf 测地圆按米半径生成填充与描边图层。"
seo_title: "MapboxBufferCircle Component"
seo_description: "MapboxBufferCircle renders a geodesic circle buffer from a center and meter radius as fill and line layers, powered by Turf.js."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/layers/buffer-circle"
---
# MapboxBufferCircle

> 圆形缓冲区，基于 turf 测地圆按米半径生成填充与描边图层。

## 简介

`MapboxBufferCircle` 以圆心与米半径生成 turf 测地圆，渲染为填充 + 描边两层。`color` 提供快捷配色，`fillPaint` / `linePaint` 可整体覆盖样式。

## 用法

拖动滑块调整半径（米）：

```vue [BufferCircleExample.vue]
<script setup lang="ts">
const center: [number, number] = [116.397, 39.908]
const radius = ref(2000)
</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, zoom: 11 }">
      <div class="absolute left-3 top-3 z-10 flex items-center gap-2 rounded-(--ui-radius) border border-default bg-default/80 px-3 py-1.5 backdrop-blur">
        <span class="text-sm text-muted">半径 {{ radius }}m</span>
        <USlider v-model="radius" :min="500" :max="5000" :step="500" class="w-32" />
      </div>
      <!-- turf 测地圆，半径单位米 -->
      <MapboxBufferCircle :center="center" :radius="radius" color="#3b82f6" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxBufferCircle component
 */
interface MapboxBufferCircleProps {
  /**
   * 圆心经纬度
   */
  center: [number, number];
  /**
   * 半径（米）
   */
  radius: number;
  /**
   * 圆周采样段数
   * @default "64"
   */
  steps?: number | undefined;
  /**
   * 图层 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/BufferCircle.vue](https://github.com/mhaibaraai/movk-mapbox/commits/main/src/runtime/components/buffers/BufferCircle.vue).


## Sitemap

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