diff --git a/components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php b/components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php
deleted file mode 100755
index 3cb833948145..000000000000
--- a/components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php
+++ /dev/null
@@ -1,192 +0,0 @@
-
- */
-class ilGoogleMapGUI extends ilMapGUI
-{
- protected static bool $google_maps_api_added = false;
- protected string $css_row = "";
-
- public function __construct()
- {
- parent::__construct();
- }
-
- public function getHtml(): string
- {
- $html_tpl = new ilTemplate(
- "tpl.google_map.html",
- true,
- true,
- "components/ILIAS/Maps"
- );
-
- $js_tpl = new ilTemplate(
- "tpl.google_map.js",
- true,
- true,
- "components/ILIAS/Maps"
- );
-
- $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;
- foreach ($this->user_marker as $user_id) {
- if (ilObject::_exists($user_id)) {
- $user = new ilObjUser($user_id);
- if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
- $user->getPref("public_location") == "y") {
- $js_tpl->setCurrentBlock("user_marker");
- $js_tpl->setVariable(
- "UMAP_ID",
- $this->getMapId()
- );
- $js_tpl->setVariable("CNT", $cnt);
-
- $js_tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
- $js_tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
- $info = htmlspecialchars($user->getFirstName() . " " . $user->getLastName());
- $delim = "
";
- if ($user->getPref("public_institution") == "y") {
- $info .= $delim . htmlspecialchars($user->getInstitution());
- $delim = ", ";
- }
- if ($user->getPref("public_department") == "y") {
- $info .= $delim . htmlspecialchars($user->getDepartment());
- }
- $delim = "
";
- if ($user->getPref("public_street") == "y") {
- $info .= $delim . htmlspecialchars($user->getStreet());
- }
- if ($user->getPref("public_zip") == "y") {
- $info .= $delim . htmlspecialchars($user->getZipcode());
- $delim = " ";
- }
- if ($user->getPref("public_city") == "y") {
- $info .= $delim . htmlspecialchars($user->getCity());
- }
- $delim = "
";
- if ($user->getPref("public_country") == "y") {
- $info .= $delim . htmlspecialchars($user->getCountry());
- }
- $js_tpl->setVariable(
- "USER_INFO",
- $info
- );
- $js_tpl->setVariable(
- "IMG_USER",
- $user->getPersonalPicturePath("xsmall")
- );
- $js_tpl->parseCurrentBlock();
- $cnt++;
- }
- }
- }
-
- $html_tpl->setVariable("MAP_ID", $this->getMapId());
- $html_tpl->setVariable("WIDTH", $this->getWidth());
- $html_tpl->setVariable("HEIGHT", $this->getHeight());
-
- $js_tpl->setVariable("MAP_ID", $this->getMapId());
- $js_tpl->setVariable("LAT", $this->getLatitude());
- $js_tpl->setVariable("LONG", $this->getLongitude());
- $js_tpl->setVariable("ZOOM", (int) $this->getZoom());
- $type_control = $this->getEnableTypeControl()
- ? "true"
- : "false";
- $js_tpl->setVariable("TYPE_CONTROL", $type_control);
- $nav_control = $this->getEnableNavigationControl()
- ? "true"
- : "false";
- $js_tpl->setVariable("NAV_CONTROL", $nav_control);
- $update_listener = $this->getEnableUpdateListener()
- ? "true"
- : "false";
- $js_tpl->setVariable("UPDATE_LISTENER", $update_listener);
- $large_map_control = $this->getEnableLargeMapControl()
- ? "true"
- : "false";
- $js_tpl->setVariable("LARGE_CONTROL", $large_map_control);
- $central_marker = $this->getEnableCentralMarker()
- ? "true"
- : "false";
- $js_tpl->setVariable("CENTRAL_MARKER", $central_marker);
-
- $this->tpl->addOnLoadCode($js_tpl->get());
-
- return $html_tpl->get();
- }
-
- /**
- * Get User List HTML (to be displayed besides the map)
- */
- public function getUserListHtml(): string
- {
- $list_tpl = new ilTemplate(
- "tpl.google_map_user_list.html",
- true,
- true,
- "components/ILIAS/Maps"
- );
-
- $cnt = 0;
- foreach ($this->user_marker as $user_id) {
- if (ilObject::_exists($user_id)) {
- $user = new ilObjUser($user_id);
- $this->css_row = ($this->css_row != "tblrow1_mo")
- ? "tblrow1_mo"
- : "tblrow2_mo";
- if ($user->getLatitude() != 0 && $user->getLongitude() != 0
- && $user->getPref("public_location") == "y") {
- $list_tpl->setCurrentBlock("item");
- $list_tpl->setVariable("MARKER_CNT", $cnt);
- $list_tpl->setVariable("MAP_ID", $this->getMapId());
- $cnt++;
- } else {
- $list_tpl->setCurrentBlock("item_no_link");
- }
- $list_tpl->setVariable("CSS_ROW", $this->css_row);
- $list_tpl->setVariable("TXT_USER", $user->getLogin());
- $list_tpl->setVariable(
- "IMG_USER",
- $user->getPersonalPicturePath("xxsmall")
- );
- $list_tpl->parseCurrentBlock();
- $list_tpl->touchBlock("row");
- }
- }
-
- return $list_tpl->get();
- }
-}
diff --git a/components/ILIAS/Maps/classes/class.ilMapUtil.php b/components/ILIAS/Maps/classes/class.ilMapUtil.php
index be97be75fdd6..e54925f2fb82 100755
--- a/components/ILIAS/Maps/classes/class.ilMapUtil.php
+++ b/components/ILIAS/Maps/classes/class.ilMapUtil.php
@@ -148,13 +148,12 @@ public static function getMapGUI(): ilMapGui
{
$type = self::getType();
switch ($type) {
+ default:
case "openlayers":
$map = new ilOpenLayersMapGUI();
$map->setTileServers(self::getStdTileServers());
$map->setGeolocationServer(self::getStdGeolocationServer());
return $map;
- default:
- return new ilGoogleMapGUI();
}
}
@@ -171,7 +170,6 @@ public static function getAvailableMapTypes(): array
return [
"openlayers" => $lng->txt("maps_open_layers_maps"),
- "googlemaps" => $lng->txt("maps_google_maps")
];
}
}
diff --git a/components/ILIAS/Maps/classes/class.ilObjMapsGUI.php b/components/ILIAS/Maps/classes/class.ilObjMapsGUI.php
index 96dfbc9ff52f..9d65d9a3add8 100644
--- a/components/ILIAS/Maps/classes/class.ilObjMapsGUI.php
+++ b/components/ILIAS/Maps/classes/class.ilObjMapsGUI.php
@@ -88,7 +88,8 @@ private function buildForm(): ilPropertyFormGUI
$std_latitude = (float) ilMapUtil::getStdLatitude();
$std_longitude = (float) ilMapUtil::getStdLongitude();
$std_zoom = ilMapUtil::getStdZoom();
- $type = ilMapUtil::getType();
+ $available_types = ilMapUtil::getAvailableMapTypes();
+ $type = self::normalizeMapType(ilMapUtil::getType(), $available_types);
$form = new ilPropertyFormGUI();
$form->setFormAction($ilCtrl->getFormAction($this));
$form->setTitle($lng->txt('maps_settings'));
@@ -101,7 +102,7 @@ private function buildForm(): ilPropertyFormGUI
// Select type
$types = new ilSelectInputGUI($lng->txt('maps_map_type'), 'type');
- $types->setOptions(ilMapUtil::getAvailableMapTypes());
+ $types->setOptions($available_types);
$types->setValue($type);
$form->addItem($types);
@@ -116,12 +117,6 @@ private function buildForm(): ilPropertyFormGUI
$form->addItem($tile);
$form->addItem($geolocation);
- } else {
- // api key for google
- $key = new ilTextInputGUI('Google API Key', 'api_key');
- $key->setMaxLength(200);
- $key->setValue(ilMapUtil::getApiKey());
- $form->addItem($key);
}
// location property
@@ -147,17 +142,17 @@ private function save(): void
{
$form = $this->buildForm();
if ($form->checkInput()) {
- if ($form->getInput('type') === 'openlayers' && 'openlayers' === ilMapUtil::getType()) {
+ $type = self::normalizeMapType($form->getInput('type'), ilMapUtil::getAvailableMapTypes());
+
+ if ($type === 'openlayers') {
ilMapUtil::setStdTileServers($form->getInput('tile'));
ilMapUtil::setStdGeolocationServer(
$form->getInput('geolocation')
);
- } else {
- ilMapUtil::setApiKey($form->getInput('api_key'));
}
ilMapUtil::setActivated($form->getInput('enable') === '1');
- ilMapUtil::setType($form->getInput('type'));
+ ilMapUtil::setType($type);
$location = $form->getInput('std_location');
ilMapUtil::setStdLatitude((string) $location['latitude']);
ilMapUtil::setStdLongitude((string) $location['longitude']);
@@ -165,4 +160,16 @@ private function save(): void
}
$this->ctrl->redirect($this, 'view');
}
+
+ /**
+ * @param array $available_types
+ */
+ private static function normalizeMapType(?string $type, array $available_types): string
+ {
+ if ($type !== null && isset($available_types[$type])) {
+ return $type;
+ }
+
+ return array_key_first($available_types) ?? 'openlayers';
+ }
}
diff --git a/components/ILIAS/Maps/templates/default/tpl.google_map.html b/components/ILIAS/Maps/templates/default/tpl.google_map.html
deleted file mode 100755
index a49dc7d69ded..000000000000
--- a/components/ILIAS/Maps/templates/default/tpl.google_map.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/components/ILIAS/Maps/templates/default/tpl.google_map.js b/components/ILIAS/Maps/templates/default/tpl.google_map.js
deleted file mode 100755
index c3d40ee9870a..000000000000
--- a/components/ILIAS/Maps/templates/default/tpl.google_map.js
+++ /dev/null
@@ -1,284 +0,0 @@
-/**
- * This file is part of ILIAS, a powerful learning management system
- * published by ILIAS open source e-Learning e.V.
- *
- * ILIAS is licensed with the GPL-3.0,
- * see https://www.gnu.org/licenses/gpl-3.0.en.html
- * You should have received a copy of said license along with the
- * source code, too.
- *
- * If this is not the case or you just want to try ILIAS, you'll find
- * us at:
- * https://www.ilias.de
- * https://github.com/ILIAS-eLearning
- */
-
-window.ilMapData = window.ilMapData || [];
-window.ilMap = window.ilMap || [];
-window.ilMapOptions = window.ilMapOptions || [];
-window.ilCM = window.ilCM || [];
-window.ilMapUserMarker = window.ilMapUserMarker || [];
-ilMapData["{MAP_ID}"] = new Array({LAT},{LONG},{ZOOM},{TYPE_CONTROL},{NAV_CONTROL},{UPDATE_LISTENER},{LARGE_CONTROL},{CENTRAL_MARKER});
-ilMapUserMarker["{MAP_ID}"] = Array();
-
-ilMapUserMarker["{UMAP_ID}"][{CNT}] = new Array({ULAT},{ULONG}, "
{USER_INFO}<\/span><\/div>");
-
-
-var ilMarkerImage = null;
-if (typeof google !== "undefined" && google.maps)
-{
- // Google Maps still supports legacy `google.maps.Marker`, but `google.maps.MarkerImage`
- // is an older wrapper API for marker icons. Using the icon as a plain object with
- // `url`, `scaledSize`, `origin`, and `anchor` passes the same marker configuration in
- // the format the current marker API expects. This keeps the existing legacy marker
- // behavior and custom SVG icon, while avoiding the deprecated `MarkerImage` wrapper
- // that no longer rendered reliably here.
- ilMarkerImage = {
- url: "./assets/images/standard/icon_mapm.svg",
- scaledSize: new google.maps.Size(12, 20),
- origin: new google.maps.Point(0, 0),
- anchor: new google.maps.Point(6, 20)
- };
-}
-
-if (typeof google !== "undefined" && google.maps)
-{
- ilInitMaps();
-}
-
-/**
- * Init all maps
- */
-function ilInitMaps()
-{
- var obj;
-
- // get all spans
- obj = document.getElementsByTagName('div');
-
- // run through them
- for (var i=0;i 0 && typeof result[0] === "object" && "geometry" in result[0]) {
- map.setCenter(result[0]["geometry"]["location"]);
- ilUpdateLocationInput(id, map, result[0]["geometry"]["location"],
- result[0]["formatted_address"]);
- }
- else
- {
- alert("Address: '" + address + "' not found");
- }
- });
-}
-window.ilLookupAddress = ilLookupAddress;
diff --git a/components/ILIAS/Maps/templates/default/tpl.google_map_user_list.html b/components/ILIAS/Maps/templates/default/tpl.google_map_user_list.html
deleted file mode 100755
index 9637e3330247..000000000000
--- a/components/ILIAS/Maps/templates/default/tpl.google_map_user_list.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
diff --git a/components/ILIAS/Maps/tests/ilObjMapsGUITest.php b/components/ILIAS/Maps/tests/ilObjMapsGUITest.php
new file mode 100644
index 000000000000..9e84bc1268a7
--- /dev/null
+++ b/components/ILIAS/Maps/tests/ilObjMapsGUITest.php
@@ -0,0 +1,66 @@
+assertSame($expected, $method->invoke(null, $configured_type, $available_types));
+ }
+
+ public static function mapTypeProvider(): \Iterator
+ {
+ yield 'supported type is kept' => [
+ 'openlayers',
+ ['openlayers' => 'OpenLayers'],
+ 'openlayers'
+ ];
+
+ yield 'legacy google maps type falls back to first available option' => [
+ 'googlemaps',
+ ['openlayers' => 'OpenLayers'],
+ 'openlayers'
+ ];
+
+ yield 'empty type falls back to first available option' => [
+ '',
+ ['openlayers' => 'OpenLayers'],
+ 'openlayers'
+ ];
+
+ yield 'missing type falls back to first available option' => [
+ null,
+ ['openlayers' => 'OpenLayers'],
+ 'openlayers'
+ ];
+
+ yield 'empty options still return openlayers default' => [
+ 'googlemaps',
+ [],
+ 'openlayers'
+ ];
+ }
+}
diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang
index 97afdc5281be..b31e7214d8dc 100644
--- a/lang/ilias_de.lang
+++ b/lang/ilias_de.lang
@@ -11893,7 +11893,6 @@ maps#:#maps_custom_tile_server_info#:#URL des Servers für die Bereitstellung de
maps#:#maps_enable_maps#:#Karten aktivieren
maps#:#maps_enable_maps_info#:#Karten können systemweit in Profilen, Kursen und Gruppen angezeigt werden.
maps#:#maps_geolocation_server#:#Server für Reverse Geolocation
-maps#:#maps_google_maps#:#Google Maps
maps#:#maps_https_for_reverse_lookup#:#Https für Reverse Lookup
maps#:#maps_latitude#:#Breitengrad
maps#:#maps_longitude#:#Längengrad
diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang
index 46f3ada25129..806264424241 100644
--- a/lang/ilias_en.lang
+++ b/lang/ilias_en.lang
@@ -11865,7 +11865,6 @@ maps#:#maps_custom_tile_server_info#:#Server URL to provide tile-data. Multiple
maps#:#maps_enable_maps#:#Enable Maps
maps#:#maps_enable_maps_info#:#Activates Maps in user profiles, groups and courses.
maps#:#maps_geolocation_server#:#Server for Reverse Geolocation
-maps#:#maps_google_maps#:#Google Maps
maps#:#maps_https_for_reverse_lookup#:#Https for Reverse Lookup
maps#:#maps_latitude#:#Latitude
maps#:#maps_longitude#:#Longitude