Today we will have a look at a simple geocoding example wherein we will see the effects of region biasing on geocoding. First things first. What is region biasing in geocoding and why is it required; would be an obvious looking question here. The answer to this is pretty simple and straight. Region biasing means returning a geocoded address so that it falls in the region specified. Consider the example of the city named “Hyderabad” which is present in India as well as Pakistan. Now, suppose that my target users are from India, then by using the region biasing property, the geocoder will always return the “Hyderabad” in India when a user enters a request for the same. I have taken the same example in the code, so that the region biasing geocoding concept would become much more clear.
The code goes here…
The code is pretty simple and does not need an explanation. The crux of the code lies in the following line of code.
As you can see, the region property is set to “IN” which is a code for India. This is a hardcoded example, where the address to be geocoded is set to “Hyderabad”. Check out the line, var query = "Hyderabad". Now as the region is set to India the output that would be seen will be as seen in the result section above.
Now change the region value to “PK”, i.e. Pakistan as,
Now change the region value to “PK”, i.e. Pakistan as,
The output that you will see is as below:
If you have any queries regarding the code feel free to leave a comment! Till the next Google Maps API v3 example…Keep mapping!
I tried region=IN but still getting suggestions for outside india.
ReplyDeleteI am using auto complete to show suggestion like google maps do
Hi IndiaVote09.
DeleteCould you let me know what were you looking for (geocoding) with region=IN?
Please respond and I would be happy to check and revert!
Regards,
Shreerang.
Like us on Facebook at https://www.facebook.com/pages/Spatial-Unlimited/185149371538692