mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
feat: 添加点标记
This commit is contained in:
parent
ff7a0830d0
commit
f8b645f867
@ -3,14 +3,15 @@ import { CreateComponentType } from '@/packages/index.d'
|
|||||||
import { MapAmapConfig } from './index'
|
import { MapAmapConfig } from './index'
|
||||||
import { chartInitConfig } from '@/settings/designSetting'
|
import { chartInitConfig } from '@/settings/designSetting'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
import dataJson from './data.json'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
dataset: '',
|
dataset: dataJson,
|
||||||
amapKey: 'aa76ad84f92f661980f710cbe966b7f6',
|
amapKey: 'aa76ad84f92f661980f710cbe966b7f6',
|
||||||
amapStyleKey: 'normal',
|
amapStyleKey: 'normal',
|
||||||
amapStyleKeyCustom: '',
|
amapStyleKeyCustom: '',
|
||||||
amapLon: 116.39,
|
amapLon: 116.397428,
|
||||||
amapLat: 40.91,
|
amapLat: 39.90923,
|
||||||
amapZindex: 10,
|
amapZindex: 10,
|
||||||
viewMode: '2D',
|
viewMode: '2D',
|
||||||
pitch: 60,
|
pitch: 60,
|
||||||
|
17
src/packages/components/Charts/Maps/MapAmap/data.json
Normal file
17
src/packages/components/Charts/Maps/MapAmap/data.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"points": [
|
||||||
|
{
|
||||||
|
"icon": "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-1.png",
|
||||||
|
"position": [116.300467, 39.907761],
|
||||||
|
"title": "我是一个文本"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-2.png",
|
||||||
|
"position": [116.368904, 39.913423]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon": "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-3.png",
|
||||||
|
"position": [116.305467, 39.807761]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -29,6 +29,7 @@ let {
|
|||||||
} = toRefs(props.chartConfig.option)
|
} = toRefs(props.chartConfig.option)
|
||||||
|
|
||||||
let map = shallowRef(null)
|
let map = shallowRef(null)
|
||||||
|
let markers = ref([])
|
||||||
|
|
||||||
const ininMap = () => {
|
const ininMap = () => {
|
||||||
AMapLoader.load({
|
AMapLoader.load({
|
||||||
@ -46,7 +47,20 @@ const ininMap = () => {
|
|||||||
features: features.value,
|
features: features.value,
|
||||||
pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度
|
pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度
|
||||||
skyColor: skyColor.value,
|
skyColor: skyColor.value,
|
||||||
viewMode: viewMode.value, // 地图模式
|
viewMode: viewMode.value // 地图模式
|
||||||
|
})
|
||||||
|
markers?.value.forEach((marker: any) => {
|
||||||
|
// 创建点实例
|
||||||
|
if (!/\d/.test(marker.icon || marker.position)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var marker = new AMap.Marker({
|
||||||
|
icon: marker?.icon,
|
||||||
|
position: [marker.position[0], marker.position[1]],
|
||||||
|
title: marker?.title,
|
||||||
|
offset: new AMap.Pixel(-13, -30)
|
||||||
|
})
|
||||||
|
marker.setMap(map)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {})
|
.catch(e => {})
|
||||||
@ -55,6 +69,7 @@ const ininMap = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option,
|
() => props.chartConfig.option,
|
||||||
newData => {
|
newData => {
|
||||||
|
markers.value = newData.dataset.points
|
||||||
ininMap()
|
ininMap()
|
||||||
},
|
},
|
||||||
{ immediate: true, deep: true }
|
{ immediate: true, deep: true }
|
||||||
|
Loading…
Reference in New Issue
Block a user