gps 경위도 변환 실제 거리

7279 단어
doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
head>

<body>
<script src="https://webapi.amap.com/maps?v=1.4.6&key=2e163cbe37323c268a52d856b3acbfef">script>
<script type="text/javascript">
    getPosition("117.133676", "36.66844")
    //x:   y: 
    function getPosition(x, y) {
        var gps = []//[, 36.66844];
        gps.push(x)
        gps.push(y)
        AMap.convertFrom(gps, 'gps', function (status, result) {
            if (result.info === 'ok') {
                var lnglats = result.locations; // Array.
                console.log(JSON.stringify(lnglats))
                var xx = lnglats[0]["O"];
                var yy = lnglats[0]["P"];
                AMap.service('AMap.Geocoder', function () {
                    geocoder = new AMap.Geocoder({});
                    var lnglatXY = [xx, yy];
                    geocoder.getAddress(lnglatXY, function (status, result) {
                        if (status === 'complete' && result.info === 'OK') {
                            console.log(JSON.stringify(result,null,4));
                        } else {
                            alert(" , :" + status + "info:" + result.info)
                        }
                    });
                })
            }
        });
    }
script>
body>

html>

 
다음으로 전송:https://www.cnblogs.com/lguow/p/9345869.html

좋은 웹페이지 즐겨찾기