Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently the google_geocode_location() function retrieves the lat/lon values from its google geocoding request.
Google also returns state & city data where it can so if this data is available it should be used.
Comment | File | Size | Author |
---|---|---|---|
#1 | location-enhance_google_geocode-839412-1.patch | 3.11 KB | rooby |
Comments
Comment #1
rooby CreditAttribution: rooby commentedHere is a patch that should do it.
It is to be applied over the top of the patch in #343487-11: 2 proposals: location_latlon_rough_default / extrenal geocoding of not-matching zips (location.de.inc location.xx.inc)
Comment #2
rooby CreditAttribution: rooby commentedComment #3
hutch CreditAttribution: hutch commentedI've created a new instance of drupal and installed location (no gmap this time) plus the two patches.
Created two nodes with full addresses, both geocoded fine as far as lat/lon goes but nothing in zipcodes, kinda thought it might put the finds there. One UK and one US address. I think I will drop some dd() in there and see what is going on.
BTW I see in the location table that column source has 3 in it, not sure what that means as yet so that's another thing to get a grip on.
I enabled google in admin/settings/location/geocoding for UK, US, Germany and Australia, I might try just postcodes next.
Comment #4
Summit CreditAttribution: Summit commentedSubscribing, greetings, Martijn
Comment #5
rooby CreditAttribution: rooby commented@hutch:
One thing to look out for is that for certain countries google_geocode_location() is never called because they have their own country specific geocoding functions in location.xx.inc.
If it is running google_geocode_location() it should be adding it to the database if it is working correctly.
So far I have only done tests calling the functionality from a devel execute PHP block. I still have to do a better test of it working via the module.
Also, I have just realised that country specific google geocoding (like _location_latlon_exact_us_geocoder() in location.us.inc) should have this functionality where possible too.
I'll check it out later.
Comment #6
hutch CreditAttribution: hutch commentedUsing uk postcodes and having made sure nothing in location.uk.inc would jump in, I found that rough and rough_default were never being reached, location_latlon_exact was being called in _location_geo_logic from location.module. Haven't traced that back yet. I'm using location enabled nodes to test this all.
More later...
Comment #7
hutch CreditAttribution: hutch commented@rooby:
On saving a node, location_save() runs location_latlon_exact() via _location_geo_logic() which only saves lat/lon. There is a comment in location.module line 1324 // @@@ How about address normalization?
This suggests that this would be a good place to add city and state, so I added
I now am saving province to the location table when I supplied country and postcode only. 'city' was not supplied by google in this particular instance. I only ran one test on UK postcode. I will try some other countries too.
rant start
UK postcodes are a pain because they are in two parts and the Royal Mail are being despicably duplicitous, insisting on the right to sell data already paid for by the taxpayer ;-| grrrrrr. Oh well
rant end
Now none of this addresses the original idea of saving geocode stuff to zipcodes table.
I would suggest some new functions: (in location.inc)
1) location_insert_zipcodes
2) location_update_zipcodes
3) a handling function function which would ensure that the zipcodes table was updated sensibly, preserving existing data etc
or perhaps all three rolled into one.
3) could be called in _location_geo_logic() or perhaps even better in location_latlon_exact()
This way it doesn't matter if rough and rough_default are used or not.
Comment #8
Summit CreditAttribution: Summit commentedWill this patch bring europe/worldwide google geocoding available to location?
Greetings, Martijn
Comment #9
legolasboClosing old D6 issues as D6 is end of life