You are here

route_planner.module in Route Planner 8

Same filename and directory in other branches
  1. 6 route_planner.module
  2. 7 route_planner.module

The Route Planner module create blocks to show a route from any address to a fixed point.

File

route_planner.module
View source
<?php

/**
 * @file
 * The Route Planner module create blocks to show a route from any address
 * to a fixed point.
 */

/**
 * Implements hook_library_info_build().
 */
function route_planner_library_info_build() {
  $config = \Drupal::config('route_planner.settings');
  $api_key = $config
    ->get('route_planner_api_key');
  $language = $config
    ->get('route_planner_api_language');
  $libraries = [];
  $libraries['googleapis'] = [
    'version' => '1.x',
    'js' => [
      'https://maps.googleapis.com/maps/api/js?key=' . $api_key . '&language=' . $language => [
        'type' => 'external',
        'minified' => true,
      ],
    ],
  ];
  return $libraries;
}

/**
 * Implements hook_block_configure().
 */
function route_planner_block_configure($delta = '') {
  module_load_include('inc', 'route_planner', 'route_planner.admin');
  switch ($delta) {
    case 'route_target':
    case 'map':
      return route_planner_settings_form();
      break;
  }
}

/**
 * Implements hook_block_save().
 */
function route_planner_block_save($delta = '', $edit = array()) {
  switch ($delta) {
    case 'route_target':
    case 'map':
      \Drupal::config('route_planner.settings')
        ->set('route_planner_address', $edit['route_planner_address']);
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_height', $edit['route_planner_map_height']);
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_width', $edit['route_planner_map_width']);
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_zoom', intval($edit['route_planner_map_zoom']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_zoomcontrol', intval($edit['route_planner_map_zoomcontrol']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_scrollwheel', intval($edit['route_planner_map_scrollwheel']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_maptypecontrol', intval($edit['route_planner_map_maptypecontrol']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_scalecontrol', intval($edit['route_planner_map_scalecontrol']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_draggable', intval($edit['route_planner_map_draggable']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_doubbleclick', intval($edit['route_planner_map_doubbleclick']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_streetviewcontrol', intval($edit['route_planner_map_streetviewcontrol']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_overviewmapcontrol', intval($edit['route_planner_map_overviewmapcontrol']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_unitsystem', intval($edit['route_planner_unitsystem']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_map_defaultui', intval($edit['route_planner_map_defaultui']));
      \Drupal::config('route_planner.settings')
        ->set('route_planner_api_key', $edit['route_planner_api_key']);
      \Drupal::config('route_planner.settings')
        ->set('route_planner_api_language', $edit['route_planner_api_language']);
      break;
  }
}

Functions

Namesort descending Description
route_planner_block_configure Implements hook_block_configure().
route_planner_block_save Implements hook_block_save().
route_planner_library_info_build Implements hook_library_info_build().