谷歌地图API v3地理解码器国家

Google Maps API v3 Geodecoder country

本文关键字:解码器 国家 API v3 谷歌地图      更新时间:2023-09-26

如何在以下查询中将搜索限制为县?

geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
        map: map,
        position: results[0].geometry.location
    });

我试过这样格式化一个对象:

{
    address: '389 george st, sydney'
    county: au
}

但是如果我搜索'poo',印度就会出现在结果中。我如何限制只在澳大利亚搜索?

你需要做区域代码偏置。

查询必须针对要搜索的区域。

这是Google给出的例子。

https://developers.google.com/maps/documentation/javascript/examples/geocoding-region-es