Needs work
Project:
Addresses
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
24 Jan 2010 at 14:20 UTC
Updated:
26 Nov 2010 at 17:50 UTC
If you add this code to the addresses_cck.module, you get basic integration with google geocoding via the geocode module.
function addresses_cck_geocode_handlers_alter(&$handlers) {
$handlers['geocode_google']['field types'][] = 'addresses_cck';
}
The "competing" Postal module has this integration, but does not support addresses outside the US.
I tested the above code and was able to geocode addresses_module fields in the US, Germany, and Japan. Not bad for three lines of code =)
Comments
Comment #1
codycraven commentedrobertDouglass,
Thank you for the request. I will need to review the geocode module's bug list and the source code, then test with different settings/inputs in Addresses to see what kind of bugs this will introduce for Addresses users.
The reason I am cautious about integrating is that I do not want there to be a lot of unforeseen problems that will then be added to the Issue queue, which I currently would not have time to correct as there is already a lot on the plate for Addresses.
Comment #2
robertdouglass commented@codycraven, understood. The nice thing is that only the geocode module is likely to call drupal_alter('geocode_handlers'), which is the only circumstance in which the above function will get called. The code simply registers the addresses_cck field as a possible provider of address information which can then be used by geocode as the text in a geocode API requeset. And, magic! It works =)
Comment #3
robertdouglass commentedI should add that the payoff is it becomes easy to show the address fields on maps of any kind (not just google), and this seems like a huge boost in the usefulness of the module in general.
Comment #4
codycraven commentedAbsolutely robertDouglass, I agree that this simple addition could really, really be useful for many users of the Addresses module. I'll review the geocode module as soon as I get a chance.
Comment #5
benedictsteele commentedCan I add my 2 pennies worth?
I've just added this snippet of code and it works beautifully, it would great to have this available in Addresses. :)
Comment #6
codycraven commentedBenedict Steele and robertDouglass,
Have you been able to produce any issues by using different countries? If you have tried and it looks good I'll commit it - from the little amount of time I've gotten with it, it looks good.
Comment #7
robertdouglass commentedI tested with a handful of countries. Is that what you meant?
I should have provided some code comments. Here they are.
(you'll have to remove the whitespace from the url ... the filters were messing it up)
Comment #8
codycraven commentedI'll commit this as soon as I get a chance.
Comment #9
codycraven commentedcommitted
Comment #11
muschpusch commentedI have a question about the integration with geocode. Is it also possible to use the "adresses" as an exposed filter in views to do distance calculations with the geo module?
Comment #12
adamus_maximus commentedActually, there are some problems with the integration of addesses and geocode.
See my posting, along with 2 patches, here:
http://drupal.org/node/961408
My patches work fine, but structure-wise they are just quick and dirty patches. I imagine the maintainers of geocode and addresses may want to discuss a better interface.
Comment #13
BenK commentedSubscribing