ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
32 class ilMapUtil
33 {
34  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  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  static function isActivated()
58  {
59  return self::settings()->get("enable") == 1;
60  }
61 
62  // RK TODO: check inputs of setters
63 
64  static function setActivated($a_activated)
65  {
66  self::settings()->set("enable", $a_activated?"1":"0");
67  }
68 
69  static function setType($a_type)
70  {
71  self::settings()->set("type", $a_type);
72  }
73 
74  static function getType() {
75  return self::settings()->get("type");
76  }
77 
78  static function setStdLatitude($a_lat)
79  {
80  self::settings()->set("std_latitude", $a_lat);
81  }
82 
83  static function getStdLatitude()
84  {
85  return self::settings()->get("std_latitude");
86  }
87 
88  static function setStdLongitude($a_lon)
89  {
90  self::settings()->set("std_longitude", $a_lon);
91  }
92 
93  static function getStdLongitude()
94  {
95  return self::settings()->get("std_longitude");
96  }
97 
98  static function setStdZoom($a_zoom)
99  {
100  self::settings()->set("std_zoom", $a_zoom);
101  }
102 
103  static function getStdZoom()
104  {
105  return self::settings()->get("std_zoom");
106  }
107 
108  static function setApiKey($a_api_key)
109  {
110  self::settings()->set("api_key", $a_api_key);
111  }
112 
113  static function getApiKey()
114  {
115  return self::settings()->get("api_key");
116  }
117 
118  static function setStdTileServers($a_tile)
119  {
120  self::settings()->set("std_tile", $a_tile);
121  }
122 
128  static function getStdTileServers()
129  {
130  $std_tile = self::settings()->get("std_tile");
131  return $std_tile ? $std_tile : self::DEFAULT_TILE;
132  }
133 
134 
135  static function setStdGeolocationServer($a_geolocation)
136  {
137  self::settings()->set("std_geolocation", $a_geolocation);
138  }
139 
145  static function getStdGeolocationServer()
146  {
147  $std_geoloc = self::settings()->get("std_geolocation");
148  return $std_geoloc ? $std_geoloc : self::DEFAULT_GEOLOCATION;
149  }
150 
156  static function getDefaultSettings()
157  {
158  return array(
159  "longitude" => self::settings()->get("std_longitude"),
160  "latitude" => self::settings()->get("std_latitude"),
161  "zoom" => self::settings()->get("std_zoom"));
162  }
163 
167  static public function getMapGUI()
168  {
169  $type = self::getType();
170  switch ($type) {
171  case "googlemaps":
172  require_once("Services/Maps/classes/class.ilGoogleMapGUI.php");
173  return new ilGoogleMapGUI();
174  case "openlayers":
175  require_once("Services/Maps/classes/class.ilOpenLayersMapGUI.php");
176  $map = new ilOpenLayersMapGUI();
177  $map->setTileServers(self::getStdTileServers());
178  $map->setGeolocationServer(self::getStdGeolocationServer());
179  return $map;
180  default:
181  require_once("Services/Maps/classes/class.ilGoogleMapGUI.php");
182  return new ilGoogleMapGUI();
183  }
184  }
185 
191  static public function getAvailableMapTypes()
192  {
193  global $DIC;
194  $lng = $DIC['lng'];
195  $lng->loadLanguageModule("maps");
196  return array( "openlayers" => $lng->txt("maps_open_layers_maps")
197  , "googlemaps" => $lng->txt("maps_google_maps")
198  );
199  }
200 }
201 ?>
ILIAS Setting Class.
static getType()
const DEFAULT_TILE
static setStdZoom($a_zoom)
static setStdGeolocationServer($a_geolocation)
static setStdLongitude($a_lon)
static getStdLongitude()
static settings()
static getStdZoom()
static getApiKey()
static setStdTileServers($a_tile)
static setApiKey($a_api_key)
$a_type
Definition: workflow.php:93
static getStdLatitude()
static getMapGUI()
Get an instance of the GUI class.
static setActivated($a_activated)
static getDefaultSettings()
Get default longitude, latitude and zoom.
User interface class for google maps.
static setType($a_type)
static setStdLatitude($a_lat)
static getAvailableMapTypes()
Get a dict { $id => $name } for available maps services.
Create styles array
The data for the language used.
Map Utility Class.
static isActivated()
Checks whether Map feature is activated.
static getStdGeolocationServer()
Returns the reverse geolocation server to be used in the installation.
settings()
Definition: settings.php:2
static $_settings
global $lng
Definition: privfeed.php:17
global $DIC
static getStdTileServers()
Returns the tile server to be used in the installation.
User interface class for OpenLayers maps.
const DEFAULT_GEOLOCATION