Is there a reason that (in the absence of other working service-providers) google maps call isn't used as fallback for _all_ addresses worldwide?
I know it does work for germany and austria ... no use to write the same function over and over again for all countries.
In the presence of the gmap module we could even reuse the apikey used there.

If there's no reason, I can come up with a patch to make it so ;-)

Comments

ray007’s picture

StatusFileSize
new12.81 KB

Since there were no replies I decided to go a slightly different route for now.
The attached patch
- introduces a new file supported/geocode_google.inc
- defines function location_geocode_google() and location_geocode_google_settings($cc = NULL) in there
- calls those 2 function for the specific function for 'us' and 'ca'
- adds similar code to provide geocoding and maplink with google for countries 'at' and 'de'

I think we need to define a "global service provider" that can be referenced from several countries, but this solution is good enough for me for now.

Comments?

ray007’s picture

Title: location_latlon_exact() » refactor google geocoding
Status: Active » Needs review

changed status and renamed issue to more proper title

ray007’s picture

Is there anything wrong with my patch?
I had been hoping for some feedback ...

nicolash’s picture

+1 for this. Gmaps is by far the most widely adopted mapping and geocoding service outside of the US...I believe pretty much all of Europe and certainly Australia are included...not sure about Asia.

BachusII’s picture

You can add 'nl' to the list of countries which can be geocoded by google.

JohnG-1’s picture

+1 AFAIK google maps is currently the best option. It makes sense to run with this until a better service appears, and then switch over to that one! Internationalisation of location.API is long overdue. Nice one Ray :)

ray007’s picture

is there anything I can do for this patch to be considered for inclusion?

Ian Ward’s picture

There are limitations with just using google, so maybe finding a clean way to allow for failovers would be good too. I write about the shortcomings of using just any one service over here - http://www.developmentseed.org/blog/geocoding/geonames

Ian

ray007’s picture

I do not doubt that a solution allowing the use of arbitrary geocoding-services would be preferable, but

- google seems to work for most situations where there's nothing working out of the box now
- i have a patch making it work with google right now

those of you living in the usa or canada may not feel the lack of a solution covering the rest of the world, but the rest of the world does ...

BobLouis’s picture

Ray, it seems that your patch is exactly what I needed, but for France (I was looking here before: http://drupal.org/node/147037).

How should I proceed to implement your patch? Does it work like this? Or do I have to replace "de" for Germany, by "fr" for France for example in your patch?

Thank you anyway for the job!

ray007’s picture

copy one of the country include files to location.fr.inc and change everything in the file that looks like the country code to 'fr'. remove the province list (if there is one) or write one for france and chances are pretty good it will work then ;-)

BobLouis’s picture

What I did:
- applied your patch, which created a "geocode_google.inc" file that I copied to the "modules/location/supported/" directory.
- already had a "location.fr.inc" file in that directory

What do I need to do next to get geocoding working ?

ray007’s picture

look at the file location.at.inc

You will probably copy over and adapt to country code 'fr' the following functions:
- location_map_link_*
- location_geocode_*

don't forget to require_once('geocode_google.inc'); and see what happens ;-)

ibnhafsun’s picture

It works with Spain but not the proximity searches.

Any suggestions? Does proximity search work with other countries (at, fr, de, nl)?

BobLouis’s picture

StatusFileSize
new2.23 KB

Ray, I done what you said ;)
Now I have the following error message at the top of the submit form when trying to add a location enabled event:

warning: Cannot modify header information - headers already sent by (output started at ***/modules/location/supported/location.fr.inc:1) in ***/includes/common.inc on line 141.

Would you have time to look at them, I attach:
- geocode_google.inc (I added "txt", uploading "inc" files is not allowed), since I am not sure to have performed the patch correctly
- location.fr.inc. (in the next comment)

Thank you anyway for your instructions.

BobLouis’s picture

StatusFileSize
new637 bytes

and here is "location.fr.inc"

ray007’s picture

your location.fr.inc file seems completely broken.
re-create it again starting from location.at.inc (or one of this others using google_geocode.inc)

BobLouis’s picture

