From 499a1038ff55744cdb0fb7b4fb1bb22f277404ee Mon Sep 17 00:00:00 2001 From: Daniel Kipp Date: Thu, 28 May 2026 13:19:35 +0200 Subject: [PATCH] [FIX]: Ensure Google Maps API Key is added to the template (Mantis #46761) ->addJavaScript had truncated the API Key. So now it is included directly in the template, which makes Google Maps usable again. --- .../ILIAS/Maps/classes/class.ilGoogleMapGUI.php | 12 +++++++++++- .../ILIAS/Maps/templates/default/tpl.google_map.html | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php b/components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php index 86c12a8708c4..176ffc1c0c22 100755 --- a/components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php +++ b/components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php @@ -25,6 +25,7 @@ */ class ilGoogleMapGUI extends ilMapGUI { + protected static bool $google_maps_api_added = false; protected string $css_row = ""; public function __construct() @@ -48,7 +49,16 @@ public function getHtml(): string "components/ILIAS/Maps" ); - $this->tpl->addJavaScript("//maps.google.com/maps/api/js?key=" . ilMapUtil::getApiKey(), false); + $api_key = trim(ilMapUtil::getApiKey()); + if ($api_key !== "" && !self::$google_maps_api_added) { + $html_tpl->setCurrentBlock("google_maps_api"); + $html_tpl->setVariable( + "GOOGLE_MAPS_API_SRC", + "https://maps.googleapis.com/maps/api/js?key=" . rawurlencode($api_key) + ); + $html_tpl->parseCurrentBlock(); + self::$google_maps_api_added = true; + } // add user markers $cnt = 0; diff --git a/components/ILIAS/Maps/templates/default/tpl.google_map.html b/components/ILIAS/Maps/templates/default/tpl.google_map.html index c1ab556d49e6..a49dc7d69ded 100755 --- a/components/ILIAS/Maps/templates/default/tpl.google_map.html +++ b/components/ILIAS/Maps/templates/default/tpl.google_map.html @@ -1 +1,4 @@ + + +