You are here

geocoder.module in Geocoder 7.2

Module file for Geocoder module.

File

geocoder.module
View source
<?php

/**
 * @file
 * Module file for Geocoder module.
 */

/**
 * The Geocoder API call.
 *
 * Given one or more plugin id(s), geocode the given data.
 *
 * @param string|string[] $plugin_ids
 *   The geocoder plugin id(s) to use.
 * @param string $data
 *   Data to be passed into the handler for geocoding.
 *   For example a address string.
 * @param array $options
 *   Additional options to pass to the handler.
 *   Exact key / values to pass depend on the handler. (Optional)
 *
 * @return mixed
 *    \Geocoder\Model\AddressCollection|FALSE
 *
 * @example:
 *    geocoder('googlemaps', '1600 Amphitheatre Parkway Mountain View,
 *    CA 94043');
 *    geocoder(array('freegeoip', 'googlemaps'), '8.8.8.8');
 *
 * @codingStandardsIgnoreStart
 */
function geocoder($plugin_ids, $data, array $options = array()) {
  if ($value = \Drupal\geocoder\Geocoder::geocode($plugin_ids, $data, $options)) {

    // @codingStandardsIgnoreEnd
    return $value;
  }
  return FALSE;
}

/**
 * The reverse Geocoder API call.
 *
 * Given one or more plugin id(s), a latitude and a longitude,
 * reverse geocode the given data.
 *
 * @param string|string[] $plugin_ids
 *   The geocoder plugin id(s) to use.
 * @param string $latitude
 *   The latitude.
 * @param string $longitude
 *   The longitude.
 * @param array $options
 *   Additional options to pass to the handler.
 *   Exact key / values to pass depend on the handler. (Optional)
 *
 * @return mixed
 *    \Geocoder\Model\AddressCollection|FALSE
 *
 * @example:
 *    reverse('googlemaps', '37.4224504', '-122.0840859');
 *
 * @codingStandardsIgnoreStart
 */
function reverse($plugin_ids = 'googlemaps', $latitude, $longitude, array $options = array()) {
  if ($value = \Drupal\geocoder\Geocoder::reverse($plugin_ids, $latitude, $longitude, $options)) {

    // @codingStandardsIgnoreEnd
    return $value;
  }
  return FALSE;
}

Functions

Namesort descending Description
geocoder The Geocoder API call.
reverse The reverse Geocoder API call.