You are here

function getdirections_entity_setlocation in Get Directions 7.3

Function to setup the map

Parameters

string $entity_type: Required. The Entity type, eg node, user etc

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

int $entity_id: Required. The entity identifier.

Return value

Returns the themed map

6 calls to getdirections_entity_setlocation()
getdirections_comment_setlocation in ./getdirections.module
Function to setup the map and form
getdirections_direction_box in ./getdirections.module
for colorbox and suchlike
getdirections_node_setlocation in ./getdirections.module
Function to setup the map and form
getdirections_setlocation in ./getdirections.module
getdirections_term_setlocation in ./getdirections.module
Function to setup the map and form

... See full list

1 string reference to 'getdirections_entity_setlocation'
getdirections_menu in ./getdirections.module
Implement hook_menu().

File

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

Code

function getdirections_entity_setlocation($entity_type, $direction, $entity_id, $width = '', $height = '') {
  if (is_numeric($entity_id) && $entity_id && getdirections_check_entity_type($entity_type)) {
    $location = getdirections_load_locations($entity_id, $entity_type);
    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 !e id !nid', array(
          '!e' => $entity_type,
          '!nid' => $entity_id,
        ), 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, $entity_id, $entity_type, $width, $height);
      return $content;
    }
  }
  return getdirections_direction();
}