Always default #map_settings to an empty array.

This commit is contained in:
Michael Stenta 2022-06-17 07:13:05 -04:00
parent ba6000ebc6
commit 70e8b1f9ea
2 changed files with 3 additions and 4 deletions

View File

@ -24,6 +24,7 @@ class FarmMap extends RenderElement {
],
'#theme' => 'farm_map',
'#map_type' => 'default',
'#map_settings' => [],
];
}
@ -66,14 +67,11 @@ class FarmMap extends RenderElement {
$element['#attached']['library'][] = 'farm_map/farmOS-map';
$element['#attached']['library'][] = 'farm_map/farm_map';
// Include map settings.
$map_settings = !empty($element['#map_settings']) ? $element['#map_settings'] : [];
// Include the map options.
$map_options = $map->getMapOptions();
// Add the instance settings under the map id key.
$instance_settings = array_merge_recursive($map_settings, $map_options);
$instance_settings = array_merge_recursive($element['#map_settings'], $map_options);
$element['#attached']['drupalSettings']['farm_map'][$map_id] = $instance_settings;
// Create and dispatch a MapRenderEvent.

View File

@ -35,6 +35,7 @@ class FarmMapInput extends FormElement {
// Display descriptions above the map by default.
'#description_display' => 'before',
'#map_type' => 'geofield_widget',
'#map_settings' => [],
'#default_value' => '',
'#display_raw_geometry' => TRUE,
];