You are here

function google_geocode_country_list_xml in Location 7.5

Same name and namespace in other branches
  1. 5.3 geocoding/google.inc \google_geocode_country_list_xml()
  2. 7.4 geocoding/google.inc \google_geocode_country_list_xml()

Returns an XML document containing the list of countries supported by the Google geocoder. A cached version is stored in the Drupal cache in case Google is unreachable.

1 call to google_geocode_country_list_xml()
google_geocode_country_list in geocoding/google.inc
Return the list of ISO3166 codes supported by this geocoder. Coverage list: http://gmaps-samples.googlecode.com/svn/trunk/mapcoverage_filtered.html Coverage list feed: http://spreadsheets.google.com/feeds/list/p9pdwsai2hDMsLkXsoM05KQ/defaul...

File

geocoding/google.inc, line 13
Google geocoder.

Code

function google_geocode_country_list_xml() {

  // Get the google data from the feed.
  $source = drupal_http_request('http://spreadsheets.google.com/feeds/list/p9pdwsai2hDMsLkXsoM05KQ/default/public/values');
  if (!$source->data) {

    // Use the cache.
    $data = cache_get('location_google');
    if (!defined('LIBXML_VERSION') || version_compare(phpversion(), '5.1.0', '<')) {
      $xml = simplexml_load_string($data->data, NULL);
    }
    else {
      $xml = simplexml_load_string($data->data, NULL, LIBXML_NOERROR | LIBXML_NOWARNING);
    }
  }
  else {
    if (!defined('LIBXML_VERSION') || version_compare(phpversion(), '5.1.0', '<')) {
      $xml = simplexml_load_string($source->data, NULL);

      // Stores the XML in the cache to eventually use it later.
      cache_set('location_google', $xml
        ->asXML());
    }
    else {
      $xml = simplexml_load_string($source->data, NULL, LIBXML_NOERROR | LIBXML_NOWARNING);

      // Store the XML in the cache to eventually use it later.
      cache_set('location_google', $xml
        ->asXML());
    }
  }
  return $xml;
}