You are here

function getdirections_user_setlocations_via in Get Directions 7.2

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

Function to setup the map to display waypoints

Parameters

$uids: Required. A comma delimited list of uids

Return value

Returns the themed map

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

File

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

Code

function getdirections_user_setlocations_via($uids, $width = '', $height = '') {
  $arruids = explode(',', $uids);
  foreach ($arruids as $key => $uid) {
    if ($key > GETDIRECTIONS_WAYPOINTS_MAX && $key < count($arruids)) {
      continue;
    }
    if (!is_numeric($uid) || !$uid) {
      continue;
    }
    $locations = getdirections_load_locations($uid, 'uid');
    if (!count($locations)) {
      continue;
    }
    $locs = _getdirections_loadaddress($locations[0]);
    $latlon = $locations[0]['latitude'] . ',' . $locations[0]['longitude'];

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