function getdirections_setlocations in Get Directions 6
Same name and namespace in other branches
- 6.2 getdirections.module \getdirections_setlocations()
- 7.2 getdirections.module \getdirections_setlocations()
Function to setup the map
Parameters
$fromvid: Required. The nid/vid of the starting point
$tovid: Required. The nid/vid of the destination
Return value
Returns the themed map
1 string reference to 'getdirections_setlocations'
- getdirections_menu in ./
getdirections.module - Implementation of hook_menu().
File
- ./
getdirections.module, line 560 - Fetches google map directions.
Code
function getdirections_setlocations($fromvid, $tovid) {
if (module_exists('location') && is_numeric($fromvid) && is_numeric($tovid)) {
// From
$fromlocation = location_load_locations($fromvid);
if (count($fromlocation)) {
$fromlatlon = $fromlocation[0]['latitude'] . ',' . $fromlocation[0]['longitude'];
$fromloc = _getdirections_loadaddress($fromlocation[0]);
if ($fromlocation[0]['country']) {
$fromloc[] = drupal_strtoupper($fromlocation[0]['country']);
}
$fromlocs = implode(', ', $fromloc);
// To
$tolocation = location_load_locations($tovid);
if (count($tolocation)) {
$tolatlon = $tolocation[0]['latitude'] . ',' . $tolocation[0]['longitude'];
$toloc = _getdirections_loadaddress($tolocation[0]);
if ($tolocation[0]['country']) {
$toloc[] = drupal_strtoupper($tolocation[0]['country']);
}
$tolocs = implode(', ', $toloc);
$content = getdirections_locations($fromlocs, $fromlatlon, $tolocs, $tolatlon);
return $content;
}
}
}
}