由于当前版本的maptalks(rc17)尚不支持对marker高度的动态修改,所以结合map源码魔改出了这个方案
还有一种方案是使用maptalks.three来生成文字悬浮效果,但是那种方法出来的效果不是很清晰
1.引入模块
import { Map, VectorLayer, Marker, Geometry, MultiPolygon } from 'maptalks'
import gsap from 'gsap'
2.初始化图层并添加点
const pointWithAltitudeLayer = new VectorLayer('vectorWithAltitude',null,{
enableAltitude: true,
altitudeProperty: 'altitude'
})
pointWithAltitudeLayer.addTo(map)
const popupIcon = require('../../../assets/images/markers/tips.png')
const highPoint = new Marker([x, y], {
id: 'highPoint_' + 1,
properties: {
type: 'flyPoint',
name: 'flyPoint_' + 1,
altitude : 200
},
symbol: {
'markerFile': popupIcon,
'markerWidth': 150,
'markerHeight': 50,
'markerDx': 0,
'markerDy': 0,
'markerOpacity': 1
}
})
highPoint.addTo(pointWithAltitudeLayer)
3.为marker添加动画
addAnimation(map,highPoint)
const addAnimation = (map, marker) => {
const properties = marker.getProperties()
gsap.to(marker.properties, {
altitude: 120,
duration: 2,
repeat: -1,
yoyo: true,
onUpdate: ()=> {
},
})
}
desktop 2023-01-16 11-04-23