private function GeofieldMapFieldTrait::setMapGoogleApiKeyElement in Geofield Map 8
Same name and namespace in other branches
- 8.2 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::setMapGoogleApiKeyElement()
Set Map Google Api Key Element.
Parameters
array $elements: The Form element to alter.
1 call to GeofieldMapFieldTrait::setMapGoogleApiKeyElement()
- GeofieldMapFieldTrait::generateGmapSettingsForm in src/
GeofieldMapFieldTrait.php - Generate the Google Map Settings Form.
File
- src/
GeofieldMapFieldTrait.php, line 382
Class
- GeofieldMapFieldTrait
- Class GeofieldMapFieldTrait.
Namespace
Drupal\geofield_mapCode
private function setMapGoogleApiKeyElement(array &$elements) {
$gmap_api_key = $this
->getGmapApiKey();
// 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<br><div class="description">A valid Gmap Api Key is needed anyway for the Widget Geocode and ReverseGeocode functionalities (provided by the Google Map Geocoder)</div>', [
'@gmaps_api_key_link' => $this->link
->generate($gmap_api_key, Url::fromRoute('geofield_map.settings', [], [
'query' => [
'destination' => Url::fromRoute('<current>')
->toString(),
],
])),
]);
}
else {
$map_google_api_key_value = $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(),
],
])),
]);
}
$elements['map_google_api_key'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => $map_google_api_key_value,
];
}