You are here

private function ip_geoloc_plugin_style_leaflet::_add_mini_map_inset in IP Geolocation Views & Maps 7

1 call to ip_geoloc_plugin_style_leaflet::_add_mini_map_inset()
ip_geoloc_plugin_style_leaflet::options_form in views/ip_geoloc_plugin_style_leaflet.inc
Implements options_form().

File

views/ip_geoloc_plugin_style_leaflet.inc, line 627

Class

ip_geoloc_plugin_style_leaflet

Code

private function _add_mini_map_inset(&$form, &$weight) {
  $form['mini_map'] = array(
    '#title' => t('Mini-map inset'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    // !empty($this->options['mini_map']['on']),
    '#description' => t('A zoomed-out version of the main map as a mini-map inset in the bottom corner.'),
    '#weight' => $weight++,
  );
  $form['mini_map']['on'] = array(
    '#title' => t('Enable mini-map inset'),
    '#type' => 'checkbox',
    '#default_value' => !empty($this->options['mini_map']['on']),
  );
  $form['mini_map']['height'] = array(
    '#title' => t('Height of inset'),
    '#type' => 'textfield',
    '#size' => 4,
    '#field_suffix' => t('px'),
    '#default_value' => $this->options['mini_map']['height'],
    '#states' => array(
      'visible' => array(
        'input[name="style_options[mini_map][on]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['mini_map']['width'] = array(
    '#title' => t('Width of inset'),
    '#type' => 'textfield',
    '#size' => 4,
    '#field_suffix' => t('px'),
    '#default_value' => $this->options['mini_map']['width'],
    '#states' => array(
      'visible' => array(
        'input[name="style_options[mini_map][on]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['mini_map']['toggle'] = array(
    '#title' => t('Allow visitor to minimise inset'),
    '#type' => 'checkbox',
    '#default_value' => !empty($this->options['mini_map']['toggle']),
    '#states' => array(
      'visible' => array(
        'input[name="style_options[mini_map][on]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['mini_map']['scope_color'] = array(
    '#title' => t('Scope rectangle color'),
    '#type' => 'textfield',
    '#size' => 10,
    '#default_value' => $this->options['mini_map']['scope_color'],
    '#description' => t('<em>#rrggbb</em> or <a target="_colors" href="@url">color name</a>.', array(
      '@url' => url('http://www.w3schools.com/html/html_colornames.asp'),
    )),
    '#states' => array(
      'visible' => array(
        'input[name="style_options[mini_map][on]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['mini_map']['zoom_delta'] = array(
    '#title' => t('Zoom delta'),
    '#type' => 'textfield',
    '#size' => 3,
    '#default_value' => $this->options['mini_map']['zoom_delta'],
    '#description' => t('The difference between the zoom levels of main map and mini-map.'),
    '#states' => array(
      'visible' => array(
        'input[name="style_options[mini_map][on]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $lib_minimap = libraries_get_path('leaflet-minimap');
  if ($lib_minimap) {
    $file_minimap = $lib_minimap . '/dist/Control.MiniMap.min.js';
    if (!file_exists($file_minimap)) {
      $form['mini_map']['#description'] .= '<br/>' . t('Error: <em>leaflet-minimap</em> library found, but %js_file is missing.', array(
        '%js_file' => $file_minimap,
      ));
    }
  }
  else {
    $form['mini_map']['#description'] .= '<br/>' . t('Requires this <a target="_js" href="@js_lib">JS library</a> to be downloaded to <em>/sites/all/libraries</em>. Change the directory name to <em>leaflet-minimap</em>.', array(
      '@js_lib' => 'https://github.com/Norkart/Leaflet-Minimap',
    ));
  }
}