TS经纬度转换

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wei11556/article/details/72954072
    GetLongitude(mylongitude) {
        mylongitude = Math.abs(mylongitude);
        let v1 = Math.floor(mylongitude);//度
        let v2 = Math.floor((mylongitude - v1) * 60);//分
        let v3 = Math.round((mylongitude - v1) * 3600 % 60);//秒
        return v1 + '度' + v2 + '分' + v3 + '秒';
    }

    GetLatitude(mylatitude) {
        mylatitude = Math.abs(mylatitude);
        let v1 = Math.floor(mylatitude);//度
        let v2 = Math.floor((mylatitude - v1) * 60);//分
        let v3 = Math.round((mylatitude - v1) * 3600 % 60);//秒
        return v1 + '度' + v2 + '分' + v3 + '秒';
    }

    DegreeConvertBack(value) { ///<summary>度分秒转换成为度</summary>  

        value = value.replace(".", "");
        var du = value.split("度")[0];
        var fen = value.split("度")[1].split("分")[0];
        var miao = value.split("度")[1].split("分")[1].split('秒')[0];
        return Math.abs(du) + (Math.abs(fen) / 60 + Math.abs(miao) / 3600);
    }

猜你喜欢

转载自blog.csdn.net/wei11556/article/details/72954072