Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
class ilGoogleMapGUI extends ilMapGUI
{
protected static bool $google_maps_api_added = false;
protected string $css_row = "";

public function __construct()
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions components/ILIAS/Maps/templates/default/tpl.google_map.html
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<!-- BEGIN google_maps_api -->
<script src="{GOOGLE_MAPS_API_SRC}"></script>
<!-- END google_maps_api -->
<div id="{MAP_ID}" class="ilGoogleMap" style="width: 100%; max-width: {WIDTH}; height: {HEIGHT};"></div>
Loading