个人相关API - 行驶方向判断函数
calculateDrivingDirection(newCoordinates,oldCoordinates){ let o = { direction: '', deviation:null, isTop: false, isRight: false, newLng: newCoordinates[0], newLat: newCoordinates[1], oldLng: oldCoordinates[0], oldLat: oldCoordinates[1], } o.deviation = Math.abs((o.newLng - o.oldLng)) - Math.abs((o.newLat - o.oldLat)) o.newLng - o.oldLng > 0 ? o.isRight = true : o.isRight = false o.newLat - o.oldLat > 0 ? o.isTop = true : o.isTop = false if(o.deviation > 0){ // 大于零 水平方向移动 o.isRight ? o.direction = 'right' : o.direction = 'left' }else{ // 小于零 垂直方向移动 o.isTop ? o.direction = 'top' : o.direction = 'down' } return o.direction },
.car-loc-marker.right{ transform: rotate(0deg) } .car-loc-marker.left{ transform: rotate(180deg) } .car-loc-marker.top{ transform: rotate(-90deg) } .car-loc-marker.down{ transform: rotate(90deg) }
API
marker.moveTo()
https://www.tongbiao.xyz/