Locations geocoding to province, not country I previously asked a question but since have done much research and am getting more focused on my problem.

I have a locations cck field in a profiles 2 profile. Here, I get users to select just countries (no cities or provinces) and they are geocoded to points and displayed on a user specific map. Many of the countries are not accurate. I have discovered the locations are being geocoded by their province code. Example: the country code is being ignored and it is selecting a province code. 




I had a problem that Barbados was being displayed in Germany. Barbados has a country code of "BB", but I found that the point was being displayed in Brandenburg Germany, the province code "BB". Every wrong point can be explained this was but 3. 

I have the geocoding setup to be at a country level accuracy. I dont think its a config problem and I have yet to find any other people with this problem.

Any ideas on what to do?

Thanks
The problem is not actually with that snippet of code in _google_geocode_flatten(), but is just a result of google's geocoding algorithms.

For example, your search for BB finds 2 results, Brandenburg Germany &amp; Barbados, however google puts the former as the first result, possibly due to popularity of searches or something.

See http://maps.googleapis.com/maps/api/geocode/json?address=bb&amp;region=bb&amp;sensor=false

The solution I can see is to also pass in the component param when requesting from google geocoder, which allows you to specify specific parts of the address in addition to the full address string.

See https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering

I have posted a patch back to your issue on drupal.org