You are here

public function LeafletMarkerClusterer::getSettingsForm in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletMarkerClusterer.php \Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature\LeafletMarkerClusterer::getSettingsForm()

Provide a generic map settings form array.

Parameters

array $settings: The current map settings.

array $parents: Form specific optional prefix.

Return value

array A form array to be integrated in whatever.

Overrides MapFeatureBase::getSettingsForm

File

modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletMarkerClusterer.php, line 40

Class

LeafletMarkerClusterer
Provides marker clusterer.

Namespace

Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature

Code

public function getSettingsForm(array $settings, array $parents) {
  $options = [
    'show_coverage_on_hover' => $this
      ->t('Hovering over a cluster shows the bounds of its markers.'),
    'zoom_to_bounds_on_click' => $this
      ->t('Clicking a cluster zooms to the bounds.'),
  ];
  $form['cluster_settings'] = [
    '#type' => 'checkboxes',
    '#options' => $options,
    '#title' => $this
      ->t('Marker Cluster default settings'),
    '#default_value' => array_keys(array_filter($settings['cluster_settings'])),
  ];
  $form['disable_clustering_at_zoom'] = [
    '#type' => 'number',
    '#min' => 0,
    '#max' => 20,
    '#step' => 1,
    '#size' => 2,
    '#title' => $this
      ->t('Disable clustering at zoom'),
    '#description' => $this
      ->t('If set, at this zoom level and below, markers will not be clustered.'),
    '#default_value' => $settings['disable_clustering_at_zoom'],
  ];
  $form['custom_marker_settings'] = [
    '#type' => 'textarea',
    '#description' => $this
      ->t('Custom marker settings in JSON format like: {"small": {"radius": 40, "limit": 10}, "medium": {"radius": 60, "limit": 50}}.'),
    '#default_value' => $settings['custom_marker_settings'],
  ];
  return $form;
}