I'm trying to geocode an address onto an OpenLayer map. The address is in this format:

825 Rinehart Rd Lake Mary, FL 32746-4867

How can I convert this using Geofield and/or Geocoder?

Comments

ejanus’s picture

- Erek J

And then there was Drupal
mastermindg’s picture

Is there a way to decode a text field? My content type is already configured with a text field for location.

## Note: The above code is fictitious. Any resemblance to real or actual working code is purely coincidental.

ejanus’s picture

Change it?

- Erek J

And then there was Drupal
mastermindg’s picture

You can't change the field type once it has data in it.

## Note: The above code is fictitious. Any resemblance to real or actual working code is purely coincidental.

ejanus’s picture

I guess you could use some php to break up the field but that sounds like a lot of work.

- Erek J

And then there was Drupal
mastermindg’s picture

I'm probably going to end up using Views PHP to geocode via Geocoder API. I'm looking at the API now.

## Note: The above code is fictitious. Any resemblance to real or actual working code is purely coincidental.

mastermindg’s picture

I ended up using Computed Field to geocode my address:

$address = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_location')));
$point = geocoder('google',$address);
$geoWKT = $point->out('wkt');
$entity_field[0]['value'] = $geoWKT;

This successfully gecodes my address to WKT.

## Note: The above code is fictitious. Any resemblance to real or actual working code is purely coincidental.

mastermindg’s picture

I highly recommend the book "Mapping with Drupal". It's an essential resource for anybody who is wanting to create interactive maps on Drupal.

## Note: The above code is fictitious. Any resemblance to real or actual working code is purely coincidental.

ejanus’s picture

Nice work!

- Erek J

And then there was Drupal
mastermindg’s picture

Thanks for your help!

## Note: The above code is fictitious. Any resemblance to real or actual working code is purely coincidental.