3
votes

I am using Google Maps Geocoding API to get geometry bounds (northeast, southwest values) of entering the address in store locator address filter.

Example:

When I use to search an address (Postal code, Street name, Landmark) of Singapore with components=country:SG parameter as like below, it gives only one value in address_components result set and also this geometry bounds values are not correct for a given address.

https://maps.googleapis.com/maps/api/geocode/json?address=14%20Scotts%20road&components=country:SG

When I use to search an address (Postal code, Street name, Landmark) of Singapore with region=SG parameter as like below, it gives more than one values in address_components result set and also this geometry bounds values are correct for a given address.

https://maps.googleapis.com/maps/api/geocode/json?address=14%20Scotts%20road&region=SG

So here I would like to know the difference and better invoking way between these two methods(region=SG vs components=country:SG).

1

1 Answers

4
votes

From the documentation:

  • region — The region code, specified as a ccTLD ("top-level domain") two-character value. This parameter will only influence, not fully restrict, results from the geocoder. (For more information see Region Biasing below.)

  • components — The component filters, separated by a pipe (|). Each component filter consists of a component:value pair and will fully restrict the results from the geocoder. For more information see Component Filtering, below.

When you filter on the country, you get the result for the country (in your example the result is for the country of Singapore). If you bias for the region, the returned result prefers results in the country (which it sounds like what you want), but doesn't restrict them to that country and will return a result for an address.