ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilOpenLayersMapGUI Class Reference

User interface class for OpenLayers maps. More...

+ Inheritance diagram for ilOpenLayersMapGUI:
+ Collaboration diagram for ilOpenLayersMapGUI:

Public Member Functions

 __construct ()
 
 getTileServers ()
 
 setTileServers (string $tile)
 
 getGeolocationServer ()
 
 setGeolocationServer (?string $geolocation)
 
 getHtml ()
 
 getUserListHtml ()
 Get User List HTML (to be displayed besides the map) More...
 
- Public Member Functions inherited from ilMapGUI
 __construct ()
 
 setMapId (string $map_id)
 
 getMapId ()
 
 setWidth (string $width)
 
 getWidth ()
 
 setHeight (string $height)
 
 getHeight ()
 
 setLatitude (string $latitude)
 
 getLatitude ()
 
 setLongitude (string $longitude)
 
 getLongitude ()
 
 setZoom (?int $zoom)
 
 getZoom ()
 
 setEnableTypeControl (bool $enable_type_control)
 
 getEnableTypeControl ()
 
 setEnableNavigationControl (bool $enable_navigation_control)
 
 getEnableNavigationControl ()
 
 setEnableUpdateListener (bool $enable_update_listener)
 
 getEnableUpdateListener ()
 
 setEnableLargeMapControl (bool $large_map_control)
 
 getEnableLargeMapControl ()
 
 setEnableCentralMarker (bool $central_marker)
 
 getEnableCentralMarker ()
 
 addUserMarker (int $user_id)
 
 getHtml ()
 
 getUserListHtml ()
 Get User List HTML (to be displayed besides the map) More...
 

Protected Attributes

string $css_row
 
string $tile_server
 
string $geolocation_server
 
- Protected Attributes inherited from ilMapGUI
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
string $map_id
 
string $width
 
string $height
 
string $latitude
 
string $longitude
 
int $zoom
 
bool $enable_type_control
 
bool $enable_update_listener
 
bool $enable_navigation_control
 
array $user_marker
 
bool $large_map_control
 
bool $central_marker
 

Detailed Description

User interface class for OpenLayers maps.

Definition at line 25 of file class.ilOpenLayersMapGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilOpenLayersMapGUI::__construct ( )

Definition at line 31 of file class.ilOpenLayersMapGUI.php.

References ILIAS\GlobalScreen\Provider\__construct().

32  {
34 
35  $this->css_row = "";
36  $this->tile_server = "";
37  $this->geolocation_server = "";
38  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getGeolocationServer()

ilOpenLayersMapGUI::getGeolocationServer ( )

Definition at line 51 of file class.ilOpenLayersMapGUI.php.

References $geolocation_server.

Referenced by getHtml().

51  : ?string
52  {
54  }
+ Here is the caller graph for this function:

◆ getHtml()

ilOpenLayersMapGUI::getHtml ( )

Definition at line 62 of file class.ilOpenLayersMapGUI.php.

References ilMapGUI\$central_marker, $user_id, ilObject\_exists(), ilMapGUI\getEnableCentralMarker(), ilMapGUI\getEnableNavigationControl(), ilMapGUI\getEnableUpdateListener(), getGeolocationServer(), ilMapGUI\getHeight(), ilMapGUI\getLatitude(), ilMapGUI\getLongitude(), ilMapGUI\getMapId(), getTileServers(), ilMapGUI\getWidth(), ilMapGUI\getZoom(), and ILIAS\Repository\lng().

62  : string
63  {
64  $html_tpl = new ilTemplate(
65  "tpl.openlayers_map.html",
66  true,
67  true,
68  "components/ILIAS/Maps"
69  );
70 
71  $js_tpl = new ilTemplate(
72  "tpl.openlayers_map.js",
73  true,
74  true,
75  "components/ILIAS/Maps"
76  );
77 
78  $this->lng->loadLanguageModule("maps");
79  $this->tpl->addCss("components/ILIAS/Maps/css/service_openlayers.css");
80  $this->tpl->addJavaScript("assets/js/ServiceOpenLayers.js");
81 
82  // add user markers
83  $cnt = 0;
84  foreach ($this->user_marker as $user_id) {
85  if (ilObject::_exists($user_id)) {
86  $user = new ilObjUser($user_id);
87  if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
88  $user->getPref("public_location") == "y") {
89  $js_tpl->setCurrentBlock("user_marker");
90  $js_tpl->setVariable(
91  "UMAP_ID",
92  $this->getMapId()
93  );
94  $js_tpl->setVariable("CNT", $cnt);
95 
96  $js_tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
97  $js_tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
98  $info = htmlspecialchars($user->getFirstName() . " " . $user->getLastName());
99  $delim = "<br />";
100  if ($user->getPref("public_institution") == "y") {
101  $info .= $delim . htmlspecialchars($user->getInstitution());
102  $delim = ", ";
103  }
104  if ($user->getPref("public_department") == "y") {
105  $info .= $delim . htmlspecialchars($user->getDepartment());
106  }
107  $delim = "<br />";
108  if ($user->getPref("public_street") == "y") {
109  $info .= $delim . htmlspecialchars($user->getStreet());
110  }
111  if ($user->getPref("public_zip") == "y") {
112  $info .= $delim . htmlspecialchars($user->getZipcode());
113  $delim = " ";
114  }
115  if ($user->getPref("public_city") == "y") {
116  $info .= $delim . htmlspecialchars($user->getCity());
117  }
118  $delim = "<br />";
119  if ($user->getPref("public_country") == "y") {
120  $info .= $delim . htmlspecialchars($user->getCountry());
121  }
122  $js_tpl->setVariable(
123  "USER_INFO",
124  $info
125  );
126  $js_tpl->setVariable(
127  "IMG_USER",
128  $user->getPersonalPicturePath("xsmall")
129  );
130  $js_tpl->parseCurrentBlock();
131  $cnt++;
132  }
133  }
134  }
135 
136  $html_tpl->setVariable("MAP_ID", $this->getMapId());
137  $html_tpl->setVariable("WIDTH", $this->getWidth());
138  $html_tpl->setVariable("HEIGHT", $this->getHeight());
139 
140  $js_tpl->setVariable("MAP_ID", $this->getMapId());
141  $js_tpl->setVariable("LAT", $this->getLatitude());
142  $js_tpl->setVariable("LONG", $this->getLongitude());
143  $js_tpl->setVariable("ZOOM", (int) $this->getZoom());
144 
145  $nav_control = $this->getEnableNavigationControl()
146  ? "true"
147  : "false";
148  $js_tpl->setVariable("NAV_CONTROL", $nav_control);
150  ? "true"
151  : "false";
152  $js_tpl->setVariable("CENTRAL_MARKER", $central_marker);
153  $replace_marker = $this->getEnableUpdateListener()
154  ? "true"
155  : "false";
156  $js_tpl->setVariable("REPLACE_MARKER", $replace_marker);
157 
158  $tile_servers = $this->getTileServers();
159  $tile_servers = explode(" ", $tile_servers);
160  array_walk($tile_servers, function (&$string) {
161  $string = '"' . $string . '"';
162  });
163  $tile_servers = '[' . implode(', ', $tile_servers) . ']';
164 
165  $js_tpl->setVariable("TILES", $tile_servers);
166  $js_tpl->setVariable("GEOLOCATION", $this->getGeolocationServer());
167  $js_tpl->setVariable("INVALID_ADDRESS_STRING", $this->lng->txt("invalid_address"));
168 
169  $this->tpl->addOnLoadCode($js_tpl->get());
170 
171  return $html_tpl->get();
172  }
bool $central_marker
getEnableCentralMarker()
getEnableUpdateListener()
getEnableNavigationControl()
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
+ Here is the call graph for this function:

