You are here

private function IpGeoLocPluginStyleLeaflet::addCheckBoxes in IP Geolocation Views & Maps 8

Form part definition.

1 call to IpGeoLocPluginStyleLeaflet::addCheckBoxes()
IpGeoLocPluginStyleLeaflet::buildOptionsForm in src/Plugin/views/style/IpGeoLocPluginStyleLeaflet.php
Provide a form to edit options for this plugin.

File

src/Plugin/views/style/IpGeoLocPluginStyleLeaflet.php, line 494

Class

IpGeoLocPluginStyleLeaflet
Views Style plugin extension for Leaflet (if enabled).

Namespace

Drupal\ip_geoloc\Plugin\views\style

Code

private function addCheckBoxes(&$form, $lib_markercluster, &$weight) {
  $form['full_screen'] = [
    '#title' => $this
      ->t('Add a full-screen toggle to the map'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['full_screen'],
    '#weight' => $weight++,
  ];

  // @TODO check how to migrate this library

  /*$lib_fullscreen = libraries_get_path('leaflet-fullscreen');

      if ($lib_fullscreen) {
      $file_fullscreen = $lib_fullscreen . '/dist/Leaflet.fullscreen.min.js';
      if (!file_exists($file_fullscreen)) {
      $form['full_screen']['#description'] = $this->t('Error: <em>leaflet-fullscreen</em> library found, but %js_file is missing.', array('%js_file' => $file_fullscreen));
      }
      }
      else {
      $form['full_screen']['#description'] = $this->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-fullscreen</em>.', array(
      '@js_lib' => 'https://github.com/Leaflet/Leaflet.fullscreen'));
      }*/
  $form['scale_imperial'] = [
    '#title' => $this
      ->t('Add an imperial (miles) scale'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['scale_imperial'],
    '#weight' => $weight++,
  ];
  $form['scale_metric'] = [
    '#title' => $this
      ->t('Add a metric (km) scale'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['scale_metric'],
    '#weight' => $weight++,
  ];
  $form['zoom_indicator'] = [
    '#title' => $this
      ->t('Add an indicator showing the active zoom level'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['zoom_indicator'],
    '#weight' => $weight++,
  ];
  $form['map_reset'] = [
    '#title' => $this
      ->t('Add a reset button'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['map_reset'],
    '#description' => $this
      ->t('This button allows the visitor to reset the map to its initial bounds (center and zoom level).'),
    '#weight' => $weight++,
  ];
  $form['map_reset_css_class'] = [
    '#title' => $this
      ->t('CSS class to apply to reset button'),
    '#type' => 'textfield',
    '#size' => 40,
    '#default_value' => $this->options['map_reset_css_class'],
    '#description' => $this
      ->t('You can use this to superimpose a font-icon on the button. For instance, if you have the Font Awesome library loaded for your markers, try <strong>fa fa-repeat</strong>. If you enter only one or two characters, for example <strong>R</strong>, these will be used verbatim as the label instead.'),
    '#weight' => $weight++,
    '#states' => [
      'visible' => [
        'input[name="style_options[map_reset]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['map_cluster_toggle'] = [
    '#title' => $this
      ->t('Add cluster toggle button'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['map_cluster_toggle'],
    '#description' => $this
      ->t('This button allows the visitor to toggle marker clustering on/off at any time and at any zoom level.') . '<br/>' . $this
      ->t('A cluster radius must be specified below.'),
    '#weight' => $weight++,
  ];
  $form['open_balloons_on_click'] = [
    '#title' => $this
      ->t('Display non-excluded fields in a pop-up balloon above the marker, when <em>clicked</em>.'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['open_balloons_on_click'],
    '#weight' => $weight++,
  ];
  $form['open_balloons_on_hover'] = [
    '#title' => $this
      ->t('Display non-excluded fields in a pop-up balloon above the marker, when <em>hovered</em>.'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['open_balloons_on_hover'],
    '#weight' => $weight++,
  ];
  $form['goto_content_on_click'] = [
    '#title' => $this
      ->t('Go to the associated content page, when a marker is <em>clicked</em>.'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['goto_content_on_click'],
    '#weight' => $weight++,
  ];
  if (!$lib_markercluster) {
    $form['map_cluster_toggle']['#description'] .= '<br/>' . $this
      ->t('<a href="!url_project">Leaflet MarkerCluster</a> must be enabled.', [
      '!url_project' => 'http://drupal.org/project/leaflet_markercluster',
    ]);
  }
}