2

I'm using https://maps.gstatic.com/maps-api-v3/api/js/19/4/intl/en_gb/geocoder.js

geocoder.geocode({"address":"European Union"}, ... 

returns New York, USA as its location !!

What changes, additional parameters, etc must I use to receive a more rational location ? Note: geocoder.geocode({"address":"EU"}, ... works fine, as do all country names I have tried.

Regards, Pete

MightyPork
  • 18,270
  • 10
  • 79
  • 133

3 Answers3

3

The New York location you got is the European Union foreign embassy for the US. You can't make changes to the library, so you'll just have to change what you're passing into the geocoder. If you're trying to geocode for countries in the EU, you'd have to pass in each country you're interested in. Just a note, when I try geocoding "Eu", I get Eu, Seine-Maritime, which is located in France.

You can also put EU as the region for the GeocodeRequest object literal before passing it to Geocode.geocode() as documented here: https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingRequests

If you're working with JavaScript and HTML, you can use region code biasing to specify EU as the region for the Google map API in the script source (although the example below uses ES, but the idea is the same): https://developers.google.com/maps/documentation/javascript/examples/geocoding-region-es

not_a_bot
  • 2,332
  • 2
  • 19
  • 33
1

I hope I'm not stating the obvious, but the European Union isn't a place that you can stick a map marker on!

It's an economic partnership between 28 different countries in and around the continent of Europe (yes, I know - some people from an English speaking country that isn't England do think that Europe is a country).

If you add EU for the region bias to the Google geocoder it will prioritise results for the Basque region (which is in Spain). You can look all the IANA Language Regions here: http://www.iana.org/assignments/language-subtag-registry.

You're trying to geocode a collection of countries as a single entity - it's not going to work no matter how many bug reports you file.

  • Can the Geocoder locate the United States or Louisiana? In that case, it would be reasonable to expect it to be able to locate the European union, too. – Jozef Mikušinec Jan 04 '20 at 19:34
0

I'll take your word for it that the New York location is that of an EU foreign embassy. And I hadn't noticed that a request for address EU returned the co-ordinates of a village in France named Eu (as opposed to a more generic location within Europe).

Including region EU within the geocode request appears to have no effect on the result. For example, the following request returns the location of Naples in Italy. But if I change IT to EU, or omit region completely, the location returned is for Naples in Florida:

"address":"Naples","region":"IT"

Google geocoder appears to accept any 2-character combination for region - and simply ignores any it does not recognise. It looks like "EU" is one such, despite it being listed since 2009 as an IANA language region subtag.

Any other ideas? Or should I raise this directly with Google?

  • Hi ABTUK Webmaster... Even we figured out the same thing, Its not just EU but other regions too. When you have a subtype of a region and enter with a combination of city/country you know the region is in still return a different value as expected or return not found. But can you tell the address you are trying to look into the map with the Geocoder API, because there is a possibility that EU being a sensitive location may not be access through these open source Google API. – AniV Jan 08 '15 at 19:32
  • Hi @AniV... the address I was looking for is exactly what is in the 2nd line of this post, i.e. geocoder.geocode({"address":"European Union"}, ... If I specify a country name (e.g. Germany, USA, etc), geocoder returns a sensible location. But for "European Union" it doesn't. – ABTUK Webmaster Jan 17 '15 at 19:14
  • Hi @Aniv ... That's great. But who did you file the bug with? If it's somewhere that Google geocoder developers are unlikely to visit, I'll open a ticket directly with them (assuming I can find out how ...) – ABTUK Webmaster Jan 23 '15 at 14:24