You are here

function search_api_location_get_units in Search API Location 8

Same name and namespace in other branches
  1. 7.2 search_api_location.module \search_api_location_get_units()

Returns an array of distance units.

Distance searching is kilometer based, so all multipliers must be relative to 1 kilometer.

Return value

array An associative array with supported distance units and their specifications.

2 calls to search_api_location_get_units()
LocationInputPluginBase::buildConfigurationForm in src/LocationInput/LocationInputPluginBase.php
Form constructor.
SearchApiFilterLocation::query in modules/search_api_location_views/src/Plugin/views/filter/SearchApiFilterLocation.php
Add this filter to the query.

File

./search_api_location.module, line 18
Adds location based search capabilities for Search API searches.

Code

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;
}