public function GeofieldGoogleMapFormatter::settingsSummary in Geofield Map 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/GeofieldGoogleMapFormatter.php \Drupal\geofield_map\Plugin\Field\FieldFormatter\GeofieldGoogleMapFormatter::settingsSummary()
Returns a short summary for the current formatter settings.
If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.
Return value
string[] A short summary of the formatter settings.
Overrides FormatterBase::settingsSummary
File
- src/
Plugin/ Field/ FieldFormatter/ GeofieldGoogleMapFormatter.php, line 217
Class
- GeofieldGoogleMapFormatter
- Plugin implementation of the 'geofield_google_map' formatter.
Namespace
Drupal\geofield_map\Plugin\Field\FieldFormatterCode
public function settingsSummary() {
$settings = $this
->getSettings();
$gmap_api_key = $this
->getGmapApiKey();
// Define the Google Maps API Key value message string.
if (!empty($gmap_api_key)) {
$state = $this->link
->generate($gmap_api_key, Url::fromRoute('geofield_map.settings', [], [
'query' => [
'destination' => Url::fromRoute('<current>')
->toString(),
],
]));
}
else {
$state = $this
->t("<span class='geofield-map-warning'>Gmap Api Key missing<br>Google Maps functionality may not be available.</span> @settings_page_link", [
'@settings_page_link' => $this->link
->generate($this
->t('Set it in the Geofield Map Configuration Page'), Url::fromRoute('geofield_map.settings', [], [
'query' => [
'destination' => Url::fromRoute('<current>')
->toString(),
],
])),
]);
}
$map_gmap_api_key = [
'#markup' => $this
->t('Google Maps API Key: @state', [
'@state' => $state,
]),
];
$map_dimensions = [
'#markup' => $this
->t('Map Dimensions: Width: @width - Height: @height', [
'@width' => $settings['map_dimensions']['width'],
'@height' => $settings['map_dimensions']['height'],
]),
];
$map_empty = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Behaviour for the Empty Map: @state', [
'@state' => $this->emptyMapOptions[$settings['map_empty']['empty_behaviour']],
]),
];
if ($settings['map_empty']['empty_behaviour'] === '1') {
$map_empty['message'] = [
'#markup' => $this
->t('Empty Field Message: Width: @state', [
'@state' => $settings['map_empty']['empty_message'],
]),
];
}
$map_center = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Map Default Center: @state_lat, @state_lon', [
'@state_lat' => $settings['map_center']['lat'],
'@state_lon' => $settings['map_center']['lon'],
]),
'center_force' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Force Map Center: @state', [
'@state' => $settings['map_center']['center_force'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
];
$map_zoom_and_pan = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => '<u>' . $this
->t('Map Zoom and Pan:') . '</u>',
'zoom' => [
'initial' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Start Zoom: @state', [
'@state' => $settings['map_zoom_and_pan']['zoom']['initial'],
]),
],
'force' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Force Start Zoom: @state', [
'@state' => $settings['map_zoom_and_pan']['zoom']['force'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
'min' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Min Zoom: @state', [
'@state' => $settings['map_zoom_and_pan']['zoom']['min'],
]),
],
'max' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Max Zoom: @state', [
'@state' => $settings['map_zoom_and_pan']['zoom']['max'],
]),
],
],
'scrollwheel' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Scrollwheel: @state', [
'@state' => $settings['map_zoom_and_pan']['scrollwheel'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
'draggable' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Draggable: @state', [
'@state' => $settings['map_zoom_and_pan']['draggable'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
'map_reset' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Map Reset Control: @state', [
'@state' => !empty($settings['map_zoom_and_pan']['map_reset']) ? $this
->t('Yes') : $this
->t('No'),
]),
],
];
// Remove the unselected array keys
// from the map_type_control_options_type_ids.
$map_type_control_options_type_ids = array_filter($settings['map_controls']['map_type_control_options_type_ids'], function ($value) {
return $value !== 0;
});
$map_controls = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => '<u>' . $this
->t('Map Controls:') . '</u>',
'disable_default_ui' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Disable Default UI: @state', [
'@state' => $settings['map_controls']['disable_default_ui'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
'map_type_id' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Default Map Type: @state', [
'@state' => $settings['map_controls']['map_type_id'],
]),
],
];
if (!$settings['map_controls']['disable_default_ui']) {
$map_controls['zoom_control'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Zoom Control: @state', [
'@state' => $settings['map_controls']['zoom_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
];
$map_controls['map_type_control'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Map Type Control: @state', [
'@state' => $settings['map_controls']['map_type_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
];
$map_controls['map_type_control_options_type_ids'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $settings['map_controls']['map_type_control'] ? $this
->t('Enabled Map Types: @state', [
'@state' => implode(', ', array_keys($map_type_control_options_type_ids)),
]) : '',
];
$map_controls['scale_control'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Scale Control: @state', [
'@state' => $settings['map_controls']['scale_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
];
$map_controls['street_view_control'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Streetview Control: @state', [
'@state' => $settings['map_controls']['street_view_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
];
$map_controls['fullscreen_control'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Fullscreen Control: @state', [
'@state' => $settings['map_controls']['fullscreen_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
];
}
$map_marker_and_infowindow = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => '<u>' . $this
->t('Map Marker and Infowindow:') . '</u>',
'icon_image_path' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Marker Icon: @state', [
'@state' => !empty($settings['map_marker_and_infowindow']['icon_image_path']) ? $settings['map_marker_and_infowindow']['icon_image_path'] : $this
->t('Default Google Marker'),
]),
],
'infowindow_field' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Marker Infowindow @state', [
'@state' => !empty($settings['map_marker_and_infowindow']['infowindow_field']) ? 'from: ' . $settings['map_marker_and_infowindow']['infowindow_field'] : $this
->t('disabled'),
]),
],
'force_open' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Open Infowindow on Load: @state', [
'@state' => $settings['map_marker_and_infowindow']['force_open'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
];
if ($settings['map_marker_and_infowindow']['infowindow_field'] == '#rendered_entity') {
$map_marker_and_infowindow['view_mode'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('View Mode: @state', [
'@state' => $settings['map_marker_and_infowindow']['view_mode'],
]),
];
}
if (!empty($settings['map_additional_options'])) {
$map_additional_options = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Map Additional Options:'),
'value' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $settings['map_additional_options'],
],
];
}
$map_oms = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => '<u>' . $this
->t('Overlapping Markers:') . '</u>',
'map_oms_control' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Spiderfy overlapping markers: @state', [
'@state' => $settings['map_oms']['map_oms_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
];
$map_markercluster = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => '<u>' . $this
->t('Marker Clustering:') . '</u>',
'markercluster_control' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Marker Cluster Enabled: @state', [
'@state' => $settings['map_markercluster']['markercluster_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
],
];
if (!empty($settings['map_markercluster']['markercluster_additional_options'])) {
$map_markercluster['markercluster_additional_options'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Marker Cluster Additional Options:'),
'value' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $settings['map_markercluster']['markercluster_additional_options'],
],
];
}
$custom_style_map = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Custom Style Map: @state', [
'@state' => $settings['custom_style_map']['custom_style_control'] ? $this
->t('Yes') : $this
->t('No'),
]),
];
if ($settings['custom_style_map']['custom_style_control']) {
$custom_style_map['custom_style_name'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Custom Style Name: @state', [
'@state' => $settings['custom_style_map']['custom_style_name'],
]),
];
$custom_style_map['custom_style_default'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Custom Map Style as Default: @state', [
'@state' => $settings['custom_style_map']['custom_style_default'] ? $this
->t('Yes') : $this
->t('No'),
]),
];
}
$summary = [
'map_gmap_api_key' => $map_gmap_api_key,
'map_dimensions' => $map_dimensions,
'map_empty' => $map_empty,
'map_center' => $map_center,
'map_zoom_and_pan' => $map_zoom_and_pan,
'map_controls' => $map_controls,
'map_marker_and_infowindow' => $map_marker_and_infowindow,
'map_additional_options' => isset($map_additional_options) ? $map_additional_options : NULL,
'map_oms' => $map_oms,
'map_markercluster' => $map_markercluster,
'custom_style_map' => $custom_style_map,
];
// Attach Geofield Map Library.
$summary['library'] = [
'#attached' => [
'library' => [
'geofield_map/geofield_map_general',
],
],
];
return $summary;
}