You are here

search_api_location.module in Search API Location 8

Same filename and directory in other branches
  1. 7.2 search_api_location.module
  2. 7 search_api_location.module

Adds location based search capabilities for Search API searches.

File

search_api_location.module
View source
<?php

/**
 * @file
 * Adds location based search capabilities for Search API searches.
 */

/**
 * Returns an array of distance units.
 *
 * Distance searching is kilometer based, so all multipliers must be relative to
 * 1 kilometer.
 *
 * @return array
 *   An associative array with supported distance units and their
 *   specifications.
 */
function search_api_location_get_units() {
  $units =& drupal_static(__FUNCTION__);
  if (!isset($units)) {
    $units = [
      'km' => [
        'id' => 'km',
        'multiplier' => 1,
        'label' => 'Kilometers',
        'abbreviation' => 'km',
      ],
      'mi' => [
        'id' => 'mi',
        'multiplier' => 1.60935,
        'label' => 'Miles',
        'abbreviation' => 'mi',
      ],
    ];
    \Drupal::moduleHandler()
      ->alter('search_api_location_units', $units);
  }
  return $units;
}

Functions

Namesort descending Description
search_api_location_get_units Returns an array of distance units.