geocode

geocode/geocode.module, line 5

Versions
6
geocode($handler, $input, $return = 'point', $options = array())

The Geocode API call.

▾ 4 functions call geocode()

geocode in geocode/geocode.module
The Geocode API call.
geocode in geocode/geocode.module
The Geocode API call.
geocode_widget_form_validate in geocode/modules/geocode_widget/geocode_widget.module
A form validation callback for forms that include geocode widgets.
geocode_widget_form_validate in geocode/modules/geocode_widget/geocode_widget.module
A form validation callback for forms that include geocode widgets.

Code

<?php
function geocode($handler, $input, $return = 'point', $options = array()) {
  static $handlers = array();

  if (!isset($handlers[$handler])) {
    $info = geocode_handler_info();
    if ($h = $info[$handler]) {
      // Load the geocoder's file.
      $path = (isset($h['file path'])) ? $h['file path'] .'/' : '';
      require_once $path . $h['file'];

      // Instantiate a class for it.
      $handlers[$handler] = New $handler($options);
    }
  }

  if (!$handler = $handlers[$handler]) return FALSE;

  if ($handler->geocode($input, $options)) {
    list ($type, $item) = explode(':', $return);
    return $handler->get_result($type, $item);
  }
}
?>