public function GoogleMapsDisplayTrait::getGoogleMapsSettings in Geolocation Field 8
Provide settings ready to handover to JS to feed to Google Maps.
Parameters
array $settings: Current settings. Might contain unrelated settings as well.
Return value
array An array only containing keys defined in this trait.
3 calls to GoogleMapsDisplayTrait::getGoogleMapsSettings()
- CommonMap::render in src/
Plugin/ views/ style/ CommonMap.php - Render the display in this style.
- GeolocationGooglegeocoderWidget::formElement in src/
Plugin/ Field/ FieldWidget/ GeolocationGooglegeocoderWidget.php - Returns the form for a single field widget.
- GeolocationGoogleMapFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ GeolocationGoogleMapFormatter.php - Builds a renderable array for a field value.
File
- src/
GoogleMapsDisplayTrait.php, line 173
Class
- GoogleMapsDisplayTrait
- Class GoogleMapsDisplayTrait.
Namespace
Drupal\geolocationCode
public function getGoogleMapsSettings(array $settings) {
$default_settings = self::getGoogleMapDefaultSettings();
$settings = array_replace_recursive($default_settings, $settings);
if (!empty($settings['google_map_settings']['marker_icon_path'])) {
$settings['google_map_settings']['marker_icon_path'] = file_url_transform_relative(file_create_url(\Drupal::token()
->replace($settings['google_map_settings']['marker_icon_path'])));
}
foreach ($settings['google_map_settings'] as $key => $setting) {
if (!isset($default_settings['google_map_settings'][$key])) {
unset($settings['google_map_settings'][$key]);
}
}
// Convert JSON string to actual array before handing to Renderer.
if (!empty($settings['google_map_settings']['style'])) {
$json = json_decode($settings['google_map_settings']['style']);
if (is_array($json)) {
$settings['google_map_settings']['style'] = $json;
}
}
return [
'google_map_settings' => $settings['google_map_settings'],
];
}