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
e89dc9d0e7
commit
94b06552f2
@ -3,14 +3,15 @@ import { CreateComponentType } from '@/packages/index.d'
|
||||
import { MapAmapConfig } from './index'
|
||||
import { chartInitConfig } from '@/settings/designSetting'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const option = {
|
||||
dataset: '',
|
||||
dataset: dataJson,
|
||||
amapKey: 'aa76ad84f92f661980f710cbe966b7f6',
|
||||
amapStyleKey: 'normal',
|
||||
amapStyleKeyCustom: '',
|
||||
amapLon: 116.39,
|
||||
amapLat: 40.91,
|
||||
amapLon: 116.397428,
|
||||
amapLat: 39.90923,
|
||||
amapZindex: 10,
|
||||
viewMode: '2D',
|
||||
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)
|
||||
|
||||
let map = shallowRef(null)
|
||||
let markers = ref([])
|
||||
|
||||
const ininMap = () => {
|
||||
AMapLoader.load({
|
||||
@ -46,7 +47,20 @@ const ininMap = () => {
|
||||
features: features.value,
|
||||
pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度
|
||||
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 => {})
|
||||
@ -55,6 +69,7 @@ const ininMap = () => {
|
||||
watch(
|
||||
() => props.chartConfig.option,
|
||||
newData => {
|
||||
markers.value = newData.dataset.points
|
||||
ininMap()
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
|
Loading…
Reference in New Issue
Block a user