ILIAS  release_8 Revision v8.24
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)
 
 initJSandCSS ()
 
 getHtml (bool $inline_js=false)
 
 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 10 of file class.ilOpenLayersMapGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilOpenLayersMapGUI::__construct ( )

Reimplemented from ilMapGUI.

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

17 {
19
20 $this->css_row = "";
21 $this->tile_server = "";
22 $this->geolocation_server = "";
23 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getGeolocationServer()

ilOpenLayersMapGUI::getGeolocationServer ( )

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

36 : ?string
37 {
39 }

References $geolocation_server.

Referenced by getHtml().

+ Here is the caller graph for this function:

◆ getHtml()

ilOpenLayersMapGUI::getHtml ( bool  $inline_js = false)

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

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

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

+ Here is the call graph for this function:

◆ getTileServers()

ilOpenLayersMapGUI::getTileServers ( )

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

25 : string
26 {
27 return $this->tile_server;
28 }

References $tile_server.

Referenced by getHtml().

+ Here is the caller graph for this function:

◆ getUserListHtml()

ilOpenLayersMapGUI::getUserListHtml ( )

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

Reimplemented from ilMapGUI.

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

172 : string
173 {
174 $list_tpl = new ilTemplate(
175 "tpl.openlayers_map_user_list.html",
176 true,
177 true,
178 "Services/Maps"
179 );
180
181 $cnt = 0;
182 foreach ($this->user_marker as $user_id) {
183 if (ilObject::_exists($user_id)) {
184 $user = new ilObjUser($user_id);
185 $this->css_row = ($this->css_row != "tblrow1_mo")
186 ? "tblrow1_mo"
187 : "tblrow2_mo";
188 if ($user->getLatitude() != 0 && $user->getLongitude() != 0
189 && $user->getPref("public_location") == "y") {
190 $list_tpl->setCurrentBlock("item");
191 $list_tpl->setVariable("MARKER_CNT", $cnt);
192 $list_tpl->setVariable("MAP_ID", $this->getMapId());
193 $cnt++;
194 } else {
195 $list_tpl->setCurrentBlock("item_no_link");
196 }
197 $list_tpl->setVariable("CSS_ROW", $this->css_row);
198 $list_tpl->setVariable("TXT_USER", $user->getLogin());
199 $list_tpl->setVariable(
200 "IMG_USER",
201 $user->getPersonalPicturePath("xxsmall")
202 );
203 $list_tpl->parseCurrentBlock();
204 $list_tpl->touchBlock("row");
205 }
206 }
207
208 return $list_tpl->get();
209 }

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

+ Here is the call graph for this function:

◆ initJSandCSS()

ilOpenLayersMapGUI::initJSandCSS ( )

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

47 : void
48 {
49 $this->tpl->addCss("node_modules/ol/ol.css");
50 $this->tpl->addCss("Services/Maps/css/service_openlayers.css");
51 $this->tpl->addJavaScript("Services/Maps/js/dist/ServiceOpenLayers.js");
52 }

Referenced by getHtml().

+ Here is the caller graph for this function:

◆ setGeolocationServer()

ilOpenLayersMapGUI::setGeolocationServer ( ?string  $geolocation)

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

42 {
43 $this->geolocation_server = $geolocation;
44 return $this;
45 }
User interface class for OpenLayers maps.

◆ setTileServers()

ilOpenLayersMapGUI::setTileServers ( string  $tile)

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

31 {
32 $this->tile_server = $tile;
33 return $this;
34 }

Field Documentation

◆ $css_row

string ilOpenLayersMapGUI::$css_row
protected

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

◆ $geolocation_server

string ilOpenLayersMapGUI::$geolocation_server
protected

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

Referenced by getGeolocationServer().

◆ $tile_server

string ilOpenLayersMapGUI::$tile_server
protected

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

Referenced by getTileServers().


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