Skip to content

Source

Supports setting GeoJSON and TileJSON data

Example

Example Source Code
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

NameDescriptionTypeDefault
idSource Idstring-
geo-json-sourceSee:GeoJsonIndexAny-
tile-json-sourceSee:TileJsonIndexAny-

EVENTS

NameDescriptionParameters
source-addedData source added eventsource

SLOTS

NameDescription

METHODS

NameDescriptionDefinition