$(function(){
 var latlon=null;
            //ajax获取用户所在经纬度
            $.ajax({
                url:"http://api.map.baidu.com/location/ip?ak=bFNYmleHunu49WxpIlCN8QxTpzs93c8V&coor=bd09ll",
                type:"POST",
                dataType:"jsonp",
                success:function(data){
                    latlon=data.content.point.y+","+data.content.point.x;
                    //ajax根据经纬度获取省市区
                    $.ajax({
                        type: "POST",
                        dataType: "jsonp",
                        url: 'http://api.map.baidu.com/geocoder/v2/?ak=C93b5178d7a8ebdb830b9b557abce78b&callback=renderReverse&location='+latlon+'&output=json&pois=0',
                        success: function (json) {
                            if(json.status==0){
                                console.log(json.result.addressComponent.province+"-"+json.result.addressComponent.city+"-"+json.result.addressComponent.district);
                            }
                        }
                    });
                }
            });
})

 

相关文章:

  • 2022-01-17
  • 2021-12-22
  • 2021-10-28
  • 2022-12-23
  • 2021-08-07
  • 2022-01-02
  • 2021-11-17
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-01-01
  • 2021-06-05
  • 2022-02-02
相关资源
相似解决方案