Skip to content

vGeoJsonLayer GeoJSON 图层

用于渲染 GeoJSON 数据的图层组件。

基础用法

vue
<script setup>
import { vMap, vGeoJsonLayer } from '@twi1i9ht/visual-lib'

const geojson = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: { name: '区域1' },
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [116.3, 39.8],
            [116.5, 39.8],
            [116.5, 40.0],
            [116.3, 40.0],
            [116.3, 39.8],
          ],
        ],
      },
    },
  ],
}
</script>

<template>
  <vMap :center-lat="39.9" :center-lng="116.4" :zoom="10">
    <vGeoJsonLayer :data="geojson" />
  </vMap>
</template>

自定义样式

vue
<template>
  <vGeoJsonLayer
    :data="geojson"
    :style="{
      color: '#ff7800',
      weight: 2,
      opacity: 0.8,
      fillColor: '#ff7800',
      fillOpacity: 0.3,
    }"
  />
</template>

Props

属性类型默认值说明
dataGeoJSON.FeatureCollectionGeoJSON 数据
styleL.PathOptions | Function样式配置
pointToLayerFunction点要素转换函数
onEachFeatureFunction每个要素的回调
filterFunction过滤函数

Events

事件名参数说明
feature-click{ feature, layer, event }点击要素

Released under the MIT License.