You are here

function getdirections_locations in Get Directions 7.3

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

Function to setup the map

Parameters

string $fromlocs: Required. The string to display for From.

string $fromlatlon: Required. The location point for From. In decimal latitude,longitude

string $tolocs: Required. The string to display for To.

string $tolatlon: Required. The location point for To. In decimal latitude,longitude

Return value

Returns the themed map.

2 calls to getdirections_locations()
getdirections_entity_setlocations in ./getdirections.module
Function to setup the map
getdirections_locations_bylatlon in ./getdirections.api.inc
API Function to setup a map with two points

File

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

Code

function getdirections_locations($fromlocs, $fromlatlon, $tolocs, $tolatlon, $width = '', $height = '') {
  if (!getdirections_check()) {
    return t('You need to !c first.', array(
      '!c' => l('configure Getdirections', 'admin/config/services/getdirections'),
    ));
  }
  $getdirections_defaults = getdirections_defaults();
  $getdirections_misc = getdirections_misc_defaults();
  getdirections_setup_map($getdirections_defaults, $getdirections_misc);
  $getdirections_settings = getdirections_get_settings($getdirections_defaults, $getdirections_misc);

  // remove brackets if any
  $fromlatlon = preg_replace("/^\\(|\\)\$/", '', $fromlatlon);
  $getdirections_settings['fromlatlon'] = $fromlatlon;
  $tolatlon = preg_replace("/^\\(|\\)\$/", '', $tolatlon);
  $getdirections_settings['tolatlon'] = $tolatlon;
  $mapid = getdirections_get_key();
  drupal_add_js(array(
    'getdirections' => array(
      $mapid => $getdirections_settings,
    ),
  ), 'setting');
  if (empty($width)) {
    $width = $getdirections_defaults['width'];
  }
  if (empty($height)) {
    $height = $getdirections_defaults['height'];
  }
  return theme('getdirections_show_locations', array(
    'mapid' => $mapid,
    'width' => $width,
    'height' => $height,
    'fromlocs' => $fromlocs,
    'tolocs' => $tolocs,
  ));
}