You are here

function _location_city_autocomplete in Location 7.3

Create a list of City from a given country.

Outputs a javascript array in json format. List of cities to return in json format.

Parameters

string $country: String. The country code

string $string: String (optional). The city name typed by user

1 string reference to '_location_city_autocomplete'
location_menu in ./location.module
Implements hook_menu().

File

./location.module, line 1104
Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…

Code

function _location_city_autocomplete($country, $string = '') {
  $string = strtolower($string);
  $matches = array();
  if (strpos($country, ',') !== FALSE) {

    // Multiple countries specified.
    $country = explode(',', $country);
    foreach ($country as $c) {
      $matches = array_merge($matches, location_get_cities($c, $string));
    }
  }
  else {
    $matches = location_get_cities($country, $string);
  }
  drupal_json_output($matches);
}