dataease/frontend/src/views/system/map/index.vue

72 lines
1.7 KiB
Vue
Raw Normal View History

2021-07-13 18:44:33 +08:00
<template>
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
<div id="maptest" style="width: 100%;height:100%;" />
</layout-content>
</template>
<script>
import LayoutContent from '@/components/business/LayoutContent'
import { get } from '@/api/panel/panel'
export default {
components: { LayoutContent },
data() {
return {
myChart: null,
defaultPcode: '100000',
mapurl: '/api/map/resourceFull/'
}
},
created() {
},
mounted() {
const chartDom = document.getElementById('maptest')
this.myChart = this.$echarts.init(chartDom)
this.initMap(this.defaultPcode)
},
methods: {
initMap(pcode) {
this.myChart.showLoading()
get(this.mapurl + pcode).then(res => {
this.myChart.hideLoading()
const geoJson = res.data
this.$echarts.registerMap('HK', geoJson)
this.myChart.setOption({
series: [
{
type: 'map',
2021-08-10 18:27:11 +08:00
map: 'MAP', // 自定义扩展图表类型
2021-07-13 18:44:33 +08:00
roam: true,
label: {
show: false
},
nameProperty: 'name'
}
]
})
this.queryAreaCodes(pcode).then(res => {
const areaEntitys = res.data
this.myChart.on('click', param => {
const name = param.name
for (let index = 0; index < areaEntitys.length; index++) {
const element = areaEntitys[index]
if (element.name === name) {
this.initMap(element.code)
}
}
})
})
})
},
queryAreaCodes(pcode) {
return get('/api/map/areaEntitys/' + pcode)
}
}
}
</script>