Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google geocoding API - search in just one country

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.

like image 362
marty bourque Avatar asked Feb 19 '13 11:02

marty bourque


People also ask

How do I show only one country on Google Maps?

we can allow only specific country to autocomplete search in google maps. We are using google map autocomplete for choosing address with latitude and longitude. but if you require to search only one country like in, us, uk etc then you can do it using setComponentRestrictions option in google map.

Is Google's geocoding API free?

The Geocoding API uses a pay-as-you-go pricing model. Geocoding API requests generate calls to one of two SKUs depending on the type of request: basic or advanced. Along with the overall Google Terms of Use, there are usage limits specific to the Geocoding API.

How do I find a geocode for a location?

One way to find your geolocation is to simply perform a lookup online. Melissa's Geocoder Lookup tool returns latitude, longitude, county, census tract and block data based on an address or ZIP Code. Simply enter the address or ZIP Code into the easy-to-use Lookups interface and submit.

Is reverse geocoding API free?

Yes, the Geoapify Reverse Geocoding Tool is Free! You can upload and process multiple locations. No coding and registration required. You can also use Geoapify Reverse Geocoding API and process up to 3000 addresses per day for FREE.


1 Answers

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

like image 95
jmm Avatar answered Oct 28 '22 08:10

jmm