function location_map_link_dk_rejseplanen in Location 6.3
Same name and namespace in other branches
- 5.3 supported/location.dk.inc \location_map_link_dk_rejseplanen()
- 7.5 supported/location.dk.inc \location_map_link_dk_rejseplanen()
- 7.3 supported/location.dk.inc \location_map_link_dk_rejseplanen()
- 7.4 supported/location.dk.inc \location_map_link_dk_rejseplanen()
Generate a link to Rejseplanen.
Rejseplanen is a route planner for Danish public transportation.
Parameters
array $location: The location array we're trying to generate a link for.
Return value
string or null Map link if generation successful, otherwise null.
File
- supported/
location.dk.inc, line 64
Code
function location_map_link_dk_rejseplanen($location = array()) {
$keys = array();
// Iterate over all the possible details, and if set, add them to an array.
foreach (array(
'street',
'postal_code',
'city',
) as $name) {
if (isset($location[$name]) && !empty($location[$name])) {
$keys[$name] = $location[$name];
}
}
// Merge postal code and city if both are available, since they
// shouldn't be comma separated in Danish addresses.
if (isset($keys['postal_code']) && isset($keys['city'])) {
$keys['postal_code'] = $keys['postal_code'] . ' ' . $keys['city'];
unset($keys['city']);
}
// If any of the key values were available, generate a URL.
if (!empty($keys)) {
return url('http://www.rejseplanen.dk/bin/query.exe/mn?Z=' . implode(', ', $keys) . '&ZADR=1');
}
else {
return NULL;
}
}