You are here

function location_map_link_gr_google in Location 7.3

Google link.

File

supported/location.gr.inc, line 44
Greece.

Code

function location_map_link_gr_google($location = array()) {
  $query_params = array();
  foreach (array(
    'street',
    'city',
    'province',
    'postal_code',
  ) as $field) {
    if (isset($location[$field]) && $location[$field] != '') {
      $query_params[] = $location[$field];
    }
  }

  // Country always exists.
  if (count($query_params) != 0 && isset($location['country']) && $location['country'] != '') {
    $query_params[] = $location['country'];
  }

  // When no address provided, but coordinates do, link to coordinates.
  if (count($query_params) == 0) {
    foreach (array(
      'latitude',
      'longitude',
    ) as $field) {
      if (isset($location[$field])) {
        $query_params[] = $location[$field];
      }
    }
  }
  if (count($query_params)) {
    return 'http://maps.google.com?q=' . urlencode(implode(", ", $query_params));
  }
  else {
    return NULL;
  }
}