@vidro/map-handler 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +232 -180
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,146 +1,192 @@
|
|
|
1
|
-
import { EventEmitter } from "events"
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
2
|
import { iframeCommunicator } from "./shared/iframe-communicator";
|
|
3
3
|
class Communicator extends EventEmitter {
|
|
4
|
-
|
|
5
|
-
constructor(data){
|
|
4
|
+
constructor(data) {
|
|
6
5
|
super();
|
|
7
|
-
this.domId =
|
|
8
|
-
if(typeof window ===
|
|
6
|
+
this.domId = "map-frame";
|
|
7
|
+
if (typeof window === "undefined") {
|
|
9
8
|
return;
|
|
10
|
-
}
|
|
11
|
-
if(typeof data.id==="string"){
|
|
9
|
+
}
|
|
10
|
+
if (typeof data.id === "string") {
|
|
12
11
|
this.domId = data.id;
|
|
13
|
-
}
|
|
14
|
-
this.com = new iframeCommunicator(data)
|
|
15
|
-
window.addEventListener("message", e => this.onMessageReceived(e));
|
|
12
|
+
}
|
|
13
|
+
this.com = new iframeCommunicator(data);
|
|
14
|
+
window.addEventListener("message", (e) => this.onMessageReceived(e));
|
|
16
15
|
this.sessionToken = data.sessionToken;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
onMessageReceived = e => {
|
|
20
|
-
switch(e.data.type){
|
|
21
|
-
case "onZoomChange":
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
case "
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case "
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
case "
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
case "
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case "
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
onMessageReceived = (e) => {
|
|
19
|
+
switch (e.data.type) {
|
|
20
|
+
case "onZoomChange":
|
|
21
|
+
this.emitEvent("onZoomChange", e.data.zoom, e.data.domId);
|
|
22
|
+
break;
|
|
23
|
+
case "geomAdded":
|
|
24
|
+
this.emitEvent("geomAdded", e.data.geom_astext, e.data.domId);
|
|
25
|
+
break;
|
|
26
|
+
case "layers":
|
|
27
|
+
this.emitEvent("layers", e.data.layers, e.data.domId);
|
|
28
|
+
break;
|
|
29
|
+
case "geoJSONlayers":
|
|
30
|
+
this.emitEvent("geoJSONlayers", e.data.layers, e.data.domId);
|
|
31
|
+
break;
|
|
32
|
+
case "info":
|
|
33
|
+
this.emitEvent("info", e.data, e.data.domId);
|
|
34
|
+
break;
|
|
35
|
+
case "error":
|
|
36
|
+
this.emitEvent("error", e.data, e.data.domId);
|
|
37
|
+
break;
|
|
38
|
+
case "coordinates":
|
|
39
|
+
this.emitEvent("coordinates", e.data, e.data.domId);
|
|
40
|
+
break;
|
|
41
|
+
case "activeLayer":
|
|
42
|
+
this.emitEvent("activeLayer", e.data, e.data.domId);
|
|
43
|
+
break;
|
|
44
|
+
case "geolocation":
|
|
45
|
+
this.emitEvent("geolocation", e.data, e.data.domId);
|
|
46
|
+
break;
|
|
47
|
+
case "WMSInfoAvailable":
|
|
48
|
+
this.emitEvent("WMSInfoAvailable", e.data, e.data.domId);
|
|
49
|
+
break;
|
|
50
|
+
case "giswaterTiledBackgroundDisplayed":
|
|
51
|
+
this.emitEvent(
|
|
52
|
+
"giswaterTiledBackgroundDisplayed",
|
|
53
|
+
e.data,
|
|
54
|
+
e.data.domId
|
|
55
|
+
);
|
|
56
|
+
break;
|
|
57
|
+
case "giswaterTiledBackgroundAvailable":
|
|
58
|
+
this.emitEvent(
|
|
59
|
+
"giswaterTiledBackgroundAvailable",
|
|
60
|
+
e.data,
|
|
61
|
+
e.data.domId
|
|
62
|
+
);
|
|
63
|
+
break;
|
|
64
|
+
case "GiswaterLayerAvailableFilters":
|
|
65
|
+
this.emitEvent("GiswaterLayerAvailableFilters", e.data, e.data.domId);
|
|
66
|
+
break;
|
|
67
|
+
case "loaded":
|
|
68
|
+
this.emitEvent("loaded", e.data, e.data.domId);
|
|
69
|
+
break;
|
|
70
|
+
case "unloaded":
|
|
71
|
+
this.emitEvent("unloaded", e.data, e.data.domId);
|
|
72
|
+
break;
|
|
73
|
+
case "availableWMSLayers":
|
|
74
|
+
this.emitEvent("availableWMSLayers", e.data.layers, e.data.domId);
|
|
75
|
+
break;
|
|
76
|
+
case "layerElements":
|
|
77
|
+
this.emitEvent("layerElements", e.data, e.data.domId);
|
|
78
|
+
break;
|
|
79
|
+
case "getToc":
|
|
80
|
+
this.emitEvent("getToc", e.data, e.data.domId);
|
|
81
|
+
break;
|
|
82
|
+
//case "getLegend": this.emitEvent("getLegend", e.data,e.data.domId); break;
|
|
40
83
|
}
|
|
41
|
-
|
|
42
|
-
}
|
|
84
|
+
};
|
|
43
85
|
|
|
44
|
-
emitEvent = (type,data,domId)=>{
|
|
45
|
-
if(domId===this.domId){
|
|
86
|
+
emitEvent = (type, data, domId) => {
|
|
87
|
+
if (domId === this.domId) {
|
|
46
88
|
delete data.domId;
|
|
47
|
-
this.emit(type, data);
|
|
89
|
+
this.emit(type, data);
|
|
48
90
|
}
|
|
49
|
-
}
|
|
91
|
+
};
|
|
50
92
|
|
|
51
93
|
ZoomIn = () => {
|
|
52
94
|
this.com.sendMessageToMap({
|
|
53
95
|
type: "zoomIn",
|
|
54
96
|
sessionToken: this.sessionToken,
|
|
55
|
-
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
56
99
|
|
|
57
|
-
}
|
|
58
|
-
|
|
59
100
|
ZoomOut = () => {
|
|
60
101
|
this.com.sendMessageToMap({
|
|
61
102
|
type: "zoomOut",
|
|
62
103
|
sessionToken: this.sessionToken,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
65
106
|
|
|
66
107
|
AddGeom = (geomtype) => {
|
|
67
108
|
this.com.sendMessageToMap({
|
|
68
109
|
type: "AddGeom",
|
|
69
110
|
geom: geomtype,
|
|
70
111
|
sessionToken: this.sessionToken,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
73
114
|
|
|
74
|
-
toggleLayer = (layer,properties) => {
|
|
75
|
-
if(typeof properties===
|
|
115
|
+
toggleLayer = (layer, properties) => {
|
|
116
|
+
if (typeof properties === "undefined") {
|
|
76
117
|
properties = {
|
|
77
118
|
gutter: null,
|
|
78
119
|
transparent: null,
|
|
79
|
-
singletile: null
|
|
120
|
+
singletile: null,
|
|
80
121
|
};
|
|
81
122
|
}
|
|
82
123
|
|
|
83
|
-
if(properties.singletile!==null){
|
|
84
|
-
if(typeof properties.singletile!==
|
|
124
|
+
if (properties.singletile !== null) {
|
|
125
|
+
if (typeof properties.singletile !== "boolean") {
|
|
85
126
|
properties.singletile = null;
|
|
86
|
-
this.emit("error",{error:"singleTile must be a Boolean"});
|
|
127
|
+
this.emit("error", { error: "singleTile must be a Boolean" });
|
|
87
128
|
}
|
|
88
|
-
}
|
|
89
|
-
if(properties.gutter!==
|
|
90
|
-
if(isNaN(parseInt(properties.gutter))){
|
|
129
|
+
}
|
|
130
|
+
if (properties.gutter !== "" && properties.gutter !== null) {
|
|
131
|
+
if (isNaN(parseInt(properties.gutter))) {
|
|
91
132
|
properties.gutter = null;
|
|
92
|
-
this.emit("error",{error:"Gutter must be a number"});
|
|
133
|
+
this.emit("error", { error: "Gutter must be a number" });
|
|
93
134
|
}
|
|
94
|
-
if(properties.singletile){
|
|
135
|
+
if (properties.singletile) {
|
|
95
136
|
properties.gutter = null;
|
|
96
|
-
this.emit("error",{
|
|
137
|
+
this.emit("error", {
|
|
138
|
+
error:
|
|
139
|
+
"Gutter can only be user with multitile layers; set singletile to false",
|
|
140
|
+
});
|
|
97
141
|
}
|
|
98
|
-
}
|
|
142
|
+
}
|
|
99
143
|
|
|
100
|
-
if(properties.transparent!==null){
|
|
101
|
-
|
|
144
|
+
if (properties.transparent !== null) {
|
|
145
|
+
if (typeof properties.transparent !== "boolean") {
|
|
102
146
|
properties.transparent = null;
|
|
103
|
-
this.emit("error",{error:"transparent must be a Boolean"});
|
|
147
|
+
this.emit("error", { error: "transparent must be a Boolean" });
|
|
104
148
|
}
|
|
105
|
-
}
|
|
149
|
+
}
|
|
106
150
|
this.com.sendMessageToMap({
|
|
107
151
|
type: "toggleLayer",
|
|
108
152
|
layer: layer,
|
|
109
|
-
gutter: !isNaN(parseInt(properties.gutter))
|
|
153
|
+
gutter: !isNaN(parseInt(properties.gutter))
|
|
154
|
+
? parseInt(properties.gutter)
|
|
155
|
+
: null,
|
|
110
156
|
transparent: properties.transparent,
|
|
111
157
|
singletile: properties.singletile,
|
|
112
158
|
sessionToken: this.sessionToken,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
159
|
+
});
|
|
160
|
+
};
|
|
115
161
|
|
|
116
162
|
setActiveLayer = (layer) => {
|
|
117
163
|
this.com.sendMessageToMap({
|
|
118
164
|
type: "setActiveLayer",
|
|
119
165
|
layer: layer,
|
|
120
166
|
sessionToken: this.sessionToken,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
167
|
+
});
|
|
168
|
+
};
|
|
123
169
|
|
|
124
170
|
getActiveLayer = () => {
|
|
125
171
|
this.com.sendMessageToMap({
|
|
126
172
|
type: "getActiveLayer",
|
|
127
173
|
sessionToken: this.sessionToken,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
174
|
+
});
|
|
175
|
+
};
|
|
130
176
|
|
|
131
177
|
loadWMSAvailableLayers = () => {
|
|
132
178
|
this.com.sendMessageToMap({
|
|
133
179
|
type: "loadWMSAvailableLayers",
|
|
134
180
|
sessionToken: this.sessionToken,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
181
|
+
});
|
|
182
|
+
};
|
|
137
183
|
|
|
138
184
|
clear = () => {
|
|
139
185
|
this.com.sendMessageToMap({
|
|
140
186
|
type: "clear",
|
|
141
187
|
sessionToken: this.sessionToken,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
188
|
+
});
|
|
189
|
+
};
|
|
144
190
|
|
|
145
191
|
Highlight = (options) => {
|
|
146
192
|
this.com.sendMessageToMap({
|
|
@@ -148,36 +194,39 @@ class Communicator extends EventEmitter {
|
|
|
148
194
|
geom: options.geom,
|
|
149
195
|
zoom: options.zoom,
|
|
150
196
|
sessionToken: this.sessionToken,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
197
|
+
});
|
|
198
|
+
};
|
|
153
199
|
|
|
154
200
|
zoomToExtent = () => {
|
|
155
201
|
this.com.sendMessageToMap({
|
|
156
202
|
type: "zoomToExtent",
|
|
157
203
|
sessionToken: this.sessionToken,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
204
|
+
});
|
|
205
|
+
};
|
|
160
206
|
|
|
161
|
-
zoomToCoordinates= (lat,lon,zoomLevel) => {
|
|
162
|
-
if(!isNaN(parseInt(zoomLevel))){
|
|
207
|
+
zoomToCoordinates = (lat, lon, zoomLevel) => {
|
|
208
|
+
if (!isNaN(parseInt(zoomLevel))) {
|
|
163
209
|
this.com.sendMessageToMap({
|
|
164
210
|
type: "zoomToCoordinates",
|
|
165
211
|
sessionToken: this.sessionToken,
|
|
166
|
-
coordinates:[lat,lon],
|
|
167
|
-
zoomLevel: zoomLevel
|
|
168
|
-
});
|
|
212
|
+
coordinates: [lat, lon],
|
|
213
|
+
zoomLevel: zoomLevel,
|
|
214
|
+
});
|
|
169
215
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
infoFromCoordinates = (type,layer,hitTolerance,format) => {
|
|
173
|
-
const _layer =
|
|
174
|
-
const _hitTolerance =
|
|
175
|
-
|
|
176
|
-
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
infoFromCoordinates = (type, layer, hitTolerance, format) => {
|
|
219
|
+
const _layer = typeof layer == "undefined" ? null : layer;
|
|
220
|
+
const _hitTolerance =
|
|
221
|
+
typeof hitTolerance == "undefined" || !hitTolerance
|
|
222
|
+
? 5
|
|
223
|
+
: parseInt(hitTolerance);
|
|
224
|
+
const _format = typeof format == "undefined" ? "xml" : format.toLowerCase();
|
|
225
|
+
if (_format !== "xml" && _format !== "json") {
|
|
177
226
|
console.error("Format must be 'xml' or 'json");
|
|
178
227
|
return;
|
|
179
228
|
}
|
|
180
|
-
if(isNaN(_hitTolerance)){
|
|
229
|
+
if (isNaN(_hitTolerance)) {
|
|
181
230
|
console.error("hitTolerance must be a number");
|
|
182
231
|
return;
|
|
183
232
|
}
|
|
@@ -188,196 +237,199 @@ class Communicator extends EventEmitter {
|
|
|
188
237
|
format: _format,
|
|
189
238
|
hitTolerance: _hitTolerance,
|
|
190
239
|
sessionToken: this.sessionToken,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
240
|
+
});
|
|
241
|
+
};
|
|
193
242
|
|
|
194
|
-
getElementsFromLayer= (layer,limit,format) => {
|
|
195
|
-
const _format =
|
|
196
|
-
if(_format!=="xml" && _format!==
|
|
243
|
+
getElementsFromLayer = (layer, limit, format) => {
|
|
244
|
+
const _format = typeof format == "undefined" ? "xml" : format.toLowerCase();
|
|
245
|
+
if (_format !== "xml" && _format !== "json") {
|
|
197
246
|
console.error("Format must be 'xml' or 'json");
|
|
198
247
|
return;
|
|
199
248
|
}
|
|
200
|
-
if(isNaN(limit)){
|
|
201
|
-
|
|
249
|
+
if (isNaN(limit)) {
|
|
250
|
+
console.error("Limit must be a number");
|
|
202
251
|
return;
|
|
203
252
|
}
|
|
204
|
-
const _layer =
|
|
253
|
+
const _layer = typeof layer == "undefined" ? null : layer;
|
|
205
254
|
this.com.sendMessageToMap({
|
|
206
255
|
type: "getElementsFromLayer",
|
|
207
256
|
layer: _layer,
|
|
208
|
-
limit:
|
|
257
|
+
limit: typeof limit != "undefined" ? parseInt(limit) : 100,
|
|
209
258
|
format: format,
|
|
210
259
|
sessionToken: this.sessionToken,
|
|
211
|
-
});
|
|
212
|
-
}
|
|
260
|
+
});
|
|
261
|
+
};
|
|
213
262
|
|
|
214
263
|
Geolocalize = (toggle) => {
|
|
215
264
|
this.com.sendMessageToMap({
|
|
216
265
|
type: "Geolocalize",
|
|
217
266
|
toggle: toggle,
|
|
218
267
|
sessionToken: this.sessionToken,
|
|
219
|
-
});
|
|
220
|
-
}
|
|
268
|
+
});
|
|
269
|
+
};
|
|
221
270
|
|
|
222
|
-
toggleGiswaterTiled = (toggle,tiled) => {
|
|
271
|
+
toggleGiswaterTiled = (toggle, tiled) => {
|
|
223
272
|
this.com.sendMessageToMap({
|
|
224
273
|
type: "toggleGiswaterTiled",
|
|
225
274
|
toggle: toggle,
|
|
226
275
|
tiled: tiled,
|
|
227
276
|
sessionToken: this.sessionToken,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
277
|
+
});
|
|
278
|
+
};
|
|
230
279
|
|
|
231
|
-
reloadDisplayedLayers = ()=>{
|
|
280
|
+
reloadDisplayedLayers = () => {
|
|
232
281
|
return this.com.sendMessageToMap({
|
|
233
282
|
type: "reloadDisplayedLayers",
|
|
234
283
|
sessionToken: this.sessionToken,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
284
|
+
});
|
|
285
|
+
};
|
|
237
286
|
|
|
238
|
-
addGeoJSON = (geoJSON,options, name)=>{
|
|
239
|
-
if(geoJSON){
|
|
287
|
+
addGeoJSON = (geoJSON, options, name) => {
|
|
288
|
+
if (geoJSON) {
|
|
240
289
|
return this.com.sendMessageToMap({
|
|
241
290
|
type: "addGeoJSON",
|
|
242
291
|
geoJSON: geoJSON,
|
|
243
|
-
options:
|
|
244
|
-
|
|
292
|
+
options:
|
|
293
|
+
typeof options != "undefined"
|
|
294
|
+
? options
|
|
295
|
+
: { fillcolor: null, strokecolor: null },
|
|
296
|
+
name: name ? name : Math.random().toString(36).substring(7),
|
|
245
297
|
sessionToken: this.sessionToken,
|
|
246
|
-
});
|
|
247
|
-
}else{
|
|
248
|
-
this.emit("error",{error:"No geoJSON data"});
|
|
298
|
+
});
|
|
299
|
+
} else {
|
|
300
|
+
this.emit("error", { error: "No geoJSON data" });
|
|
249
301
|
return;
|
|
250
302
|
}
|
|
251
|
-
}
|
|
303
|
+
};
|
|
252
304
|
|
|
253
|
-
|
|
305
|
+
clearGeoJSON = () => {
|
|
254
306
|
return this.com.sendMessageToMap({
|
|
255
307
|
type: "clearGeoJSON",
|
|
256
308
|
sessionToken: this.sessionToken,
|
|
257
|
-
});
|
|
258
|
-
}
|
|
309
|
+
});
|
|
310
|
+
};
|
|
259
311
|
|
|
260
|
-
|
|
261
|
-
if(name){
|
|
312
|
+
removeGeoJSONLayer = (name) => {
|
|
313
|
+
if (name) {
|
|
262
314
|
return this.com.sendMessageToMap({
|
|
263
315
|
type: "removeGeoJSONLayer",
|
|
264
316
|
name: name,
|
|
265
317
|
sessionToken: this.sessionToken,
|
|
266
|
-
});
|
|
267
|
-
}else{
|
|
268
|
-
this.emit("error",{error:"No geoJSON data"});
|
|
318
|
+
});
|
|
319
|
+
} else {
|
|
320
|
+
this.emit("error", { error: "No geoJSON data" });
|
|
269
321
|
return;
|
|
270
322
|
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
setGiswaterFilters = (filters)=>{
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
setGiswaterFilters = (filters) => {
|
|
274
326
|
var filtersJson = filters;
|
|
275
|
-
if(filters){
|
|
276
|
-
if(typeof filters!="object"){
|
|
277
|
-
filters = filters.trim()
|
|
278
|
-
filters = filters.replace(/^\s+|\s+$/g,
|
|
279
|
-
filters = filters.replace(/\\/g,
|
|
280
|
-
try{
|
|
281
|
-
filtersJson = JSON.parse(filters);
|
|
282
|
-
}catch(e){
|
|
283
|
-
this.emit("error",{error:"Filters is not a valid JSON"});
|
|
327
|
+
if (filters) {
|
|
328
|
+
if (typeof filters != "object") {
|
|
329
|
+
filters = filters.trim();
|
|
330
|
+
filters = filters.replace(/^\s+|\s+$/g, "");
|
|
331
|
+
filters = filters.replace(/\\/g, "");
|
|
332
|
+
try {
|
|
333
|
+
filtersJson = JSON.parse(filters);
|
|
334
|
+
} catch (e) {
|
|
335
|
+
this.emit("error", { error: "Filters is not a valid JSON" });
|
|
284
336
|
return;
|
|
285
337
|
}
|
|
286
338
|
}
|
|
287
|
-
|
|
339
|
+
|
|
288
340
|
return this.com.sendMessageToMap({
|
|
289
341
|
type: "setGiswaterFilters",
|
|
290
342
|
filters: filtersJson,
|
|
291
343
|
sessionToken: this.sessionToken,
|
|
292
|
-
});
|
|
293
|
-
}else{
|
|
294
|
-
this.emit("error",{error:"No filters"});
|
|
344
|
+
});
|
|
345
|
+
} else {
|
|
346
|
+
this.emit("error", { error: "No filters" });
|
|
295
347
|
return;
|
|
296
348
|
}
|
|
297
|
-
}
|
|
349
|
+
};
|
|
298
350
|
|
|
299
|
-
getGiswaterLayerAvailableFilters = (layer_name)=>{
|
|
300
|
-
if(layer_name){
|
|
301
|
-
|
|
351
|
+
getGiswaterLayerAvailableFilters = (layer_name) => {
|
|
352
|
+
if (layer_name) {
|
|
353
|
+
return this.com.sendMessageToMap({
|
|
302
354
|
type: "getGiswaterLayerAvailableFilters",
|
|
303
355
|
name: layer_name,
|
|
304
356
|
sessionToken: this.sessionToken,
|
|
305
|
-
});
|
|
306
|
-
}else{
|
|
307
|
-
this.emit("error",{error:"No layer_name"});
|
|
357
|
+
});
|
|
358
|
+
} else {
|
|
359
|
+
this.emit("error", { error: "No layer_name" });
|
|
308
360
|
return;
|
|
309
361
|
}
|
|
310
|
-
}
|
|
362
|
+
};
|
|
311
363
|
|
|
312
|
-
getToc = ()=>{
|
|
364
|
+
getToc = () => {
|
|
313
365
|
return this.com.sendMessageToMap({
|
|
314
366
|
type: "getToc",
|
|
315
367
|
sessionToken: this.sessionToken,
|
|
316
|
-
});
|
|
317
|
-
}
|
|
368
|
+
});
|
|
369
|
+
};
|
|
318
370
|
|
|
319
|
-
setDebug = (what) =>{
|
|
320
|
-
if(!isNaN(parseInt(what))){
|
|
371
|
+
setDebug = (what) => {
|
|
372
|
+
if (!isNaN(parseInt(what))) {
|
|
321
373
|
this.com.sendMessageToMap({
|
|
322
374
|
type: "setDebug",
|
|
323
375
|
what: what,
|
|
324
376
|
sessionToken: this.sessionToken,
|
|
325
377
|
});
|
|
326
|
-
}else{
|
|
378
|
+
} else {
|
|
327
379
|
console.error("Debug is not a integer");
|
|
328
380
|
}
|
|
329
|
-
}
|
|
381
|
+
};
|
|
330
382
|
|
|
331
|
-
setCustomColors = (properties)=>{
|
|
383
|
+
setCustomColors = (properties) => {
|
|
332
384
|
//validate data
|
|
333
|
-
if(typeof properties!==
|
|
385
|
+
if (typeof properties !== "object") {
|
|
334
386
|
console.error("properties is not an object");
|
|
335
387
|
return;
|
|
336
388
|
}
|
|
337
|
-
if(properties.hasOwnProperty(
|
|
338
|
-
if(isNaN(parseInt(properties.geom_stroke_width))){
|
|
389
|
+
if (properties.hasOwnProperty("geom_stroke_width")) {
|
|
390
|
+
if (isNaN(parseInt(properties.geom_stroke_width))) {
|
|
339
391
|
console.error("geom_stroke_width is not an number");
|
|
340
392
|
return;
|
|
341
|
-
}else{
|
|
393
|
+
} else {
|
|
342
394
|
properties.geom_stroke_width = parseInt(properties.geom_stroke_width);
|
|
343
395
|
}
|
|
344
|
-
}else{
|
|
396
|
+
} else {
|
|
345
397
|
properties.geom_stroke_width = 1;
|
|
346
398
|
}
|
|
347
|
-
if(properties.hasOwnProperty(
|
|
348
|
-
if(isNaN(parseInt(properties.geom_radius))){
|
|
399
|
+
if (properties.hasOwnProperty("geom_radius")) {
|
|
400
|
+
if (isNaN(parseInt(properties.geom_radius))) {
|
|
349
401
|
console.error("geom_stroke_width is not an number");
|
|
350
402
|
return;
|
|
351
|
-
}else{
|
|
403
|
+
} else {
|
|
352
404
|
properties.geom_radius = parseInt(properties.geom_radius);
|
|
353
405
|
}
|
|
354
|
-
}else{
|
|
406
|
+
} else {
|
|
355
407
|
properties.geom_radius = 4;
|
|
356
408
|
}
|
|
357
409
|
|
|
358
|
-
if(properties.hasOwnProperty(
|
|
359
|
-
if(
|
|
360
|
-
properties.geom_shape
|
|
410
|
+
if (properties.hasOwnProperty("geom_shape")) {
|
|
411
|
+
if (
|
|
412
|
+
properties.geom_shape !== "circle" &&
|
|
413
|
+
properties.geom_shape !== "square"
|
|
414
|
+
) {
|
|
415
|
+
properties.geom_shape = "circle";
|
|
361
416
|
console.error("geom_shape must be either 'circle' or 'square'");
|
|
362
417
|
}
|
|
363
418
|
}
|
|
364
419
|
this.com.sendMessageToMap({
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
420
|
+
type: "setCustomColors",
|
|
421
|
+
properties: properties,
|
|
422
|
+
sessionToken: this.sessionToken,
|
|
368
423
|
});
|
|
369
|
-
}
|
|
424
|
+
};
|
|
370
425
|
|
|
371
|
-
changeBackground = (newBackground)=>{
|
|
426
|
+
changeBackground = (newBackground) => {
|
|
372
427
|
return this.com.sendMessageToMap({
|
|
373
428
|
type: "changeBackground",
|
|
374
429
|
sessionToken: this.sessionToken,
|
|
375
|
-
newBackground: newBackground
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
|
|
430
|
+
newBackground: newBackground,
|
|
431
|
+
});
|
|
432
|
+
};
|
|
379
433
|
}
|
|
380
434
|
|
|
381
|
-
export {
|
|
382
|
-
Communicator,
|
|
383
|
-
}
|
|
435
|
+
export { Communicator };
|