ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMapUtil.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
33{
34 public static $_settings = null;
35
36 const DEFAULT_TILE = "a.tile.openstreetmap.org b.tile.openstreetmap.org c.tile.openstreetmap.org";
37 const DEFAULT_GEOLOCATION = null;
38
39 // Settings
40
41 public static function settings()
42 {
43 if (self::$_settings === null) {
44 self::$_settings = new ilSetting("maps");
45 }
46 return self::$_settings;
47 }
48
49
50
57 public static function isActivated()
58 {
59 return self::settings()->get("enable") == 1;
60 }
61
62 // RK TODO: check inputs of setters
63
64 public static function setActivated($a_activated)
65 {
66 self::settings()->set("enable", $a_activated?"1":"0");
67 }
68
69 public static function setType($a_type)
70 {
71 self::settings()->set("type", $a_type);
72 }
73
74 public static function getType()
75 {
76 return self::settings()->get("type");
77 }
78
79 public static function setStdLatitude($a_lat)
80 {
81 self::settings()->set("std_latitude", $a_lat);
82 }
83
84 public static function getStdLatitude()
85 {
86 return self::settings()->get("std_latitude");
87 }
88
89 public static function setStdLongitude($a_lon)
90 {
91 self::settings()->set("std_longitude", $a_lon);
92 }
93
94 public static function getStdLongitude()
95 {
96 return self::settings()->get("std_longitude");
97 }
98
99 public static function setStdZoom($a_zoom)
100 {
101 self::settings()->set("std_zoom", $a_zoom);
102 }
103
104 public static function getStdZoom()
105 {
106 return self::settings()->get("std_zoom");
107 }
108
109 public static function setApiKey($a_api_key)
110 {
111 self::settings()->set("api_key", $a_api_key);
112 }
113
114 public static function getApiKey()
115 {
116 return self::settings()->get("api_key");
117 }
118
119 public static function setStdTileServers($a_tile)
120 {
121 self::settings()->set("std_tile", $a_tile);
122 }
123
129 public static function getStdTileServers()
130 {
131 $std_tile = self::settings()->get("std_tile");
132 return $std_tile ? $std_tile : self::DEFAULT_TILE;
133 }
134
135
136 public static function setStdGeolocationServer($a_geolocation)
137 {
138 self::settings()->set("std_geolocation", $a_geolocation);
139 }
140
146 public static function getStdGeolocationServer()
147 {
148 $std_geoloc = self::settings()->get("std_geolocation");
149 return $std_geoloc ? $std_geoloc : self::DEFAULT_GEOLOCATION;
150 }
151
157 public static function getDefaultSettings()
158 {
159 return array(
160 "longitude" => self::settings()->get("std_longitude"),
161 "latitude" => self::settings()->get("std_latitude"),
162 "zoom" => self::settings()->get("std_zoom"));
163 }
164
168 public static function getMapGUI()
169 {
171 switch ($type) {
172 case "googlemaps":
173 require_once("Services/Maps/classes/class.ilGoogleMapGUI.php");
174 return new ilGoogleMapGUI();
175 case "openlayers":
176 require_once("Services/Maps/classes/class.ilOpenLayersMapGUI.php");
177 $map = new ilOpenLayersMapGUI();
178 $map->setTileServers(self::getStdTileServers());
179 $map->setGeolocationServer(self::getStdGeolocationServer());
180 return $map;
181 default:
182 require_once("Services/Maps/classes/class.ilGoogleMapGUI.php");
183 return new ilGoogleMapGUI();
184 }
185 }
186
192 public static function getAvailableMapTypes()
193 {
194 global $DIC;
195 $lng = $DIC['lng'];
196 $lng->loadLanguageModule("maps");
197 return array( "openlayers" => $lng->txt("maps_open_layers_maps")
198 , "googlemaps" => $lng->txt("maps_google_maps")
199 );
200 }
201}
An exception for terminatinating execution or to throw for unit testing.
User interface class for google maps.
Map Utility Class.
static getApiKey()
static getStdGeolocationServer()
Returns the reverse geolocation server to be used in the installation.
static getStdLatitude()
static getStdTileServers()
Returns the tile server to be used in the installation.
static getStdLongitude()
static setApiKey($a_api_key)
static setActivated($a_activated)
static getStdZoom()
static setStdLatitude($a_lat)
const DEFAULT_TILE
static settings()
static isActivated()
Checks whether Map feature is activated.
const DEFAULT_GEOLOCATION
static setStdZoom($a_zoom)
static setStdGeolocationServer($a_geolocation)
static setStdLongitude($a_lon)
static $_settings
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 setStdTileServers($a_tile)
static setType($a_type)
static getType()
User interface class for OpenLayers maps.
ILIAS Setting Class.
global $lng
Definition: privfeed.php:17
$type
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$a_type
Definition: workflow.php:92