◆ getTileServers()

ilOpenLayersMapGUI::getTileServers ( )

Definition at line 40 of file class.ilOpenLayersMapGUI.php.

References $tile_server.

Referenced by getHtml().

40  : string
41  {
42  return $this->tile_server;
43  }
+ Here is the caller graph for this function:

◆ getUserListHtml()

ilOpenLayersMapGUI::getUserListHtml ( )

Get User List HTML (to be displayed besides the map)

Definition at line 177 of file class.ilOpenLayersMapGUI.php.

References $user_id, ilObject\_exists(), and ilMapGUI\getMapId().

177  : string
178  {
179  $list_tpl = new ilTemplate(
180  "tpl.openlayers_map_user_list.html",
181  true,
182  true,
183  "components/ILIAS/Maps"
184  );
185 
186  $cnt = 0;
187  foreach ($this->user_marker as $user_id) {
188  if (ilObject::_exists($user_id)) {
189  $user = new ilObjUser($user_id);
190  $this->css_row = ($this->css_row != "tblrow1_mo")
191  ? "tblrow1_mo"
192  : "tblrow2_mo";
193  if ($user->getLatitude() != 0 && $user->getLongitude() != 0
194  && $user->getPref("public_location") == "y") {
195  $list_tpl->setCurrentBlock("item");
196  $list_tpl->setVariable("MARKER_CNT", $cnt);
197  $list_tpl->setVariable("MAP_ID", $this->getMapId());
198  $cnt++;
199  } else {
200  $list_tpl->setCurrentBlock("item_no_link");
201  }
202  $list_tpl->setVariable("CSS_ROW", $this->css_row);
203  $list_tpl->setVariable("TXT_USER", $user->getLogin());
204  $list_tpl->setVariable(
205  "IMG_USER",
206  $user->getPersonalPicturePath("xxsmall")
207  );
208  $list_tpl->parseCurrentBlock();
209  $list_tpl->touchBlock("row");
210  }
211  }
212 
213  return $list_tpl->get();
214  }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
+ Here is the call graph for this function:

◆ setGeolocationServer()

ilOpenLayersMapGUI::setGeolocationServer ( ?string  $geolocation)

Definition at line 56 of file class.ilOpenLayersMapGUI.php.

57  {
58  $this->geolocation_server = $geolocation;
59  return $this;
60  }
User interface class for OpenLayers maps.

◆ setTileServers()

ilOpenLayersMapGUI::setTileServers ( string  $tile)

Definition at line 45 of file class.ilOpenLayersMapGUI.php.

46  {
47  $this->tile_server = $tile;
48  return $this;
49  }
User interface class for OpenLayers maps.

Field Documentation

◆ $css_row

string ilOpenLayersMapGUI::$css_row
protected

Definition at line 27 of file class.ilOpenLayersMapGUI.php.

◆ $geolocation_server

string ilOpenLayersMapGUI::$geolocation_server
protected

Definition at line 29 of file class.ilOpenLayersMapGUI.php.

Referenced by getGeolocationServer().

◆ $tile_server

string ilOpenLayersMapGUI::$tile_server
protected

Definition at line 28 of file class.ilOpenLayersMapGUI.php.

Referenced by getTileServers().


The documentation for this class was generated from the following file: