function location_map_link in Location 5
Same name and namespace in other branches
- 5.3 location.inc \location_map_link()
- 6.3 location.inc \location_map_link()
- 7.5 location.inc \location_map_link()
- 7.3 location.inc \location_map_link()
- 7.4 location.inc \location_map_link()
Get a deep-link to a mapping service such as Yahoo! Maps or MapPoint given an location. The call is delegated based on the 'country' value in the $location parameter.
Parameters
$location: An associative array where 'street' => A string representing the street location 'additional' => A string for any additional portion of the street location 'city' => A string for the city name 'province' => The standard postal abbreviation for the province 'country' => The two-letter ISO code for the country of the location (REQUIRED) 'postal_code' => The international postal code for the location
Return value
A link to a map provided by a third-party. The idea is to encode the appropriate parameters as HTTP GET variables to the URL.
1 call to location_map_link()
- theme_location in ./
location.theme - Generates HTML for the passed location.
File
- ./
location.inc, line 32
Code
function location_map_link($location = array(), $link_text = 'See map: ') {
if (!isset($location['country']) && $location['country'] != 'xx') {
return '';
}
$default_func = 'location_map_link_' . $location['country'] . '_default_providers';
$providers_func = 'location_map_link_' . $location['country'] . '_providers';
$providers = function_exists($providers_func) ? $providers_func() : array();
$selected_providers = variable_get('location_map_link_' . $location['country'], function_exists($default_func) ? $default_func() : array());
$links = array();
foreach ($selected_providers as $mapper) {
$link_func = 'location_map_link_' . $location['country'] . '_' . $mapper;
if (function_exists($link_func)) {
if ($link = $link_func($location)) {
$links[] = '<a href="' . $link . '"' . (variable_get('location_maplink_external', 0) ? ' ' . variable_get('location_maplink_external_method', 'target="_blank"') : '') . '>' . $providers[$mapper]['name'] . '</a>';
}
}
}
if (count($links)) {
return t($link_text) . implode($links, ", ");
}
else {
return NULL;
}
}