修改地图

new-map
ihzero 2022-11-23 13:19:59 +08:00
parent 20507d4d2e
commit 13ec879c1e
1 changed files with 42 additions and 9 deletions

View File

@ -53,6 +53,8 @@
const mapJSON = ref() const mapJSON = ref()
const tempMapJSON = ref() const tempMapJSON = ref()
let options: any = null
const { rootEmitter } = useVContext() const { rootEmitter } = useVContext()
const baseData = ref([]) const baseData = ref([])
@ -85,12 +87,14 @@
}) })
}) })
registerMap('lcxz', tempMapJSON.value) registerMap('lcxz', tempMapJSON.value)
options = {
setOptions({
backgroundColor: 'transparent', backgroundColor: 'transparent',
stateAnimation: { stateAnimation: {
duration: 100, duration: 100,
}, },
// tooltip: {
// trigger: 'item',
// },
geo: { geo: {
map: 'lcxz', map: 'lcxz',
aspectScale: 0.75, aspectScale: 0.75,
@ -233,7 +237,8 @@
type: 'scatter', type: 'scatter',
coordinateSystem: 'geo', coordinateSystem: 'geo',
tooltip: { tooltip: {
show: false, trigger: 'item',
show: true,
}, },
symbol: (_, params) => { symbol: (_, params) => {
return mapData[params.dataIndex].img return mapData[params.dataIndex].img
@ -246,10 +251,10 @@
{ {
type: 'scatter', type: 'scatter',
coordinateSystem: 'geo', coordinateSystem: 'geo',
stateAnimation: { // stateAnimation: {
duration: 300, // duration: 300,
easing: 'bounceOut', // easing: 'bounceOut',
}, // },
label: { label: {
show: true, show: true,
align: 'center', align: 'center',
@ -284,10 +289,12 @@
symbolSize: [100, 34], symbolSize: [100, 34],
symbolOffset: [0, -46], symbolOffset: [0, -46],
z: 999, z: 999,
data: mapData, // data: mapData,
data: [],
}, },
], ],
}) }
setOptions(options)
} }
async function getBase() { async function getBase() {
@ -315,9 +322,35 @@
tempMapJSON.value = deepMerge(mapJSON.value) tempMapJSON.value = deepMerge(mapJSON.value)
getBase() getBase()
} }
let tempName: any = null
onMounted(async () => { onMounted(async () => {
await getData() await getData()
getInstance()?.on('mousemove', (e) => {
// const arr = options.series[3].data
// if (e.seriesType == 'map' && arr.length) {
// console.log('=====')
// options.series[3].data = []
// getInstance()?.setOption({ series: options.series }, false)
// }
if (tempName == e.name && e.seriesType == 'scatter') return
if (e.seriesType == 'scatter') {
tempName = e.name
options.series[3].data = [e.data]
getInstance()?.setOption({ series: options.series }, false)
}
// if (tempName == e.name) return
// tempName = e.name
// if (e.componentSubType == 'scatter') {
// options.series[3].data = [e.data]
// getInstance()?.setOption({ series: options.series }, false)
// } else {
// options.series[3].data = [e.data]
// getInstance()?.setOption({ series: options.series }, false)
// }
})
getInstance()?.on('click', (e) => { getInstance()?.on('click', (e) => {
if (e.seriesType == 'effectScatter' || e.seriesType == 'scatter') { if (e.seriesType == 'effectScatter' || e.seriesType == 'scatter') {
rootEmitter.emit('base:click', e.data) rootEmitter.emit('base:click', e.data)