@@ -20,8 +20,13 @@ interface LocationData extends ComponentData {
20
20
coordinates : {
21
21
latitude : number ,
22
22
longitude : number
23
- }
24
- sensitivity : number
23
+ } ,
24
+ sensitivity : number ,
25
+ showMarker : boolean ,
26
+ markerPictureUrl : string ;
27
+ markerPopupText : string ;
28
+ showUsers : boolean ,
29
+ containerClass : string ,
25
30
}
26
31
27
32
interface LocationState {
@@ -70,7 +75,10 @@ export class LeafletLocation extends Component<LocationData, LocationState> {
70
75
"additionalProperties" : false ,
71
76
"required" : [
72
77
"coordinates" ,
73
- "sensitivity"
78
+ "sensitivity" ,
79
+ "showMarker" ,
80
+ "markerPictureUrl" ,
81
+ "showUsers"
74
82
] ,
75
83
"definitions" : {
76
84
"location" : {
@@ -103,6 +111,36 @@ export class LeafletLocation extends Component<LocationData, LocationState> {
103
111
"title" : "Proximity to location (km)" ,
104
112
"default" : 0.1 ,
105
113
"minimum" : 0.0
114
+ } ,
115
+ "showMarker" : {
116
+ "$id" : "#/properties/showMarker" ,
117
+ "type" : "boolean" ,
118
+ "title" : "Show marker" ,
119
+ "default" : true
120
+ } ,
121
+ "markerPictureUrl" : {
122
+ "$id" : "#/properties/markerPictureUrl" ,
123
+ "type" : "string" ,
124
+ "title" : "Marker picture url" ,
125
+ "default" : "http://assets.stickpng.com/images/58568b014f6ae202fedf2717.png"
126
+ } ,
127
+ "markerPopupText" : {
128
+ "$id" : "#/properties/markerPopupText" ,
129
+ "type" : "string" ,
130
+ "title" : "Marker popup text" ,
131
+ "default" : "This is your goal!"
132
+ } ,
133
+ "showUsers" : {
134
+ "$id" : "#/properties/showUsers" ,
135
+ "type" : "boolean" ,
136
+ "title" : "Show users" ,
137
+ "default" : true
138
+ } ,
139
+ "containerClass" : {
140
+ "$id" : "#/properties/containerClass" ,
141
+ "type" : "string" ,
142
+ "title" : "Map container class name" ,
143
+ "default" : "leaflet-map-container"
106
144
}
107
145
}
108
146
} ;
@@ -112,7 +150,12 @@ export class LeafletLocation extends Component<LocationData, LocationState> {
112
150
example : {
113
151
longitude : 47.541246 ,
114
152
latitude : 19.243312 ,
153
+ showMarker : true ,
154
+ markerPictureUrl : "http://assets.stickpng.com/images/58568b014f6ae202fedf2717.png" ,
155
+ showUsers : true ,
156
+ markerPopupText : "Your goal is here!" ,
115
157
players : [ "test" ] ,
158
+ containerClass : "leaflet-map-container" ,
116
159
playerLocations : {
117
160
"test" : {
118
161
longitude : 47.541497 ,
@@ -121,8 +164,8 @@ export class LeafletLocation extends Component<LocationData, LocationState> {
121
164
}
122
165
}
123
166
} ,
124
- template : `<div id="leaflet-plugin-container-{{id}}" style="width: 90%; margin: 0 auto; height: 50vh">
125
- <div id="leaflet-map-{{id}}"></div>
167
+ template : `<div id="leaflet-plugin-container-{{id}}" class="{{containerClass}}" style="width: 90%; margin: 0 auto; height: 50vh">
168
+
126
169
</div>
127
170
<script>
128
171
var leafletPluginMapId = "{{id}}";
@@ -144,10 +187,8 @@ function createMapSetup(mapId) {
144
187
145
188
var map;
146
189
if (container != null && leafletPluginMaps[mapId] != null && leafletPluginMaps != undefined) {
147
- console.log("Loading map from cache");
148
190
map = leafletPluginMaps[mapId];
149
191
} else {
150
- console.log("Creating new map");
151
192
document.getElementById('leaflet-plugin-container-' + mapId).innerHTML = "<div id=" + mapName + "></div>";
152
193
map = L.map(mapName);
153
194
@@ -159,21 +200,27 @@ function createMapSetup(mapId) {
159
200
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
160
201
}).addTo(map);
161
202
162
- var mainIcon = L.icon({
163
- iconUrl: "https://tcbmag.com/wp-content/uploads/2020/03/7fe12969-5641-4ce0-9395-e325cee0e830.jpg",
164
- iconSize: [50, 50],
165
- });
166
- var mainMarker = L.marker([mapLatitude, mapLongitude], { icon: mainIcon }).addTo(map);
167
- mainMarker.bindPopup("Célpont: {{latitude}}, {{longitude}}")
203
+ if ("{{showMarker}}" === "true") {
204
+ var mainIcon = L.icon({
205
+ iconUrl: "{{markerPictureUrl}}",
206
+ iconSize: [50, 50],
207
+ });
208
+ var mainMarker = L.marker([mapLatitude, mapLongitude], { icon: mainIcon }).addTo(map);
209
+ var popupText = "{{markerPopupText}}";
210
+ if (popupText.length !== 0)
211
+ mainMarker.bindPopup(popupText)
212
+ }
213
+
168
214
}
169
215
170
216
if (leafletPluginMarkers[mapId] !== undefined) {
171
217
leafletPluginMarkers[mapId].forEach(marker => map.removeLayer(marker));
172
218
leafletPluginMarkers[mapId] = [];
173
219
}
174
220
175
- updateMarkers(mapId, map);
176
-
221
+ if ("{{showUsers}}" === "true") {
222
+ updateMarkers(mapId, map);
223
+ }
177
224
return map;
178
225
}
179
226
}
@@ -218,6 +265,11 @@ function updateMarkers(mapId, map) {
218
265
feedId : createFeed ( "leafletHint" , {
219
266
latitude : information . data . coordinates . latitude ,
220
267
longitude : information . data . coordinates . longitude ,
268
+ showMarker : information . data . showMarker ,
269
+ markerPictureUrl : information . data . markerPictureUrl ,
270
+ markerPopupText : information . data . markerPopupText ,
271
+ showUsers : information . data . showUsers ,
272
+ containerClass : information . data . containerClass ,
221
273
id : information . id ,
222
274
} ) ,
223
275
players : [ ] ,
@@ -251,6 +303,11 @@ function updateMarkers(mapId, map) {
251
303
updateFeed ( ctx . feedId , {
252
304
latitude : information . data . coordinates . latitude ,
253
305
longitude : information . data . coordinates . longitude ,
306
+ showMarker : information . data . showMarker ,
307
+ markerPictureUrl : information . data . markerPictureUrl ,
308
+ markerPopupText : information . data . markerPopupText ,
309
+ showUsers : information . data . showUsers ,
310
+ containerClass : information . data . containerClass ,
254
311
players : ctx . players ,
255
312
playerLocations : ctx . playerLocations ,
256
313
id : information . id
0 commit comments