限制对国家/地区的地理编码

Mau*_*rry 3 google-maps-api-3 google-geocoder

我已经看到有可能用"静态"将搜索范围限制到某个区域(有组件限制),我也看到在JavaScript API的发行版3.exp(将是3.14)中,新类google.maps.GeocoderComponentRestrictions已经出现.我还没有看到过应该如何使用这个类.有没有人有关于此的更多信息?

car*_*iam 6

看起来这是通过Google Maps Geocoding API解决的,它的JS api(?)中缺少API的功能,格式如下:

geocoder.geocode( 
      { 'address': address, 'componentRestrictions':{'country':'GB'}}, 
function(results, status){
...   
});
Run Code Online (Sandbox Code Playgroud)

GeocoderComponentRestrictions参数获得通过与componentRestrictions关键.