Skip to content

CircleLayer

Circle layer, which can also be used as a point when the radius is small.

Example

Example Source Code
vue
<template>
  <div style="height: 400px" class="vw-full vh-full">
    <mb-map :zoom="1.5" :pitch="20">
      <mb-tianditu-layer />
      <mb-circle-layer
        :data="airpotDataSource"
        :color="color"
        :radius="radius"
        :stroke-width="1"
        :stroke-opacity="1"
      />
    </mb-map>
  </div>
</template>
<script setup lang="ts">
import { onBeforeMount, ref } from 'vue'

const airpotDataSource = ref([])
const color = [
  'scalerank',
  1,
  'rgb(178,24,43)',
  2,
  'rgb(239,138,98)',
  4,
  'rgb(253,219,199)',
  6,
  'rgb(209,229,240)',
  8,
  'rgb(103,169,207)',
  10,
  'rgba(33,102,172,0)',
]
const radius = ['scalerank', 1, 10, 10, 1]

onBeforeMount(() => {
  fetch(`${__RESOURCE_URL__}json/ne_10m_airports.geojson`)
    .then((res) => res.json())
    .then((data) => {
      airpotDataSource.value = data.features.map((feature) => {
        return {
          coordinates: feature.geometry.coordinates.slice(),
          properties: feature.properties,
        }
      })
    })
})
</script>

API

PROPS

NameDescriptionTypeDefault
idLayer IDstring-
radiusRadius. ['mag',1,5,14,20] indicates that the circle radius is set according to the mag property value. When the value is 1/14, the circle radius is 5/20. [1,5,14,20] indicates that when the map zoom value is 1/14, the circle radius is 5/20number / Array<string | number>5
blurCircle blur amount. A value of 1 means only the center of the circle is opaquenumber0
colorColor value. Can be set to a number or an array. ['mag',1,"rgba(33,102,172,0)",14,"rgb(253,219,199)"] indicates that the color value is set according to the mag property value. When the value is 1/14, the color value is rgba(33,102,172,0)/rgb(253,219,199)string / Array<string | number>#000000
dataData for the vector layer. Each object in the array must contain the required coordinates property and the optional properties property. Each object represents a point/line/polygonVectorLayerData-
geo-json-data-sourceGeoJSON data source. Can be set to a GeoJSON data link or a GeoJSON data object. Specification Link. If this property is set, the data property is ignoredstring / GeoJSONSource-
opacityOpacity. The default value is 1. If set as an array, it is associated with zoom. For example: [7,1,9,0] means the opacity is 1 from zoom level 0 to 7, and 0 above zoom level 9number / number[]1
maxzoomMaximum zoom levelnumber22
minzoomMinimum zoom levelnumber0
pickableWhether the layer responds to pick events. If false, the component will not emit mouse-related eventsbooleantrue
showWhether to show the layerbooleantrue
source-idID of the layer's source. If this ID is set, both the geoJsonDataSource and data properties are ignoredstring-
source-layer-nameLayer name in the source data. This property is effective when sourceId is setstring-
stroke-colorCircle border color. Can be set to a number or an array. ['mag',1,"rgba(33,102,172,0)",14,"rgb(253,219,199)"] indicates that the color value is set according to the mag property value. When the value is 1/14, the color value is rgba(33,102,172,0)/rgb(253,219,199)string / Array<string | number>#000000
stroke-opacityCircle border opacitynumber0
stroke-widthCircle border width in pixelsnumber0
translateAnchor point translation. Positive direction is right/down in pixelsnumber[][0,0]
auto-highlightWhether to automatically apply highlightingbooleanfalse
highlight-colorThe highlight colorstring / number[][255, 255, 128, 1]
generate-idWhether to automatically generate GeoJSON Feature IDs. If the data does not have IDs and automatic highlighting is required, this must be set to truebooleanfalse

EVENTS

NameDescriptionParameters
createdMap initialization completed event-
clickLayer click eventobject — Contains screen coordinates (pixel), longitude/latitude (coordinate), selected element properties, and originalEvent
mousemoveMouse move eventobject — Contains screen coordinates (pixel), longitude/latitude (coordinate), selected element properties, and originalEvent
mouseleaveMouse leave element eventMapMouseEvent

SLOTS

NameDescription

METHODS

NameDescriptionDefinition
exportToGeoJsonTranslate the layer's data to GeoJSON formatted text. If the layer's data source comes from a source component or a URL, output null.()=> object | null