You are here

function geocoder_service_callback in Geocoder 7

Page callback for AJAX / Geocoder service.

This service can be accessed at /geocoder/service/<handler> and takes the query-parameter "data". Optionally a "output" parameter may also be passed. "output" corresponds to geoPHP output formats.

Some examples: /geocoder/service/google?data=4925 Gair Ave, Terrace, BC /geocoder/service/wkt?data=POINT(10 10) /geocoder/service/yahoo?data=94112&output=wkt

1 string reference to 'geocoder_service_callback'
geocoder_menu in ./geocoder.module
Implements hook_menu().

File

./geocoder.module, line 276

Code

function geocoder_service_callback($handler) {
  if (!isset($_GET['data'])) {
    throw new Exception(t('No data parameter found'));
    exit;
  }
  $format = isset($_GET['output']) ? $_GET['output'] : 'json';
  geophp_load();
  geocoder_service_check_request($handler, $format);
  $geom = geocoder($handler, $_GET['data']);
  header('Content-Type: ' . geocoder_service_get_content_type($format));
  print $geom
    ->out($format);
  exit;
}