According to the documentation, I found out this :
geocoder.setBaseCountryCode(countrycode);
However this did not work even if I hard codded the country code ( both cases :small-capital).
Any help?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
geocoder.setBaseCountryCode()will not center the map. That will set the base country for geocoding, so that if you try to geocode ‘Plymouth’, it will distinguish between the UK and the Massachusetts cities.If you want to specify the country code manually, you could use the
GClientGeocoderas follows:There is no need to use set the
setBaseCountryCode()in this case, because country codes are obviously unique.If you are using version 3 of the Google Maps API, you may want to use the
google.loader.ClientLocationto center the map automatically to the client’s country as in this Google Demo. This uses the IP address of the client to determine the country.The code would look something like this:
Note that geolocation from IP addresses is not a very reliable science. You will be getting the location of your ISP, which can be quite far away, and in addition the IP-to-location databases aren’t always up to date with the latest changes, so you might not have any data for a particular IP address. However since you would be checking for just the country, the margin of error would be quite small.