private function GeofieldMapFieldTrait::setMapGoogleApiKeyElement in Geofield Map 8.2
Same name and namespace in other branches
- 8 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::setMapGoogleApiKeyElement()
Set Map Google Api Key Element.
8 calls to GeofieldMapFieldTrait::setMapGoogleApiKeyElement()
- GeofieldGoogleEmbedMapFormatter::settingsForm in modules/
geofield_map_extras/ src/ Plugin/ Field/ FieldFormatter/ GeofieldGoogleEmbedMapFormatter.php - Returns a form to configure settings for the formatter.
- GeofieldGoogleEmbedMapFormatter::settingsSummary in modules/
geofield_map_extras/ src/ Plugin/ Field/ FieldFormatter/ GeofieldGoogleEmbedMapFormatter.php - Returns a short summary for the current formatter settings.
- GeofieldGoogleMapFormatter::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ GeofieldGoogleMapFormatter.php - Returns a short summary for the current formatter settings.
- GeofieldGoogleStaticMapFormatter::settingsForm in modules/
geofield_map_extras/ src/ Plugin/ Field/ FieldFormatter/ GeofieldGoogleStaticMapFormatter.php - Returns a form to configure settings for the formatter.
- GeofieldGoogleStaticMapFormatter::settingsSummary in modules/
geofield_map_extras/ src/ Plugin/ Field/ FieldFormatter/ GeofieldGoogleStaticMapFormatter.php - Returns a short summary for the current formatter settings.
File
- src/
GeofieldMapFieldTrait.php, line 373
Class
- GeofieldMapFieldTrait
- Class GeofieldMapFieldTrait.
Namespace
Drupal\geofield_mapCode
private function setMapGoogleApiKeyElement() {
$gmap_api_key = $this
->getGmapApiKey();
$query = [];
if (isset($this->fieldDefinition)) {
$query['destination'] = Url::fromRoute('<current>')
->toString();
}
$this_class = get_class($this);
// Define the Google Maps API Key value message markup.
if (!empty($gmap_api_key)) {
$map_google_api_key_value = $this
->t("<strong>Gmap Api Key:</strong> @gmaps_api_key_link", [
'@gmaps_api_key_link' => $this->link
->generate($gmap_api_key, Url::fromRoute('geofield_map.settings', [], [
'query' => $query,
])),
]);
switch ($this_class) {
case 'Drupal\\geofield_map\\Plugin\\Field\\FieldWidget\\GeofieldMapWidget':
// Set the 'map_google_places' accordingly the
// search_address_geocoder_module title.
$search_address_geocoder_option_title = $this
->getMapGeocoderTitle();
$gmap_api_key_description = $this
->t("<div class='description'>A valid Gmap Api Key is needed for the Widget Google Maps Library and the Geocode & ReverseGeocode functionalities<br>(provided by the Google Maps Geocoder, if the \"@search_address_geocoder_option_title\" option is not selected).</div>", [
'@search_address_geocoder_option_title' => $search_address_geocoder_option_title,
]);
break;
case 'Drupal\\geofield_map\\Plugin\\Field\\FieldFormatter\\GeofieldGoogleMapFormatter':
case 'Drupal\\geofield_map\\Plugin\\views\\style\\GeofieldGoogleMapViewStyle':
case 'Drupal\\geofield_map_extras\\Plugin\\Field\\FieldFormatter\\GeofieldGoogleEmbedMapFormatter':
case 'Drupal\\geofield_map_extras\\Plugin\\Field\\FieldFormatter\\GeofieldGoogleStaticMapFormatter':
$gmap_api_key_description = $this
->t("<div class='description'>A valid Gmap Api Key is needed for Google Maps rendering.</div>");
break;
default:
$gmap_api_key_description = "";
}
}
else {
$map_google_api_key_value = $this
->t("<span class='geofield-map-warning'>Gmap Api Key missing - @settings_page_link.</span>", [
'@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(),
],
])),
]);
switch ($this_class) {
case 'Drupal\\geofield_map\\Plugin\\Field\\FieldWidget\\GeofieldMapWidget':
$gmap_api_key_description = $this
->t("<div class='description'>Google Maps rendering and Geocode & ReverseGeocode functionalities (provided by the Google Maps Geocoder) not available.</div>");
break;
case 'Drupal\\geofield_map\\Plugin\\Field\\FieldFormatter\\GeofieldGoogleMapFormatter':
case 'Drupal\\geofield_map\\Plugin\\views\\style\\GeofieldGoogleMapViewStyle':
case 'Drupal\\geofield_map_extras\\Plugin\\Field\\FieldFormatter\\GeofieldGoogleEmbedMapFormatter':
case 'Drupal\\geofield_map_extras\\Plugin\\Field\\FieldFormatter\\GeofieldGoogleStaticMapFormatter':
$gmap_api_key_description = $this
->t("<div class='geofield-map-warning'>Google Maps rendering not available.</div>");
break;
default:
$gmap_api_key_description = "";
}
}
return [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $map_google_api_key_value,
'description' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $gmap_api_key_description,
],
];
}