protected function GeofieldMapFieldTrait::preProcessMapSettings in Geofield Map 8
Same name and namespace in other branches
- 8.2 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::preProcessMapSettings()
Pre Process the MapSettings.
Performs some preprocess on the maps settings before sending to js.
Parameters
array $map_settings: The map settings.
2 calls to GeofieldMapFieldTrait::preProcessMapSettings()
- GeofieldGoogleMapFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ GeofieldGoogleMapFormatter.php - Builds a renderable array for a field value.
- GeofieldGoogleMapViewStyle::render in src/
Plugin/ views/ style/ GeofieldGoogleMapViewStyle.php - Renders the View.
File
- src/
GeofieldMapFieldTrait.php, line 316
Class
- GeofieldMapFieldTrait
- Class GeofieldMapFieldTrait.
Namespace
Drupal\geofield_mapCode
protected function preProcessMapSettings(array &$map_settings) {
// Set the gmap_api_key as map settings.
$map_settings['gmap_api_key'] = $this
->getGmapApiKey();
// Transform into simple array values the map_type_control_options_type_ids.
$map_settings['map_controls']['map_type_control_options_type_ids'] = array_keys(array_filter($map_settings['map_controls']['map_type_control_options_type_ids'], function ($value) {
return $value !== 0;
}));
// Generate Absolute icon_image_path, if it is not.
$icon_image_path = $map_settings['map_marker_and_infowindow']['icon_image_path'];
if (!empty($icon_image_path) && !UrlHelper::isExternal($map_settings['map_marker_and_infowindow']['icon_image_path'])) {
$map_settings['map_marker_and_infowindow']['icon_image_path'] = Url::fromUri('base:' . $icon_image_path, [
'absolute' => TRUE,
])
->toString();
}
}