经纬度转换详细地址 -百度api

//23.16625105989508,113.4260949486429 

var x = 113.4260949486429;

var y = 23.16625105989508;

var ggPoint = new BMap.Point(x,y);

var convertor = new BMap.Convertor();

//坐标转换完之后的回调函数

translateCallback = function (data){

  if(data.status === 0) {

for (var i = 0; i < data.points.length; i++) {

var newPoint=data.points[i];

console.log(newPoint.lng);

console.log(newPoint.lat);

}

var point = new BMap.Point(newPoint.lng,newPoint.lat);

var gc = new BMap.Geocoder();

gc.getLocation(point, function(rs){

  alert(rs.address+rs.surroundingPois[0].title);

  console.log(JSON.stringify(rs));

});

  }

}

setTimeout(function(){

        var convertor = new BMap.Convertor();

        var pointArr = [];

        pointArr.push(ggPoint);

        convertor.translate(pointArr, 1, 5, translateCallback);

}, 1000);

你可能感兴趣的:(经纬度转换详细地址 -百度api)