Skip to content

数据源(Source)

支持设置GeoJson、TileJson数据

示例

示例源码
vue
<template>
  <div style="height: 400px" class="vw-full vh-full">
    <mb-map :zoom="mapZoom" :center="mapCenter">
      <mb-tianditu-layer />
      <mb-polygon-layer
        v-if="showLayer"
        source-id="sourceExample"
        :opacity="0.1"
        color="blue"
      />
      <mb-polyline-layer
        v-if="showLayer"
        source-id="sourceExample"
        color="blue"
      />
      <mb-source
        id="sourceExample"
        :geo-json-source="geoJsonSource"
        @source-added="showLayer = true"
      />
    </mb-map>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue'

const mapCenter = [120.30782359643746, 31.49292271319491]
const mapZoom = 11
const showLayer = ref(false)
const geoJsonSource = {
  type: 'geojson',
  data: `${__RESOURCE_URL__}json/source-example.geojson`,
}
</script>

API

PROPS

名称描述类型默认值
id数据源Idstring-
geo-json-source参考:GeoJsonIndexAny-
tile-json-source参考:TileJsonIndexAny-

EVENTS

名称描述参数
source-added数据源添加完成事件source

SLOTS

名称描述

METHODS

名称描述定义