百度地图API提供Geocoder类

var map = new BMap.Map("MapTest");
 var point = new BMap.Point(113.110518, 23.201543);
 map.centerAndZoom(point, 11);
 var address = "";

//坐标转换为地理位置
 var geo = new BMap.Geocoder();
 geo.getLocation(point, function(result) {                                               
  if (result){                                                       
   address = result.address;
   document.getElementById("address").innerHTML = address;
   } 
   });

 

//地理位置转换为坐标

var geo = new BMap.Geocoder();
geo.getPoint(“上海市益江路286弄玉兰香苑广场内(近盛夏路)”, function(point){
if (point) {
     //经度
     var pointx = point.lng;
     //纬度
     var pointy = point.lat;
}
}, “上海”);

 

api地址: http://developer.baidu.com/map/webservice-geocoding.htm

你可能感兴趣的:(百度地图API提供Geocoder类)