Hi,

I updated the location.gr.inc to create map links to google maps.

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

function location_map_link_gr_providers() {
  return array('google' => array('name' => 'Google Maps', 'url' => 'http://www.google.com/help/terms_maps.html'));
}

function location_map_link_gr_default_providers() {
  return array('google');
}

I attach the patch for review.

And, just a thought...
maybe it would be a good idea to have a fall-back function to create map links from coordinates for all countries

Cheers,
Dimitris

CommentFileSizeAuthor
location.gr_.inc_.patch1.36 KBjimkont

Comments

tsotsos’s picture

awesome work , its also works in ver. 6.x-3.1

podarok’s picture

Status: Needs review » Active

#1931088: [META] Fixing tests tests were broken, so triggering to active

podarok’s picture

Status: Active » Needs review

bot

podarok’s picture

Status: Needs review » Fixed

#0 commited pushed to 7.x-3.x
thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.