天天看點

TS經緯度轉換

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);
    }