You are here

function getdirections_setup_map in Get Directions 6

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

Function to setup the map scripts

Parameters

$defaults: Required. the current settings. Sets up the call to googlemaps, css and the relevant getdirections js in html head

3 calls to getdirections_setup_map()
getdirections_direction in ./getdirections.module
Function to setup the map and form
getdirections_locations in ./getdirections.module
Function to setup the map
getdirections_locations_via in ./getdirections.module
Function to setup the map

File

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

Code

function getdirections_setup_map($defaults) {
  global $language;
  if (variable_get('use_v3', 0)) {

    // v3
    $query = array(
      'sensor' => 'false',
      'language' => $language->language,
    );
    $head = '<script src="' . url('http://maps.google.com/maps/api/js', array(
      'query' => $query,
    )) . '" type="text/javascript"></script>';
    $js = drupal_get_path('module', 'getdirections') . '/getdirections_v3.js';
  }
  else {

    // v2
    if (module_exists('gmap')) {
      $query = array(
        'file' => 'api',
        'v' => $defaults['api_version'] ? $defaults['api_version'] : GMAP_API_VERSION,
        'key' => gmap_get_key(),
        'hl' => $language->language,
      );
    }
    else {
      $query = array(
        'file' => 'api',
        'v' => $defaults['api_version'] ? $defaults['api_version'] : '2',
        'key' => variable_get('getdirections_api_key', ''),
        'hl' => $language->language,
      );
    }
    $head = '<script src="' . url('http://maps.google.com/maps', array(
      'query' => $query,
    )) . '" type="text/javascript"></script>';
    $js = drupal_get_path('module', 'getdirections') . '/getdirections_v2.js';
  }
  drupal_set_html_head($head);
  drupal_add_css(drupal_get_path('module', 'getdirections') . '/getdirections.css');
  drupal_add_js($js);
}