You are here

protected function IpGeoLocPluginStyleLeaflet::defineOptions in IP Geolocation Views & Maps 8

Set default Leaflet options.

Overrides StylePluginBase::defineOptions

File

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

Class

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

Namespace

Drupal\ip_geoloc\Plugin\views\style

Code

protected function defineOptions() {
  $options = parent::defineOptions();

  // The leaflet.module default.
  $options['map'] = [
    'default' => 'OSM Mapnik',
  ];
  $options['map_height'] = [
    'default' => 300,
  ];
  $latitude = $this->moduleHandler
    ->moduleExists('location') ? 'location_latitude' : 'ip_geoloc_latitude';
  $longitude = $this->moduleHandler
    ->moduleExists('location') ? 'location_longitude' : ($latitude == 'ip_geoloc_latitude' ? 'ip_geoloc_longitude' : $latitude);
  $options['ip_geoloc_views_plugin_latitude'] = [
    'default' => $latitude,
  ];
  $options['ip_geoloc_views_plugin_longitude'] = [
    'default' => $longitude,
  ];
  $options['default_marker'] = [
    'contains' => [
      'default_marker_color' => [
        'default' => '',
      ],
      'default_marker_special_char' => [
        'default' => '',
      ],
      'default_marker_special_char_class' => [
        'default' => '',
      ],
    ],
  ];
  $options['visitor_marker_leaflet'] = [
    'contains' => [
      'visitor_marker_color' => [
        'default' => '',
      ],
      'visitor_marker_special_char' => [
        'default' => '',
      ],
      'visitor_marker_special_char_class' => [
        'default' => '',
      ],
      'visitor_marker_accuracy_circle' => [
        'default' => FALSE,
      ],
    ],
  ];
  $options['differentiator'] = [
    'contains' => [
      'differentiator_field' => [
        'default' => '',
      ],
    ],
  ];
  $options['center_option'] = [
    'default' => 0,
  ];
  $options['tags'] = [
    'contains' => [
      'marker_tag' => [
        'default' => '',
      ],
      'tag_css_class' => [
        'default' => 'tag-inside-marker',
      ],
    ],
  ];
  $options['tooltips'] = [
    'contains' => [
      'marker_tooltip' => [
        'default' => '',
      ],
    ],
  ];
  $options['sync'] = [
    'contains' => [
      LEAFLET_SYNC_CONTENT_TO_MARKER => [
        'default' => FALSE,
      ],
      LEAFLET_SYNC_MARKER_TO_CONTENT => [
        'default' => FALSE,
      ],
      LEAFLET_SYNC_MARKER_TO_CONTENT_WITH_POPUP => [
        'default' => TRUE,
      ],
      LEAFLET_SYNC_REVERT_LAST_MARKER_ON_MAP_OUT => [
        'default' => TRUE,
      ],
    ],
  ];
  $options['full_screen'] = [
    'default' => FALSE,
  ];
  $options['scale_metric'] = [
    'default' => FALSE,
  ];
  $options['scale_imperial'] = [
    'default' => FALSE,
  ];
  $options['zoom_indicator'] = [
    'default' => FALSE,
  ];
  $options['open_balloons_on_click'] = [
    'default' => TRUE,
  ];
  $options['open_balloons_on_hover'] = [
    'default' => FALSE,
  ];
  $options['goto_content_on_click'] = [
    'default' => FALSE,
  ];
  $options['map_reset'] = [
    'default' => FALSE,
  ];
  $options['map_reset_css_class'] = [
    'default' => 'R',
  ];
  $options['map_cluster_toggle'] = [
    'default' => FALSE,
  ];
  $options['mini_map'] = [
    'contains' => [
      'on' => [
        'default' => FALSE,
      ],
      'height' => [
        'default' => 100,
      ],
      'width' => [
        'default' => 150,
      ],
      'toggle' => [
        'default' => TRUE,
      ],
      'scope_color' => [
        'default' => 'red',
      ],
      'zoom_delta' => [
        'default' => -5,
      ],
    ],
  ];
  $options['cluster_radius'] = [
    'default' => $this->moduleHandler
      ->moduleExists('leaflet_markercluster') ? 80 : '',
  ];
  $options['disable_clustering_at_zoom'] = [
    'default' => '',
  ];
  $options['cluster_differentiator'] = [
    'contains' => [
      'cluster_differentiator_fields' => [
        'default' => '',
      ],
      'zoom_ranges' => [
        'default' => [],
      ],
      'cluster_tooltips' => [
        'default' => TRUE,
      ],
      'cluster_outline' => [
        'default' => 0,
      ],
      'cluster_touch_mode' => [
        'default' => 1,
      ],
    ],
  ];
  $options['cluster_aggregation'] = [
    'contains' => [
      'aggregation_field' => [
        'default' => '',
      ],
      'aggregation_function' => [
        'default' => '',
      ],
      'ranges' => [
        'contains' => [],
      ],
      'precision' => [
        'default' => '',
      ],
    ],
  ];
  $range = 10;
  foreach ([
    'small',
    'medium',
    'large',
  ] as $size) {
    $options['cluster_aggregation']['contains']['ranges']['contains'][$size] = [
      'default' => $range,
    ];
    $range *= 10;
  }
  $options['disable_clustering_at_zoom'] = [
    'default' => '',
  ];
  $options['empty_map_center'] = [
    'default' => '',
  ];
  $options['map_options_leaflet'] = [
    'contains' => [
      'maxzoom' => [
        'default' => 18,
      ],
      'zoom' => [
        'default' => 2,
      ],
      'zoom_on_click' => [
        'default' => '',
      ],
      'center_lat' => [
        'default' => '',
      ],
      'center_lon' => [
        'default' => '',
      ],
      'scrollwheelzoom' => [
        'default' => TRUE,
      ],
      'dragging' => [
        'default' => TRUE,
      ],
      'separator' => [
        'default' => '<br/>',
      ],
    ],
  ];
  return $options;
}