You are here

function getdirections_user_setlocations in Get Directions 6.2

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

Function to setup the map

Parameters

int $fromuid: Required. The uid of the starting point

int $touid: Required. The uid of the destination

Return value

Returns the themed map

1 call to getdirections_user_setlocations()
getdirections_direction_box in ./getdirections.module
1 string reference to 'getdirections_user_setlocations'
getdirections_menu in ./getdirections.module
Implementation of hook_menu().

File

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

Code

function getdirections_user_setlocations($fromuid, $touid, $width = '', $height = '') {
  if (module_exists('location') && is_numeric($fromuid) && is_numeric($touid)) {

    // From
    $fromlocation = location_load_locations($fromuid, 'uid');
    if (count($fromlocation)) {
      $fromlatlon = $fromlocation[0]['latitude'] . ',' . $fromlocation[0]['longitude'];

      // sanity check
      if (!getdirections_latlon_check($fromlatlon)) {
        watchdog('getdirections', 'Lat, Lon failed for user id !nid', array(
          '!nid' => $fromuid,
        ), WATCHDOG_WARNING);
        $fromlatlon = getdirections_load_latlon_defaults();
      }
      $fromlocs = _getdirections_loadaddress($fromlocation[0]);

      // To
      $tolocation = location_load_locations($touid, 'uid');
      if (count($tolocation)) {
        $tolatlon = $tolocation[0]['latitude'] . ',' . $tolocation[0]['longitude'];

        // sanity check
        if (!getdirections_latlon_check($tolatlon)) {
          watchdog('getdirections', 'Lat, Lon failed for user id !nid', array(
            '!nid' => $touid,
          ), WATCHDOG_WARNING);
          $tolatlon = getdirections_load_latlon_defaults();
        }
        $tolocs = _getdirections_loadaddress($tolocation[0]);
        $content = getdirections_locations($fromlocs, $fromlatlon, $tolocs, $tolatlon, $width, $height);
        return $content;
      }
    }
  }
  return getdirections_direction();
}