JP Silvashy
JP Silvashy

Reputation: 48535

Is Google maps `region` parameter determined automatically?

The Google Maps JS API allows for a few localization options to be set, some appear to be automatically detected by the users browser, for example the language parameter will be set by the client.

There seems to be no mention of the region parameter being set in the same fashion, however it affects the user experience and how the maps handle user input.

Do I need to set this parameter to provide a more localized experience for visitors?

This is not clear from the docs, or my testing (what is the best way to really test this?)

Here is an example: https://developers.google.com/maps/documentation/javascript/examples/geocoding-region-us

Upvotes: 0

Views: 353

Answers (1)

xomena
xomena

Reputation: 32178

Google Maps JavaScript API supports both language and region parameters. You can apply them when you load an API as described in the official documentation

https://developers.google.com/maps/documentation/javascript/localization

Typically providing a region parameter affects the representation of tile imagery especially in areas where different countries have different names for the same geographical feature. For example, Sea of Japan which will be shown as East see with Korean regional settings.

Referring to the services (geocoding, directions, etc.) Google Maps JavaScript API uses a visible view port of the map to bias results to the visible area/region. This logic is applied to client side services and places library as you can see in the example mentioned in your question.

I believe the easiest way to demonstrate this might be autocomplete in place finder. Let set visible view port on Sydney and type 'Hyde'. All prediction will be from Australia according to the visible view port as shown in my screenshot.

enter image description here

Now change view port to London and type 'Hyde' again. This time all predictions will be biased toward United Kingdom.

enter image description here

I hope my answer explains your doubts!

Upvotes: 1

Related Questions