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 @@ + + +