public function GeofieldMapWidget::settingsSummary in Geofield Map 8.2
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldWidget/GeofieldMapWidget.php \Drupal\geofield_map\Plugin\Field\FieldWidget\GeofieldMapWidget::settingsSummary()
Returns a short summary for the current widget settings.
If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.
Return value
array A short summary of the widget settings.
Overrides GeofieldLatLonWidget::settingsSummary
File
- src/
Plugin/ Field/ FieldWidget/ GeofieldMapWidget.php, line 602
Class
- GeofieldMapWidget
- Plugin implementation of the 'geofield_map' widget.
Namespace
Drupal\geofield_map\Plugin\Field\FieldWidgetCode
public function settingsSummary() {
$gmap_api_key = $this
->getGmapApiKey();
$map_library = [
'#markup' => $this
->t('Map Library: @state', [
'@state' => 'gmap' == $this
->getSetting('map_library') ? 'Google Maps' : 'Leaflet Js',
]),
];
$map_type = [
'#markup' => $this
->t('Map Type: @state', [
'@state' => 'leaflet' == $this
->getSetting('map_library') ? $this
->getSetting('map_type_leaflet') : $this
->getSetting('map_type_google'),
]),
];
$map_google_places = [
'#markup' => ' - ' . $this
->t('Google Places Autocomplete Service: @state', [
'@state' => $this
->getSetting('map_google_places')['places_control'] && !empty($gmap_api_key) ? $this
->t('enabled') : $this
->t('disabled'),
]),
];
$map_type_selector = [
'#markup' => $this
->t('Map Type Selector: @state', [
'@state' => $this
->getSetting('map_type_selector') ? $this
->t('enabled') : $this
->t('disabled'),
]),
];
$map_dimensions = [
'#markup' => $this
->t('Map Dimensions -'),
];
$map_dimensions['#markup'] .= ' ' . $this
->t('Width: @state;', [
'@state' => $this
->getSetting('map_dimensions')['width'],
]);
$map_dimensions['#markup'] .= ' ' . $this
->t('Height: @state;', [
'@state' => $this
->getSetting('map_dimensions')['height'],
]);
$map_zoom_levels = [
'#markup' => $this
->t('Zoom Levels -'),
];
$map_zoom_levels['#markup'] .= ' ' . $this
->t('Start: @state;', [
'@state' => $this
->getSetting('zoom')['start'],
]);
$map_zoom_levels['#markup'] .= ' ' . $this
->t('Focus: @state;', [
'@state' => $this
->getSetting('zoom')['focus'],
]);
$map_zoom_levels['#markup'] .= ' ' . $this
->t('Min: @state;', [
'@state' => $this
->getSetting('zoom')['min'],
]);
$map_zoom_levels['#markup'] .= ' ' . $this
->t('Max: @state;', [
'@state' => $this
->getSetting('zoom')['max'],
]);
$html5 = [
'#markup' => $this
->t('HTML5 Geolocation button: @state', [
'@state' => $this
->getSetting('html5_geolocation') ? $this
->t('enabled') : $this
->t('disabled'),
]),
];
$map_center = [
'#markup' => $this
->t('Click to find marker: @state', [
'@state' => $this
->getSetting('click_to_find_marker') ? $this
->t('enabled') : $this
->t('disabled'),
]),
];
$marker_center = [
'#markup' => $this
->t('Click to place marker: @state', [
'@state' => $this
->getSetting('click_to_place_marker') ? $this
->t('enabled') : $this
->t('disabled'),
]),
];
$hide_coordinates = [
'#markup' => $this
->t('Lat/Lon coordinates hidden: @state', [
'@state' => $this
->getSetting('hide_coordinates') ? $this
->t('enabled') : $this
->t('disabled'),
]),
];
$geoaddress_field_field = [
'#markup' => $this
->t('Geoaddress Field: @state', [
'@state' => '0' != $this
->getSetting('geoaddress_field')['field'] ? $this
->getSetting('geoaddress_field')['field'] : $this
->t('- any -'),
]),
];
$geoaddress_field_hidden = [
'#markup' => '0' != $this
->getSetting('geoaddress_field')['field'] ? $this
->t('Geoaddress Field Hidden: @state', [
'@state' => $this
->getSetting('geoaddress_field')['hidden'],
]) : '',
];
$geoaddress_field_disabled = [
'#markup' => '0' != $this
->getSetting('geoaddress_field')['field'] ? $this
->t('Geoaddress Field Disabled: @state', [
'@state' => $this
->getSetting('geoaddress_field')['disabled'],
]) : '',
];
$gmap_geocoder_enabled = $this->moduleHandler
->moduleExists('geocoder') && $this
->getSetting('map_geocoder')['control'];
$summary = [
'map_google_api_key' => $this
->setMapGoogleApiKeyElement(),
'map_geocoder' => [
'#type' => 'container',
'title' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $this
->t('Search Address Functionalities based on:'),
],
'type' => $gmap_geocoder_enabled ? [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => ' - ' . $this
->t('Geocoder Module Providers'),
] : [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => ' - ' . $this
->t('Geofield Map GMaps API Key Geocoder') . (empty($gmap_api_key) ? ' ' . $this
->t("<span class='geofield-map-warning'> Not available</span>") : ''),
],
'map_google_places' => !$this
->getSetting('map_geocoder')['control'] ? $map_google_places : [
'#markup' => '',
],
],
'map_library' => $map_library,
'map_type' => $map_type,
'map_type_selector' => $map_type_selector,
'map_dimensions' => $map_dimensions,
'map_zoom_levels' => $map_zoom_levels,
'html5' => $html5,
'map_center' => $map_center,
'marker_center' => $marker_center,
'hide_coordinates' => $hide_coordinates,
'field' => $geoaddress_field_field,
'hidden' => $geoaddress_field_hidden,
'disabled' => $geoaddress_field_disabled,
];
// Attach Geofield Map Library.
$summary['library'] = [
'#attached' => [
'library' => [
'geofield_map/geofield_map_general',
],
],
];
return $summary;
}