You are here

function getdirections_setlocation_id in Get Directions 7.3

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

Function to setup the map and form

Parameters

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

int $lid: Required. The lid of the location

Return value

Returns the themed map and form

1 call to getdirections_setlocation_id()
getdirections_direction_box in ./getdirections.module
for colorbox and suchlike
1 string reference to 'getdirections_setlocation_id'
getdirections_menu in ./getdirections.module
Implement hook_menu().

File

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

Code

function getdirections_setlocation_id($direction, $lid, $width = '', $height = '') {
  if (is_numeric($lid) && $lid) {
    $location = getdirections_load_location($lid);
    if (is_array($location) && count($location)) {
      $country = isset($location['country']) ? $location['country'] : '';
      $latlon = $location['latitude'] . ',' . $location['longitude'];

      // sanity check
      if (!getdirections_latlon_check($latlon)) {
        watchdog('getdirections', 'Lat, Lon failed for location id !lid', array(
          '!lid' => $lid,
        ), WATCHDOG_WARNING);
        $latlon = getdirections_load_latlon_defaults();
      }

      // $locs only used for display now
      $locs = _getdirections_loadaddress($location);
      $content = getdirections_direction_other($direction, $locs, $country, $latlon, $lid, 'location', $width, $height);
      return $content;
    }
  }
  return getdirections_direction();
}