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

codycraven’s picture

robertDouglass,

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.

robertdouglass’s picture

@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 =)

robertdouglass’s picture

I 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.

codycraven’s picture

Absolutely 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.

benedictsteele’s picture

Can 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. :)

codycraven’s picture

Benedict 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.

robertdouglass’s picture

I tested with a handful of countries. Is that what you meant?

I should have provided some code comments. Here they are.

/**
 * Implementation of hook_geocode_handlers_alter.
 * Allows the address field to be used by the geocode module.
 * @see http:      //drupal.org/project/geocode
 */
function addresses_cck_geocode_handlers_alter(&$handlers) {
  $handlers['geocode_google']['field types'][] = 'addresses_cck'; 
} 

(you'll have to remove the whitespace from the url ... the filters were messing it up)

codycraven’s picture

Assigned: Unassigned » codycraven
Status: Needs review » Reviewed & tested by the community

I'll commit this as soon as I get a chance.

codycraven’s picture

Status: Reviewed & tested by the community » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

muschpusch’s picture

I 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?

adamus_maximus’s picture

Category: feature » bug
Status: Closed (fixed) » Needs work

Actually, 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.

BenK’s picture

Subscribing