I applied the patch from my PC (windows) and uploaded the results to my host. For some reason, patching from my PC didn't work properly (although I used Unxutils as explained here : http://drupal.org/node/60179).
Then I tried to apply the patch directly from my host, using Putty. And it worked !

So thank you very much for your help Ray!

Just one question now: is there a way to display the map associated with the node instead of a "See map: Google Maps" link (the map is only displayed in the node for addresses in the US)?

ray007’s picture

I have work in progress on a gmap cck field (see http://drupal.org/project/gmap_addons) and location-integration is on my list of things to do ... but will take some time.

sivasamba’s picture

Hello Im french Bob Louis.

And I would like to do the same thing like you. I can not geocode mi adresses?

What should I do?

Thanks a lot

TimDavies’s picture

Only just spotted this thread.

I wrote a patch a while back which makes use of the Geonames service as a fallback:

http://drupal.org/node/75459#comment-216146

It seems to work pretty well for me for most countries (although with more accuracy in some than others...)

It could be adapted to also use Google Maps where geonames doesn't provide a suitable response, or vice-versa.

Tim

ray007’s picture

@obscurity:

Yes, I've already seen this thread.
As I already wrote in another comment, I think we need to introduce the concept of "global geocoding services", and those have a list of countries they support. But until we get word from the maintainers about what changes they'd accept I'll happily live with using google for the countries I need. Seems to work well enough so far.

ankur’s picture

Assigned: Unassigned » ankur

I've actually been looking at the patches on this thread over the last month or so and been using them to write something similar. I should have something similar up soon (i.e., within the next week or two).

-Ankur

nashINATOR’s picture

Hey Ray!!
Your patch looks unbelievably awesome. But I have a problem, a severe handicap. I am a noob!!! I cant seem to figure out how to patch or implement the patch.
Someone please help!!!
Cheers
Nash

nashINATOR’s picture

Title: refactor google geocoding » Much accomplished

After much internal debate, and the admission to not knowing any php (limited php rather) i decided to look at the code for my self.
Well I took the us file and restructured it for nz. It works. The geocoding i mean but thats as far as it gets. I cant seem to get google maps to get the location information and display a map in the node. Maybe i need to understand the google maps module better. On the other hand i got it to work with the see map links module. (which means it opens in a new page and at the google website).
I would be eager to get some help re displaying a map within the node that gets map data from location module.
Cheers
Nash

Ps: if anyone requires the code for customising location to geocode your location contact me and i will fill you in. Basically what is to consider is does maps.google.com know where you are? Yes? then it will work. Oh! and i got my locations module to work for New Zealand

ankur’s picture

Title: Much accomplished » refactor google geocoding
Status: Needs review » Fixed

I've committed a fix for this issue. Google geocoding now takes place in only one function and you only have to enter a Google API key once. I will also look into adding additional countries for which Google Maps has recently begun offering geocoding web services. ray007 and BobLouis, thanks for your patches.

-Ankur

Anonymous’s picture

Status: Fixed » Closed (fixed)
rich86’s picture

Hi, I'm sorry to reopen this issue but I'm slightly confused about its status. I tried using the file at the top of this page but it doesn't seem to provide any geocode details for uk data.

summit’s picture

Status: Closed (fixed) » Active

SUbscribing. I have the same behaviour as stated for uk data. But for me it is Spanish dat which is not provided.

Greetings,
Martijn

raymondllee’s picture

Subscribing, I have the same issue as #28 for UK addresses

bdragon’s picture

Component: Code » Data update

Changing component to Data update.

catch’s picture

Whole bunch of geocoding issues marked as duplicate of this one: http://drupal.org/node/66887

scott.mclewin’s picture

subscribing. We do essentially this with a bespoke patch for www.folkjam.org and would really like to have a google geocode fallback for all locations.

yesct’s picture

which should be the master discussion of geocoding?

this or #66887: Better geocoding support?

yesct’s picture

yesct’s picture

cyberwolf’s picture

Subscribing.

ankur’s picture

Status: Active » Closed (fixed)

Looks like this was done a while back. Users now only need to enter their key once.