从经纬度 google api 获取邮政编码

lne*_*n92 2 javascript ajax jquery google-maps

我只需要知道如何从经度和纬度获取邮政编码。

我使用谷歌地图 api 根据诸如“曼彻斯特”之类的搜索来获取经纬度,然后我需要从中获取邮政编码以查询我的数据库。

到目前为止我的代码是

function getLatLng()
{
    var localSearch = new google.maps.Geocoder();
    var postcode = $("#address").val();
    localSearch.geocode({ 'address': postcode },
                    function(results, status) {
                        if (results.length == 1) {
                            var result = results[0];
                            var location = result.geometry.location;
                        }
                        else 
                        {
                            $("#error").html("Address not found");
                        }
                    });
}
Run Code Online (Sandbox Code Playgroud)