首页 > Windows开发 > 详细

个人相关API - 行驶方向判断函数

时间:2019-10-16 20:23:32      阅读:51      评论:0      收藏:0      [点我收藏+]
        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)
    }

 

水平方向移动
[Shuǐpíng fāngxiàng yídòng]
技术分享图片
The horizontal direction

个人相关API - 行驶方向判断函数

原文:https://www.cnblogs.com/tongbiao/p/11687307.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!