Google geocoding API - search in just one country

血红的双手。 提交于 2019-12-05 01:49:27

问题


I am looking for geocodes with the google geocode-API:

http://maps.googleapis.com/maps/api/geocode/json?address=london%c2+UK&sensor=false

The problem is, that the input isn't very accurate (specially the street) and sometimes google mixes things up and ignores UK, because the street has a perfect match (as street and city) somewhere else. e.g. US.

Now i cannot solve this issue (input data), but I am wondering if there is a parameter, which forces google to search in UK and return no result instead of a completly wrong result.


回答1:


You can add component filters in the url to constraint results. In this case you can use:

http://maps.googleapis.com/maps/api/geocode/json?address=london%c2+UK**&components=country:UK**&sensor=false

For more information about how to use component filtering see:

https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering



来源:https://stackoverflow.com/questions/14956511/google-geocoding-api-search-in-just-one-country

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