You are here

function getdirections_user_setlocations_via in Get Directions 6.2

Same name and namespace in other branches
  1. 6 getdirections.module \getdirections_user_setlocations_via()
  2. 7.3 getdirections.module \getdirections_user_setlocations_via()
  3. 7.2 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
Implementation of hook_menu().

File

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

Code

function getdirections_user_setlocations_via($uids, $width = '', $height = '') {
  if (module_exists('location')) {
    $arruids = explode(',', $uids);
    foreach ($arruids as $key => $uid) {
      if ($key > GETDIRECTIONS_WAYPOINTS_MAX && $key < count($arruids)) {
        continue;
      }
      $location = location_load_locations($uid, 'uid');
      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 user id !nid', array(
          '!nid' => $uid,
        ), WATCHDOG_WARNING);
        continue;
      }
      $latlons[] = $latlon;
    }
    $content = getdirections_locations_via($locs, $latlons, $width, $height);
    return $content;
  }
  return getdirections_direction();
}