坐标转换是一类简单的HTTP接口,能够将用户输入的非高德坐标(GPS坐标、mapbar坐标、baidu坐标)转换成高德坐标。
webAPI坐标转换
JS函数封装
/*
* coordsys,原坐标系,可选值:gps;mapbar;baidu;autonavi(不进行转换)
* */
function convertPoints(points, coordsys, keys) {
var url = "https://restapi.amap.com/v3/assistant/coordinate/convert?locations=" + points + "&coordsys=" + coordsys + "&output=json&key=" + keys;
$.getJSON(url, function (res) {
//console.log(res);
$("#coords").html(res.locations);
})
}
var points = "121.554586,29.813444";
var coordsys = "baidu";
var keys = "4d9a765939a**";
//函数调用;
convertPoints(points, coordsys, keys);
成功返回的数据格式

jsAPI批量转换
var map = new AMap.Map('container', {
        center: [121.548181, 29.806906],
        zoom: 15
    });
    // 创建包含4个节点的折线及文字标注
    var path = [
        new AMap.LngLat(121.552371,29.813682),
        new AMap.LngLat(121.555713,29.812867)
    ];
    // 坐标转换
    /*
    * type用于说明是哪个服务商的坐标,可选值有:
     gps:GPS原始坐标;
     baidu:百度经纬度;
     mapbar:图吧经纬度;*/
    AMap.convertFrom(path, 'baidu', function (status, result) {
        console.log(result);
        if ( === 'ok') {
            var path2 = result.locations;
            polyline2 = new AMap.Polyline({
                path: path2,
                borderWeight: 2, // 线条宽度,默认为 1
                strokeColor: 'blue', // 线条颜色
                lineJoin: 'round' // 折线拐点连接处样式
            });
            map.add(polyline2);
        }
    });成功返回的数据格式

lockdatav Done!
 
 
                     
            
        













 
                    

 
                 
                    