简体   繁体   English

谷歌地图地理编码API,其JS API中缺少API的功能(?)

[英]Google Maps Geocoding API, feature from the API missing in their JS api (?)

The problem is simple, in the documentation for the Geocoding API they say component filtering exists. 问题很简单,在地理编码API的文档中,他们说存在组件过滤。 (Source: https://developers.google.com/maps/documentation/geocoding/ ) (来源: https//developers.google.com/maps/documentation/geocoding/

However, if I look at the JS documentation ( https://developers.google.com/maps/documentation/javascript/geocoding ), it doesn't seem to be implemented. 但是,如果我查看JS文档( https://developers.google.com/maps/documentation/javascript/geocoding ),它似乎没有实现。 I do however remember that google earlier used to have features implemented but not written about in their API, so I wonder if anyone knows how to achieve component filtering with the Google Maps Geocoding API? 但是我记得google之前曾经使用过但没有在其API中编写的功能,所以我想知道是否有人知道如何使用Google Maps Geocoding API实现组件过滤?

Thanks! 谢谢!

The documentation seems to of implemented it now. 文档似乎现在已经实现了。 Either way, here is the code: 无论哪种方式,这里是代码:

geocoder.geocode( 
      { 'address': address, 'componentRestrictions':{'country':'GB'}}, 
function(results, status){
...   
});

Used to restrict results to a specific area. 用于将结果限制为特定区域。 A filter consists of one or more of: route, locality, administrativeArea, postalCode or country. 过滤器由以下一个或多个组成:route,locality,administrativeArea,postalCode或country。 Only the results that match all the filters will be returned. 仅返回与所有过滤器匹配的结果。 Filter values support the same methods of spelling correction and partial matching as other geocoding requests. 过滤器值支持与其他地理编码请求相同的拼写校正和部分匹配方法。 See Component Filtering in the Geocoding web service for further details. 有关详细信息,请参阅地理编码Web服务中的组件过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM