MapboxBufferPolygon

View source
多边形缓冲区,向外扩展或负值向内收缩指定米宽。

简介

MapboxBufferPolygon 把面要素向外扩展 width 米(负值向内收缩),polygon 接受面要素、几何或外环坐标数组。

用法

拖动滑块在扩展与收缩间切换:

宽度 800m
<script setup lang="ts">
const polygon: [number, number][] = [
  [116.38, 39.94],
  [116.44, 39.94],
  [116.44, 39.89],
  [116.38, 39.89],
  [116.38, 39.94]
]
const width = ref(800)
</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.41, 39.915], 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">宽度 {{ width }}m</span>
        <USlider v-model="width" :min="-400" :max="1500" :step="100" class="w-32" />
      </div>
      <!-- 正值向外扩展、负值向内收缩 -->
      <MapboxBufferPolygon :polygon="polygon" :width="width" color="#8b5cf6" />
    </MapboxMap>
  </div>
</template>

API

Props

Prop Default Type
polygonGeoJSON.Polygon | GeoJSON.Feature<GeoJSON.Polygon, { [name: string]: any; }> | [number, number][]

面要素、几何或外环坐标数组

widthnumber

缓冲宽度(米),负值向内收缩

layerIdstring

图层 id 前缀;省略时自动生成

colorstring

主色(快捷样式)

fillPaintRecord<string, unknown>

整体覆盖填充 paint

linePaintRecord<string, unknown>

整体覆盖描边 paint

beforeIdstring

插入到该图层之前

Changelog

No recent changes
Copyright © 2026 - 2026 YiXuan - MIT License