引入密钥
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){
        var point = new BMap.Point(r.point.lng,r.point.lat);//用所定位的经纬度查找所在地省市街道等信息
        var gc = new BMap.Geocoder();
        gc.getLocation(point, function(rs){
            if (typeof rs.addressComponents.city !== "undefined") {
                console.log(rs.addressComponents);
                 province = rs.addressComponents.province;
                 city = rs.addressComponents.city;
                 district = rs.addressComponents.district;
                //$("a.city").children('span').html(city);
                $("#city-picker").val(province+' '+city+' '+district);
            }
            /*$("#address").val(rs.addressComponents.street+rs.addressComponents.streetNumber);*/
        });
    }else {
        //alert('failed'+this.getStatus());
    }
},{enableHighAccuracy: true})


今日吐槽

让烦恼与风去远行;让痛苦陪云去流浪。哼一曲好歌,也许心情,就会轻松许多

Contact ME

TAG Link