You are here

function getdirections_setlocations_via in Get Directions 7.2

Same name and namespace in other branches
  1. 6.2 getdirections.module \getdirections_setlocations_via()
  2. 6 getdirections.module \getdirections_setlocations_via()

Function to setup the map to display waypoints

Parameters

string $nids: Required. A comma delimited list of nids

Return value

Returns the themed map

1 call to getdirections_setlocations_via()
getdirections_direction_box in ./getdirections.module
1 string reference to 'getdirections_setlocations_via'
getdirections_menu in ./getdirections.module
Implement hook_menu().

File

./getdirections.module, line 1042
Fetches google map directions.

Code

function getdirections_setlocations_via($nids, $width = '', $height = '') {
  $arrnids = explode(',', $nids);
  foreach ($arrnids as $key => $nid) {
    if ($key > GETDIRECTIONS_WAYPOINTS_MAX && $key < count($arrnids)) {
      continue;
    }
    if (!is_numeric($nid) || !$nid) {
      continue;
    }
    $vid = getdirections_get_vid($nid);
    $location = getdirections_load_locations($vid);
    if (!count($location)) {
      continue;
    }
    $locs = _getdirections_loadaddress($location[0]);
    $latlon = $location[0]['latitude'] . ',' . $location[0]['longitude'];

    // sanity check
    if (!getdirections_latlon_check($latlon)) {
      watchdog('getdirections', 'Lat, Lon failed for node id !nid', array(
        '!nid' => $nid,
      ), WATCHDOG_WARNING);
      continue;
    }
    $latlons[] = $latlon;
  }
  $content = getdirections_locations_via($locs, $latlons, $width, $height);
  return $content;
}