ILIAS  release_8 Revision v8.24
class.ilMapUtil.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2018 - Richard Klees <richard.klees@concepts-and-training.de> - Extended GPL, see LICENSE */
6
8{
9 public const DEFAULT_TILE = "a.tile.openstreetmap.org b.tile.openstreetmap.org c.tile.openstreetmap.org";
10 public const DEFAULT_GEOLOCATION = null;
11
12 public static ?ilSetting $_settings = null;
13
14 public static function settings(): ilSetting
15 {
16 if (self::$_settings === null) {
17 self::$_settings = new ilSetting("maps");
18 }
19 return self::$_settings;
20 }
21
26 public static function isActivated(): bool
27 {
28 return self::settings()->get("enable") == 1;
29 }
30
31 public static function setActivated(bool $activated): void
32 {
33 self::settings()->set("enable", $activated ? "1" : "0");
34 }
35
36 public static function setType(string $type): void
37 {
38 self::settings()->set("type", $type);
39 }
40
41 public static function getType(): ?string
42 {
43 return self::settings()->get("type");
44 }
45
46 public static function setStdLatitude(string $lat): void
47 {
48 self::settings()->set("std_latitude", $lat);
49 }
50
51 public static function getStdLatitude(): ?string
52 {
53 return self::settings()->get("std_latitude");
54 }
55
56 public static function setStdLongitude(string $lon): void
57 {
58 self::settings()->set("std_longitude", $lon);
59 }
60
61 public static function getStdLongitude(): ?string
62 {
63 return self::settings()->get("std_longitude");
64 }
65
66 public static function setStdZoom(string $zoom): void
67 {
68 self::settings()->set("std_zoom", $zoom);
69 }
70
71 public static function getStdZoom(): ?string
72 {
73 return self::settings()->get("std_zoom");
74 }
75
76 public static function setApiKey(string $api_key): void
77 {
78 self::settings()->set("api_key", $api_key);
79 }
80
81 public static function getApiKey(): ?string
82 {
83 return self::settings()->get("api_key");
84 }
85
86 public static function setStdTileServers(string $tile): void
87 {
88 self::settings()->set("std_tile", $tile);
89 }
90
96 public static function getStdTileServers(): string
97 {
98 $std_tile = self::settings()->get("std_tile");
99 return $std_tile ?: self::DEFAULT_TILE;
100 }
101
102
103 public static function setStdGeolocationServer($geolocation): void
104 {
105 self::settings()->set("std_geolocation", $geolocation);
106 }
107
111 public static function getStdGeolocationServer(): ?string
112 {
113 $std_geoloc = self::settings()->get("std_geolocation");
114 return $std_geoloc ?: self::DEFAULT_GEOLOCATION;
115 }
116
121 public static function getDefaultSettings(): array
122 {
123 return [
124 "longitude" => self::settings()->get("std_longitude") ?? "",
125 "latitude" => self::settings()->get("std_latitude") ?? "",
126 "zoom" => self::settings()->get("std_zoom") ?? 0
127 ];
128 }
129
133 public static function getMapGUI(): ilMapGui
134 {
136 switch ($type) {
137 case "openlayers":
138 $map = new ilOpenLayersMapGUI();
139 $map->setTileServers(self::getStdTileServers());
140 $map->setGeolocationServer(self::getStdGeolocationServer());
141 return $map;
142 default:
143 return new ilGoogleMapGUI();
144 }
145 }
146
152 public static function getAvailableMapTypes(): array
153 {
154 global $DIC;
155 $lng = $DIC['lng'];
156 $lng->loadLanguageModule("maps");
157
158 return [
159 "openlayers" => $lng->txt("maps_open_layers_maps"),
160 "googlemaps" => $lng->txt("maps_google_maps")
161 ];
162 }
163}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$type
$lng