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
192 changes: 0 additions & 192 deletions components/ILIAS/Maps/classes/class.ilGoogleMapGUI.php

This file was deleted.

4 changes: 1 addition & 3 deletions components/ILIAS/Maps/classes/class.ilMapUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -171,7 +170,6 @@ public static function getAvailableMapTypes(): array

return [
"openlayers" => $lng->txt("maps_open_layers_maps"),
"googlemaps" => $lng->txt("maps_google_maps")
];
}
}
31 changes: 19 additions & 12 deletions components/ILIAS/Maps/classes/class.ilObjMapsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -147,22 +142,34 @@ 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']);
ilMapUtil::setStdZoom((string) $location['zoom']);
}
$this->ctrl->redirect($this, 'view');
}

/**
* @param array<string, string> $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';
}
}
4 changes: 0 additions & 4 deletions components/ILIAS/Maps/templates/default/tpl.google_map.html

This file was deleted.

Loading
Loading