根据路书源码,marker是在start时通过_addMarker()添加的。所以必须在lushu.start之后,才可以通过lushu._marker.point获取实时位置。
const lushu= new Lushu(map, arrPois, {
autoView: false,
icon: new BMap.Icon(
require('../../../../assets/小车2.png'),
new BMap.Size(24, 14),
{ anchor: new BMap.Size(12, 7) }
),
speed: 100, //速度,单位米每秒
enableRotation: false,
landmarkPois: [],
})
//小车1.5s后开始运动,并1s打印一次坐标
setTimeout(function () {
lushu.start()
setInterval(() => console.log(lushu._marker.point), 1000)
}, 1500)