Skip to content
Snippets Groups Projects
Commit 1ab68302 authored by Italo Mairo's avatar Italo Mairo
Browse files

Support and compatibility added for new GeofieldBackend in Geofield 8.x-1.31

Minor Leaflet settings fixes.
parent c9c72333
No related branches found
Tags 1.14.0 8.x-1.14
Loading
......@@ -48,6 +48,6 @@
}
},
"require": {
"drupal/geofield": "^1.0"
"drupal/geofield": "^1.31"
}
}
......@@ -772,7 +772,7 @@ trait LeafletSettingsElementsTrait {
'attributes' => ['target' => 'blank'],
])),
]),
'#default_value' => isset($settings['leaflet_markercluster']['control']) ? $settings['leaflet_markercluster']['control'] : $default_settings['leaflet_markercluster']['control'],
'#default_value' => $settings['leaflet_markercluster']['control'] ?? $default_settings['leaflet_markercluster']['control'],
'#description' => $this->t("@leaflet_markercluster_submodule_warning", [
'@leaflet_markercluster_submodule_warning' => $leaflet_markercluster_submodule_warning,
]),
......@@ -797,7 +797,7 @@ trait LeafletSettingsElementsTrait {
'#rows' => 4,
'#title' => $this->t('Marker Cluster Additional Options'),
'#description' => $this->t('An object literal of additional marker cluster options, that comply with the Leaflet Markercluster Js Library.<br>The syntax should respect the javascript object notation (json) format.<br>As suggested in the field placeholder, always use double quotes (") both for the indexes and the string values.'),
'#default_value' => isset($settings['leaflet_markercluster']['options']) ? $settings['leaflet_markercluster']['options'] : $default_settings['leaflet_markercluster']['options'],
'#default_value' => $settings['leaflet_markercluster']['options'] ?? $default_settings['leaflet_markercluster']['options'],
'#placeholder' => $default_settings['leaflet_markercluster']['options'],
'#element_validate' => [[get_class($this), 'jsonValidate']],
'#states' => $leaflet_markercluster_visibility,
......@@ -805,7 +805,7 @@ trait LeafletSettingsElementsTrait {
$element['leaflet_markercluster']['include_path'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable Markeclustering of Paths elements'),
'#default_value' => $settings['leaflet_markercluster']['include_path'],
'#default_value' => $settings['leaflet_markercluster']['include_path'] ?? $default_settings['leaflet_markercluster']['include_path'],
'#description' => $this->t("Check this options to extend Markerclustering to the Leaflet Map features extending the @path_class_link (Polygon, Polyline, Circle).", [
'@path_class_link' => $this->link->generate($this->t('Leaflet Path class'), Url::fromUri('https://leafletjs.com/reference-1.7.1.html#path', [
'absolute' => TRUE,
......
......@@ -2,6 +2,7 @@
namespace Drupal\leaflet\Plugin\Field\FieldWidget;
use Drupal\geofield\Plugin\GeofieldBackendManager;
use Drupal\leaflet\LeafletSettingsElementsTrait;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
......@@ -87,6 +88,8 @@ class LeafletDefaultWidget extends GeofieldDefaultWidget {
* The geoPhpWrapper.
* @param \Drupal\geofield\WktGeneratorInterface $wkt_generator
* The WKT format Generator service.
* @param \Drupal\geofield\Plugin\GeofieldBackendManager $geofield_backend_manager
* The geofieldBackendManager.
* @param \Drupal\leaflet\LeafletService $leaflet_service
* The Leaflet service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
......@@ -104,6 +107,7 @@ class LeafletDefaultWidget extends GeofieldDefaultWidget {
array $third_party_settings,
GeoPHPInterface $geophp_wrapper,
WktGeneratorInterface $wkt_generator,
GeofieldBackendManager $geofield_backend_manager,
LeafletService $leaflet_service,
ModuleHandlerInterface $module_handler,
LinkGeneratorInterface $link_generator,
......@@ -116,7 +120,8 @@ class LeafletDefaultWidget extends GeofieldDefaultWidget {
$settings,
$third_party_settings,
$geophp_wrapper,
$wkt_generator
$wkt_generator,
$geofield_backend_manager
);
$this->leafletService = $leaflet_service;
$this->moduleHandler = $module_handler;
......@@ -136,6 +141,7 @@ class LeafletDefaultWidget extends GeofieldDefaultWidget {
$configuration['third_party_settings'],
$container->get('geofield.geophp'),
$container->get('geofield.wkt_generator'),
$container->get('plugin.manager.geofield_backend'),
$container->get('leaflet.service'),
$container->get('module_handler'),
$container->get('link_generator'),
......@@ -311,13 +317,6 @@ class LeafletDefaultWidget extends GeofieldDefaultWidget {
'#disabled' => TRUE,
];
// $form['toolbar']['drawCircleMarker'] = [
// '#type' => 'checkbox',
// '#title' => $this->t('Adds button to draw circle marker. (unsupported by GeoJSON'),
// '#default_value' => $toolbar_settings['drawCircleMarker'] ?? $default_settings['toolbar']['drawCircleMarker'],
// '#disabled' => TRUE,
// ];
$form['toolbar']['editMode'] = [
'#type' => 'checkbox',
'#title' => $this->t('Adds button to toggle edit mode for all layers.'),
......@@ -373,8 +372,6 @@ class LeafletDefaultWidget extends GeofieldDefaultWidget {
// Determine map settings and add map element.
$map_settings = $this->getSetting('map');
$default_settings = self::defaultSettings();
$input_settings = $this->getSetting('input');
$js_settings = [];
$map = leaflet_map_get_info($map_settings['leaflet_map'] ?? $default_settings['map']['leaflet_map']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment