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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章