生活随笔
收集整理的這篇文章主要介紹了
echarts 5.4版本 map 地图下钻,海南三沙市隐藏显示
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
需求:渲染中國地圖,支持下鉆,同時南沙群島顯示在地圖右下腳
geoJson 數(shù)據(jù)可從 阿里云-dataV-下載
如果要展示 南海諸島需要將地圖類型設(shè)置為china, 將海南省中的三沙市坐標刪除
<template
>
<div ref
="echartInstance"></div
>
</template
>
<script
>
import * as echarts
from 'echarts'
import { registerMap
} from 'echarts'
import geoJson
from './geoJson.json'const CITY_LEVEL = {country: 'country', province: 'province',city: 'city', district: 'district'
}export default {name: 'chinaMap',data() {return {curLevel: {level: CITY_LEVEL.country
, adcode: '100000'},levelStack: [] }},methods: {init(){geoJson
.features
= geoJson
.features
.filter(item => item
.properties
.adcode
!== '100000_JD')const ecahrtInstance
= echarts
.init(this.$refs
.echartInstance
)registerMap(‘china’
, geoJson
)const option
= {geo: {map: 'china'},series: [{type: 'map',map: 'china'}]}ecahrtInstance
.setOption(option
, true)ecahrtInstance
.on('click', (params) => {const {level
, adcode
} = this.curLevel
this.levelStack
.push({level
, adcode
})fetch(`/api/${params.adcode}.json`).then(res => {})})} }
}
</script
>
最終效果:
總結(jié)
以上是生活随笔為你收集整理的echarts 5.4版本 map 地图下钻,海南三沙市隐藏显示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。