通过经纬度调用百度api获取城市

首先需要引入

js内:

var geoc = new BMap.Geocoder();
var point = new BMap.Point(经度, 纬度);
geoc.getLocation(point, function(rs){
          var addComp = rs.addressComponents;
    alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
    //var city = addComp.substring(0 , addComp.length-1);
})

你可能感兴趣的:(通过经纬度调用百度api获取城市)