Closed (fixed)
Project:
Location
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 May 2011 at 17:25 UTC
Updated:
26 Mar 2013 at 18:00 UTC
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
| Comment | File | Size | Author |
|---|---|---|---|
| location.gr_.inc_.patch | 1.36 KB | jimkont |
Comments
Comment #2
tsotsos commentedawesome work , its also works in ver. 6.x-3.1
Comment #3
podarok#1931088: [META] Fixing tests tests were broken, so triggering to active
Comment #4
podarokbot
Comment #5
podarok#0 commited pushed to 7.x-3.x
thanks!