You are here

function getdirections_defaults in Get Directions 6

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

Some defaults.

5 calls to getdirections_defaults()
getdirections_direction in ./getdirections.module
Function to setup the map and form
getdirections_direction_form in ./getdirections.module
Function to setup the form
getdirections_locations in ./getdirections.module
Function to setup the map
getdirections_locations_via in ./getdirections.module
Function to setup the map
getdirections_settings_form in ./getdirections.admin.inc
Function to display the getdirections admin settings form

File

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

Code

function getdirections_defaults() {

  // no gmap for v3 googlemap API
  if (variable_get('use_v3', 0)) {
    $defaults = array(
      'api_version' => 3,
      'width' => '300px',
      'height' => '200px',
      'zoom' => 3,
      'controltype' => 'default',
      'latlong' => '40,0',
      'maptype' => 'Map',
      'mtc' => 'standard',
      'baselayers' => array(
        'Map' => 1,
        'Satellite' => 1,
        'Hybrid' => 1,
        'Physical' => 1,
      ),
      'behavior' => array(
        'scale' => 0,
        'scrollwheel' => 0,
        'draggable' => 1,
      ),
      'unitsystem' => 'auto',
      'from_width' => 20,
      'to_width' => 20,
      'travelmode_show' => 0,
      'travelextras_show' => 0,
    );
  }
  else {
    if (module_exists('gmap')) {
      $defaults = gmap_defaults();
      $defaults['api_version'] = GMAP_API_VERSION;
    }
    else {
      $defaults = array(
        'api_version' => 2,
        'width' => '300px',
        'height' => '200px',
        'zoom' => 3,
        'controltype' => 'Small',
        'latlong' => '40,0',
        'maptype' => 'Map',
        'mtc' => 'standard',
        'baselayers' => array(
          'Map' => 1,
          'Satellite' => 1,
          'Hybrid' => 1,
          'Physical' => 0,
        ),
        'behavior' => array(
          'scale' => 0,
          'overview' => 0,
        ),
        'from_width' => 20,
        'to_width' => 20,
      );
    }
  }
  $getdirections_defaults = variable_get('getdirections_default', array());

  // array_merge deletes things in $defaults that are not in $getdirections_defaults ;-/
  // roll my own
  $newdefaults = array();
  foreach ($defaults as $k => $v) {
    if (is_array($v)) {
      foreach ($defaults[$k] as $k1 => $v1) {
        if (isset($getdirections_defaults[$k][$k1])) {
          $newdefaults[$k][$k1] = $getdirections_defaults[$k][$k1];
        }
        else {
          $newdefaults[$k][$k1] = $v1;
        }
      }
    }
    else {
      if (isset($getdirections_defaults[$k])) {
        $newdefaults[$k] = $getdirections_defaults[$k];
      }
      else {
        $newdefaults[$k] = $v;
      }
    }
  }
  return $newdefaults;
}