ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMapUtil.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public const DEFAULT_TILE = "a.tile.openstreetmap.org b.tile.openstreetmap.org c.tile.openstreetmap.org";
24 public const DEFAULT_GEOLOCATION = null;
25
26 public static ?ilSetting $_settings = null;
27
28 public static function settings(): ilSetting
29 {
30 if (self::$_settings === null) {
31 self::$_settings = new ilSetting("maps");
32 }
33 return self::$_settings;
34 }
35
40 public static function isActivated(): bool
41 {
42 return self::settings()->get("enable") == 1;
43 }
44
45 public static function setActivated(bool $activated): void
46 {
47 self::settings()->set("enable", $activated ? "1" : "0");
48 }
49
50 public static function setType(string $type): void
51 {
52 self::settings()->set("type", $type);
53 }
54
55 public static function getType(): ?string
56 {
57 return self::settings()->get("type");
58 }
59
60 public static function setStdLatitude(string $lat): void
61 {
62 self::settings()->set("std_latitude", $lat);
63 }
64
65 public static function getStdLatitude(): ?string
66 {
67 return self::settings()->get("std_latitude");
68 }
69
70 public static function setStdLongitude(string $lon): void
71 {
72 self::settings()->set("std_longitude", $lon);
73 }
74
75 public static function getStdLongitude(): ?string
76 {
77 return self::settings()->get("std_longitude");
78 }
79
80 public static function setStdZoom(string $zoom): void
81 {
82 self::settings()->set("std_zoom", $zoom);
83 }
84
85 public static function getStdZoom(): ?string
86 {
87 return self::settings()->get("std_zoom");
88 }
89
90 public static function setApiKey(string $api_key): void
91 {
92 self::settings()->set("api_key", $api_key);
93 }
94
95 public static function getApiKey(): ?string
96 {
97 return self::settings()->get("api_key");
98 }
99
100 public static function setStdTileServers(string $tile): void
101 {
102 self::settings()->set("std_tile", $tile);
103 }
104
110 public static function getStdTileServers(): string
111 {
112 $std_tile = self::settings()->get("std_tile");
113 return $std_tile ?: self::DEFAULT_TILE;
114 }
115
116
117 public static function setStdGeolocationServer($geolocation): void
118 {
119 self::settings()->set("std_geolocation", $geolocation);
120 }
121
125 public static function getStdGeolocationServer(): ?string
126 {
127 $std_geoloc = self::settings()->get("std_geolocation");
128 return $std_geoloc ?: self::DEFAULT_GEOLOCATION;
129 }
130
135 public static function getDefaultSettings(): array
136 {
137 return [
138 "longitude" => self::settings()->get("std_longitude") ?? "",
139 "latitude" => self::settings()->get("std_latitude") ?? "",
140 "zoom" => self::settings()->get("std_zoom") ?? 0
141 ];
142 }
143
147 public static function getMapGUI(): ilMapGui
148 {
149 $type = self::getType();
150 switch ($type) {
151 case "openlayers":
152 $map = new ilOpenLayersMapGUI();
153 $map->setTileServers(self::getStdTileServers());
154 $map->setGeolocationServer(self::getStdGeolocationServer());
155 return $map;
156 default:
157 return new ilGoogleMapGUI();
158 }
159 }
160
166 public static function getAvailableMapTypes(): array
167 {
168 global $DIC;
169 $lng = $DIC['lng'];
170 $lng->loadLanguageModule("maps");
171
172 return [
173 "openlayers" => $lng->txt("maps_open_layers_maps"),
174 "googlemaps" => $lng->txt("maps_google_maps")
175 ];
176 }
177}
User interface class for Google Maps.
static setActivated(bool $activated)
static getApiKey()
static getStdGeolocationServer()
Returns the reverse geolocation server to be used in the installation.
static getStdLatitude()
static setStdLongitude(string $lon)
static setStdTileServers(string $tile)
static setStdLatitude(string $lat)
static getStdTileServers()
Returns the tile server to be used in the installation.
static getStdLongitude()
static setStdGeolocationServer($geolocation)
static getStdZoom()
const DEFAULT_TILE
static setStdZoom(string $zoom)
static settings()
static isActivated()
Checks whether Map feature is activated.
const DEFAULT_GEOLOCATION
static ilSetting $_settings
static setType(string $type)
static getAvailableMapTypes()
Get a dict { $id => $name } for available maps services.
static getMapGUI()
Get an instance of the GUI class.
static getDefaultSettings()
Get default longitude, latitude and zoom.
static setApiKey(string $api_key)
static getType()
User interface class for OpenLayers maps.
ILIAS Setting Class.
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26