You are here

function getdirections_setlocation in Get Directions 6.2

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

Function to setup the map and form

Parameters

string $direction: Required. The direction the supplied input applies to

int $nid: Required. The nid of the location node

Return value

Returns the themed map and form

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

File

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

Code

function getdirections_setlocation($direction, $nid, $width = '', $height = '') {
  if (module_exists('location')) {
    $vid = getdirections_get_vid($nid);
    $location = location_load_locations($vid);
    if (count($location)) {
      $country = isset($location[0]['country']) ? $location[0]['country'] : '';
      $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);
        $latlon = getdirections_load_latlon_defaults();
      }

      // $locs only used for display now
      $locs = _getdirections_loadaddress($location[0]);
      $content = getdirections_direction($direction, $locs, $country, $latlon, $nid, 'node', $width, $height);
      return $content;
    }
  }
  return getdirections_direction();
}