TS经纬度转换

来源:互联网 发布:机械加工工艺编程员 编辑:程序博客网 时间:2024/05/21 22:33
    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);    }

原创粉丝点击