Reputation: 14600
Here is my string I'm passing to the geocoder service.
where region=GB is country code for United Kingdom and instead of London I'm passing in Lindon. Componentrestrictions=locality should be for cities only!
But my results are coming back with some location in the USA!!
Is this not how you use component restrictions for google geocoder?
I don't want to see any results here if 'Lindon' is passed in, especially not for the USA.
Upvotes: 1
Views: 2920
Reputation: 117354
componentRestrictions
(this parameter belongs to the Javascript-API), the parameter for the Webservice is called components
locality
) and a value. In your case, when you want to search for a city called Lindon it should be locality:Lindon
region
-parameter doesn't restrict the results, it will only prefer results from the given region.
Use the component country:gb
when you want to restrict the results to GB.Sample-request for a city Washington (as it seems there is no city Lindon in the UK)
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:Washington|country:gb
Upvotes: 1
Reputation: 6158
Add ",GB" for address parameter.
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=Lindon,UK®ion=GB&componentRestrictions=locality&language=en
The region parameter is just "biasing", not restricted the area. https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingRegionCodes
In my experience, adding country code, zip code, works for all most cases.
Upvotes: 0