数据源(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 | 数据源Id | string | - |
geo-json-source | 参考:GeoJson | IndexAny | - |
tile-json-source | 参考:TileJson | IndexAny | - |
EVENTS
名称 | 描述 | 参数 |
---|---|---|
source-added | 数据源添加完成事件 | source |
SLOTS
名称 | 描述 |
---|
METHODS
名称 | 描述 | 定义 |
---|