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

て烟熏妆下的殇ゞ 提交于 2019-12-07 04:00:56

问题


The problem is simple, in the documentation for the Geocoding API they say component filtering exists. (Source: 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. 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?

Thanks!


回答1:


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. 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.



来源:https://stackoverflow.com/questions/17201535/google-maps-geocoding-api-feature-from-the-api-missing-in-their-js-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!