You are here

function getdirections_term_setlocation in Get Directions 7.2

Same name and namespace in other branches
  1. 7.3 getdirections.module \getdirections_term_setlocation()

Function to setup the map and form

Parameters

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

int $tid: Required. The tid of the location enabled taxonomy term

Return value

Returns the themed map and form

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

File

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

Code

function getdirections_term_setlocation($direction, $tid, $width = '', $height = '') {
  if (is_numeric($tid) && $tid) {
    $locations = getdirections_load_locations($tid, 'tid');
    if (count($locations)) {
      $country = isset($locations[0]['country']) ? $locations[0]['country'] : '';
      $latlon = $locations[0]['latitude'] . ',' . $locations[0]['longitude'];

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

      // $locs only used for display now

      #$loc = _getdirections_loadaddress($location[0]);
      $term = taxonomy_term_load($tid);
      $locs = $term->name;
      $content = getdirections_direction($direction, $locs, $country, $latlon, $tid, 'term', $width, $height);
      return $content;
    }
  }
  return getdirections_direction();
}