You are here

function route_planner_get_address_form in Route Planner 7

Same name and namespace in other branches
  1. 6 route_planner.module \route_planner_get_address_form()

Get Address-Form Block

Helper function to add several stuff to the Block.

Return value

The address form.

1 call to route_planner_get_address_form()
route_planner_block_view in ./route_planner.module
Implements hook_block_view().

File

./route_planner.module, line 174
The Route Planner module create blocks to show a route from any address to a fixed point.

Code

function route_planner_get_address_form() {

  // Detect protocol to use when calling maps api.
  global $is_https;
  $protocol = $is_https ? 'https://' : 'http://';

  // Add google maps api. Pass parameters "key" and "language" localization.
  // Parameter "sensor" is deprecated and no more used.
  $key = variable_get('route_planner_api_key', '');
  $language = variable_get('route_planner_api_language', '');
  drupal_add_js($protocol . 'maps.googleapis.com/maps/api/js?key=' . $key . '&language=' . $language, 'external');

  // Add some custom javascript to display the map.
  drupal_add_js(drupal_get_path('module', 'route_planner') . '/route_planner.js');

  // Set variables from Route Planner settings page.
  drupal_add_js(array(
    'routePlanner' => array(
      'zoomlevel' => variable_get('route_planner_map_zoom', 10),
      'zoomcontrol' => variable_get('route_planner_map_zoomcontrol', TRUE),
      'scrollwheel' => variable_get('route_planner_map_scrollwheel', TRUE),
      'mapTypeControl' => variable_get('route_planner_map_maptypecontrol', TRUE),
      'scaleControl' => variable_get('route_planner_map_scalecontrol', TRUE),
      'draggable' => variable_get('route_planner_map_draggable', TRUE),
      'doubbleclick' => variable_get('route_planner_map_doubbleclick', TRUE),
      'streetviewcontrol' => variable_get('route_planner_map_streetviewcontrol', TRUE),
      'overviewmapcontrol' => variable_get('route_planner_map_overviewmapcontrol', TRUE),
      'unitSystem' => variable_get('route_planner_unitsystem', TRUE),
      'end' => variable_get('route_planner_address', 'Hamburg, Germany'),
      'defaultui' => variable_get('route_planner_map_defaultui', TRUE),
      'style' => variable_get('route_planner_map_style', NULL),
      'travelMode' => variable_get('route_planner_map_travelmode', FALSE),
    ),
  ), 'setting');

  // Get the address form.
  $output = drupal_get_form('route_planner_address_form');
  return $output;
}