Closed (fixed)
Project:
Location
Version:
5.x-1.x-dev
Component:
Data update
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
10 Jul 2007 at 08:21 UTC
Updated:
4 Apr 2010 at 07:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
TimDavies commentedOk, so this was quicker to do than I thought.
I've just switched the US google geocoding routine to work for the UK with a few tweaks to take account of the accuracy setting google appears to return for UK post-codes lookups, and to make sure the minimum address information to get an accurate return is sent (e.g. if there is a postcode, only send the postcode) as otherwise too much of an address can cause Google Maps API to return a not-found...
The attached location.uk.inc should drop in place of the existing one.
Tim
Comment #2
ankur commentedWere you able to get it to geocode even w/ postcodes? I did some testing yesterday and for some reason, if I send the string "19 Leicester Square, London WC2H 7LE, uk" or "19 Leicester Square, London, uk WC2H 7LE", I get back an error saying nothing was found, whereas if I send the same string without the postcode, "19 Leicester Square, London, uk", I get an exact result.
-Ankur
Comment #3
ankur commentedAh, nevermind. I see, it'll take a street + city XOR a postcode
Comment #4
csc4 commentedLooks good - but is there a special reason it doesn't use the Gmap Google Maps key if it exists?
Drat I can't seem to get it to work - does the address/postcode comment mean you can't allow people to enter addresses _and_ postcodes or have I just missed a setup set.
Comment #5
TimDavies commentedHey
No special reason it doesn't use the Gmap api key. Feel free to update it to use that if available...
Re: postcodes / addresses - as ankur seemed to find - the google api doesn't like returning an location where both address and postcode are included (I've not tested this widely - so it may just be a quirk for the addresses I tried)... so the code tries to use a postcode if available, and then an address if no postcode is available...
If you can get your address to work from http://googlemapsapi.blogspot.com/2007/07/uk-geocoding-now-available-in-... then you might find it worth checking the accurancy google api is returning. It seemed to return lower accuracy scores for the UK than met those set in the location.us.inc, so I changed the threshold - but it may need more tweaking...
Comment #6
ankur commentedI've committed a fix for this as part of a greater patch solving the problem with redundant code for google geocoding (see http://drupal.org/node/132541 )
Comment #7
ankur commentedI've committed a fix for this as part of a greater patch solving the problem with redundant code for google geocoding (see http://drupal.org/node/132541 )
Comment #8
(not verified) commentedComment #9
rich86 commentedHi, 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.
Comment #10
nigels commentedI replaced the location.uk.inc file as per the instructions in this thread. And it was working really well for the last 2 weeks, but for some reason now its not anymore.
Is anyone else having troubles with this?
The only thing that has changed was there was an update to the gmap module.
Any one any ideas?
Thanks
Comment #11
andrew.lansdowne commentedThis might help someone who's having trouble getting Location.module to geocode places decently. I found that if you live in a town, it sends a request to google like this "Street, City, uk" where it should be "Street, Town, uk" (eg. for the town of Yate). To fix this I changed google.inc thus:
and then changed location.inc thus:
Hope this helps someone. Applies to location 5.x-1.x-dev of 2007-10-08.
Comment #12
nicholasthompsonI'm changing this back because in the 5.x-dev version I checked out, the location.uk.inc file is just a list of places - there is no lookup function.
Based on the initial change to the location.uk.inc file shown in post #1 of this issue, I include a patch which fixes the Search By Location feature.
Its basically the same function except...
location_latlon_rough_uk. I dont know what the other function name mapped to - but for searches, you need to know the 'rough' Long/Lat of the postcode.Comment #13
bdragon commentedChanging component.
Comment #14
csc4 commentedIt's great to see this as a patch - and even better when it's committed.
But I think you might like to look again at the postcode being enough - for the last few months it has suddenly stopped being enough - I'm pretty sure it's only returning the lat/lon of the aa00 0 rather than the full aa00 0aa and I'm also sure the change is recent.
I've done some searching and found threads which suggests a change October/November - though it suggest the Ajax version is more accurate (though given the Google employee's statement that the original accuracy was 'not intended' perhaps that won't last either)
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/fce6...
about the most definitive statement I can find is here
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/c880...
other threads
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/e564...
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/33d3...
and another which says the same thing WRT Driving Directions - http://groups.google.com/group/Google-Maps-API/browse_thread/thread/15b6...
so I think we need to keep as much of the address as we have in the call....
The examples given in http://groups.google.com/group/Google-Maps-API/browse_thread/thread/5eaa... are helpful - they can be put in http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html for a real time display.
Comment #15
nicholasthompsoncsc4 - nicely explained! I have just found precisely the same problem with a site i'm developing...
Just reading up on all the pages you posted ;-)
Comment #16
stephenpickett commentedHello,
I'm pretty new to Drupal - only started looking at it at the start of January for a site I am building for a client - so please bear with me if I get anything wrong here. One of their requirements is to have events listed on a map, so we decided to use the Location module and a Google Maps implementation (GMap isn't quite right for us so we're coding this ourselves). We've been having major problems getting the geocoding working for the UK. I've just figured out why, but I really don't understand why this is working for lots of people and not for me.
Anyway, what I found - after hours of tracing through code - was that the "location_geocode_uk_google()" function in location.uk.inc was not getting called. I tracked it down to line 1032 of location.inc:
if (function_exists($exact_latlon_function)) {
The problem is that the function does not seem to exist. The reason being that the provider is google|uk. Now I don't know whether this is just my installation or everyone elses so I will report a bug for others to check it out. However, if this is a problem for others I will also post how I resolved it...
On line 1026:
$exact_latlon_function = 'location_geocode_'. $country .'_'. $service;
I added in some code to remove the pipe and UK ("|uk"):
$exact_latlon_function = 'location_geocode_'. $country .'_'. substr($service, 0, strpos($service, '|'));
This then allowed the code to work correctly. I really hope this helps anyone else who has been stuck like me!
Steve
Comment #17
stephenpickett commentedHere's the link to the bug report that I mentioned above - I've posted a patch there: http://drupal.org/node/220404
Also, it's probably worth pointing out that I had to make a change to location.uk.inc to make sure it was using the correct country. I changed line 40 from:
$address = $location['postal_code'];
To:
$address = $location['postal_code'] . "," . $location['country'];
This may need to be done in other places, however I'm only doing it here because we only use the postcode for our addresses. Maybe someone "in the know" could put together a patch that implements this wherever needed?
Comment #18
giorgio79 commentedhttp://drupal.org/project/gcg
Comment #19
yesct commentedlinking this with a collection of data updates:
#175193: Zip code database out of date
Also, could someone check to see if this patch is still needed?
And if it is, please re-roll it against the newest version?
I'll mark this postponed, needs more information, for now.
Comment #20
yesct commentedclosed. no one has responded. if someone has more information, please update the status to reopen it. thanks.