@vidro/map-handler 1.1.4 → 1.1.15
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +39 -101
- package/dist/map-handler.js +1 -1
- package/examples/full/cachedToken.dat +1 -1
- package/examples/full/cachedTokenData.dat +1 -1
- package/examples/full/index.php +9 -78
- package/examples/full/tester.js +12 -177
- package/examples/serverLess/dist/index.23420cfa.js +117 -120
- package/examples/serverLess/dist/index.23420cfa.js.map +1 -1
- package/examples/serverLess/dist/index.html +1 -38
- package/examples/serverLess/index.html +1 -2
- package/examples/serverLess/main.js +2 -2
- package/examples/simple/index.html +1 -1
- package/examples/taigua/index.html +46 -8
- package/examples/taigua/main.js +467 -18
- package/examples/vidromap/index.php +1 -1
- package/package.json +1 -1
- package/src/index.js +178 -321
- package/examples/externalwms/index.js +0 -20
- package/examples/externalwms/index.php +0 -88
- package/examples/integration/tool/css/dist/home.css.min.css +0 -0
- package/examples/integration/tool/css/dist/home.min.css +0 -1
- package/examples/integration/tool/css/dist/home.min.css.map +0 -10
- package/examples/integration/tool/css/dist/style-login.css.min.css +0 -0
- package/examples/integration/tool/css/dist/style-login.min.css +0 -1
- package/examples/integration/tool/css/dist/style-login.min.css.map +0 -10
- package/examples/integration/tool/css/dist/style.css.min.css +0 -0
- package/examples/integration/tool/css/dist/style.min.css +0 -1
- package/examples/integration/tool/css/dist/style.min.css.map +0 -23
- package/examples/integration/tool/css/master/_bottom-sheet-2.scss +0 -103
- package/examples/integration/tool/css/master/_bottom-sheet.scss +0 -142
- package/examples/integration/tool/css/master/_colors.scss +0 -35
- package/examples/integration/tool/css/master/_dropdown-form.scss +0 -167
- package/examples/integration/tool/css/master/_forms.scss +0 -416
- package/examples/integration/tool/css/master/_header.scss +0 -134
- package/examples/integration/tool/css/master/_menu-toc.scss +0 -135
- package/examples/integration/tool/css/master/_menu-tools.scss +0 -187
- package/examples/integration/tool/css/master/_mixins.scss +0 -42
- package/examples/integration/tool/css/master/_notifyjs.scss +0 -39
- package/examples/integration/tool/css/master/_ol-map-controls.scss +0 -117
- package/examples/integration/tool/css/master/_simplelightbox.scss +0 -287
- package/examples/integration/tool/css/master/_toc-config.scss +0 -28
- package/examples/integration/tool/css/master/_toc-layouts.scss +0 -173
- package/examples/integration/tool/css/master/_tooltip.scss +0 -34
- package/examples/integration/tool/css/master/home.scss +0 -266
- package/examples/integration/tool/css/master/style-login.scss +0 -240
- package/examples/integration/tool/css/master/style.scss +0 -166
- package/examples/integration/tool/img/doc-gallery-placeholder.svg +0 -3
- package/examples/integration/tool/img/home/ic_calendar-clock.svg +0 -1
- package/examples/integration/tool/img/home/ic_caret-down.svg +0 -1
- package/examples/integration/tool/img/home/ic_cog.svg +0 -1
- package/examples/integration/tool/img/home/ic_marker.svg +0 -1
- package/examples/integration/tool/img/home/ic_play-circle.svg +0 -1
- package/examples/integration/tool/img/home/ic_power.svg +0 -1
- package/examples/integration/tool/img/home/ic_squares.svg +0 -1
- package/examples/integration/tool/img/home/ic_user-pointer.svg +0 -1
- package/examples/integration/tool/img/home/ic_user-square.svg +0 -1
- package/examples/integration/tool/img/home/logo_footer.svg +0 -1
- package/examples/integration/tool/img/ic/accessControl.svg +0 -1
- package/examples/integration/tool/img/ic/account-location.svg +0 -1
- package/examples/integration/tool/img/ic/actionDelete.svg +0 -64
- package/examples/integration/tool/img/ic/actionOpen.svg +0 -64
- package/examples/integration/tool/img/ic/addFile.svg +0 -100
- package/examples/integration/tool/img/ic/addFile_off.svg +0 -102
- package/examples/integration/tool/img/ic/arrow-left.svg +0 -1
- package/examples/integration/tool/img/ic/arrow-right-drop-circle-outline.svg +0 -1
- package/examples/integration/tool/img/ic/bt_add_photo.svg +0 -3
- package/examples/integration/tool/img/ic/bug.svg +0 -1
- package/examples/integration/tool/img/ic/caret-down-bottomsheet.svg +0 -3
- package/examples/integration/tool/img/ic/checkbox-blank-outline-grey.svg +0 -8
- package/examples/integration/tool/img/ic/checkbox-blank-outline-white.svg +0 -8
- package/examples/integration/tool/img/ic/checkbox-blank-outline.svg +0 -1
- package/examples/integration/tool/img/ic/checkbox-marked-outline-grey.svg +0 -8
- package/examples/integration/tool/img/ic/checkbox-marked-outline-white.svg +0 -8
- package/examples/integration/tool/img/ic/checkbox-marked-outline.svg +0 -1
- package/examples/integration/tool/img/ic/chevron-down-grey.svg +0 -7
- package/examples/integration/tool/img/ic/chevron-down-white.svg +0 -7
- package/examples/integration/tool/img/ic/chevron-down.svg +0 -1
- package/examples/integration/tool/img/ic/chevron-right-grey.svg +0 -7
- package/examples/integration/tool/img/ic/chevron-right-white.svg +0 -7
- package/examples/integration/tool/img/ic/chevron-right.svg +0 -1
- package/examples/integration/tool/img/ic/comment-text-outline.svg +0 -1
- package/examples/integration/tool/img/ic/cookie.svg +0 -1
- package/examples/integration/tool/img/ic/delete.svg +0 -1
- package/examples/integration/tool/img/ic/dot.svg +0 -1
- package/examples/integration/tool/img/ic/dump.svg +0 -1
- package/examples/integration/tool/img/ic/e.svg +0 -9
- package/examples/integration/tool/img/ic/eye-off.svg +0 -1
- package/examples/integration/tool/img/ic/eye.svg +0 -1
- package/examples/integration/tool/img/ic/forbidden.svg +0 -1
- package/examples/integration/tool/img/ic/form-title-1.svg +0 -3
- package/examples/integration/tool/img/ic/group.svg +0 -1
- package/examples/integration/tool/img/ic/hamburger.svg +0 -1
- package/examples/integration/tool/img/ic/ic-users.svg +0 -1
- package/examples/integration/tool/img/ic/ic_dropdown-form-close.svg +0 -3
- package/examples/integration/tool/img/ic/ic_dropdown-form-link.svg +0 -3
- package/examples/integration/tool/img/ic/ic_feature-edit-cancel.svg +0 -14
- package/examples/integration/tool/img/ic/ic_feature-edit-save.svg +0 -14
- package/examples/integration/tool/img/ic/ic_gallery-item-delete.svg +0 -3
- package/examples/integration/tool/img/ic/ic_gallery-item-view.svg +0 -3
- package/examples/integration/tool/img/ic/ic_gps.svg +0 -3
- package/examples/integration/tool/img/ic/ic_search.svg +0 -5
- package/examples/integration/tool/img/ic/ic_selector_fechas.svg +0 -63
- package/examples/integration/tool/img/ic/ic_zoom-to-extent.svg +0 -3
- package/examples/integration/tool/img/ic/icon_reminder.png +0 -0
- package/examples/integration/tool/img/ic/image-gallery-placeholder.svg +0 -55
- package/examples/integration/tool/img/ic/imaqua.svg +0 -87
- package/examples/integration/tool/img/ic/incidencia.svg +0 -77
- package/examples/integration/tool/img/ic/info_multi_selection.svg +0 -230
- package/examples/integration/tool/img/ic/layers.svg +0 -1
- package/examples/integration/tool/img/ic/map-marker.svg +0 -3
- package/examples/integration/tool/img/ic/map.svg +0 -1
- package/examples/integration/tool/img/ic/measure_area.svg +0 -111
- package/examples/integration/tool/img/ic/minus.svg +0 -7
- package/examples/integration/tool/img/ic/notification.svg +0 -1
- package/examples/integration/tool/img/ic/offline.svg +0 -3
- package/examples/integration/tool/img/ic/online.svg +0 -1
- package/examples/integration/tool/img/ic/pencil.svg +0 -3
- package/examples/integration/tool/img/ic/plus.svg +0 -1
- package/examples/integration/tool/img/ic/polygon_selection.svg +0 -68
- package/examples/integration/tool/img/ic/power.svg +0 -1
- package/examples/integration/tool/img/ic/remoteLocalized.svg +0 -4
- package/examples/integration/tool/img/ic/remoteStartLocalize.svg +0 -4
- package/examples/integration/tool/img/ic/ruler.svg +0 -125
- package/examples/integration/tool/img/ic/selection-plus.svg +0 -10
- package/examples/integration/tool/img/ic/selection.svg +0 -1
- package/examples/integration/tool/img/ic/settings.svg +0 -1
- package/examples/integration/tool/img/ic/sort.svg +0 -1
- package/examples/integration/tool/img/ic/sort_asc.svg +0 -1
- package/examples/integration/tool/img/ic/sort_desc.svg +0 -1
- package/examples/integration/tool/img/ic/spreadsheet.svg +0 -3
- package/examples/integration/tool/img/ic/times.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/AB3.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/AB4.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/IC1.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB1.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB11.svg +0 -5
- package/examples/integration/tool/img/ic/toolbar/TB2.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB20.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB21.svg +0 -54
- package/examples/integration/tool/img/ic/toolbar/TB3.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB31.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB32.svg +0 -57
- package/examples/integration/tool/img/ic/toolbar/TB4.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB5.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB6.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB7.svg +0 -1
- package/examples/integration/tool/img/ic/toolbar/TB8.svg +0 -1
- package/examples/integration/tool/img/ic/tools.svg +0 -28
- package/examples/integration/tool/img/ic/user.svg +0 -1
- package/examples/integration/tool/img/ic/vector-polygon.svg +0 -1
- package/examples/integration/tool/img/ic/visit_manager.svg +0 -135
- package/examples/integration/tool/img/logo-footer-login.png +0 -0
- package/examples/integration/tool/img/logo-footer.png +0 -0
- package/examples/integration/tool/img/logo-header-login.png +0 -0
- package/examples/integration/tool/img/logo-header-login@2x.png +0 -0
- package/examples/integration/tool/img/logo-header-login@3x.png +0 -0
- package/examples/integration/tool/img/logo-header.png +0 -0
- package/examples/integration/tool/img/logo-header@2x.png +0 -0
- package/examples/integration/tool/img/logo-header@3x.png +0 -0
- package/examples/integration/tool/img/logo_project.png +0 -0
- package/examples/integration/tool/img/photo-gallery-placeholder.svg +0 -3
- package/examples/integration/tool/img/pixel.png +0 -0
- package/examples/integration/tool/index.html +0 -228
- package/examples/integration/tool/js/demo.js +0 -238
- package/examples/integration/tool/js/interface.js +0 -147
- package/examples/integration/tool/js/jquery.js +0 -4
- package/examples/integration/vanguardia.html +0 -6636
- package/examples/taigua/global.css +0 -10
- package/examples/xavi/index.html +0 -37
- package/examples/xavi/main.js +0 -168
package/src/index.js
CHANGED
@@ -1,220 +1,146 @@
|
|
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
|
-
|
4
|
+
|
5
|
+
constructor(data){
|
5
6
|
super();
|
6
|
-
this.domId =
|
7
|
-
if
|
7
|
+
this.domId = 'map-frame';
|
8
|
+
if(typeof window === 'undefined'){
|
8
9
|
return;
|
9
|
-
}
|
10
|
-
if
|
10
|
+
};
|
11
|
+
if(typeof data.id==="string"){
|
11
12
|
this.domId = data.id;
|
12
|
-
}
|
13
|
-
this.com = new iframeCommunicator(data)
|
14
|
-
window.addEventListener("message",
|
13
|
+
}
|
14
|
+
this.com = new iframeCommunicator(data)
|
15
|
+
window.addEventListener("message", e => this.onMessageReceived(e));
|
15
16
|
this.sessionToken = data.sessionToken;
|
16
|
-
this.setMaxListeners(100);
|
17
17
|
}
|
18
18
|
|
19
|
-
onMessageReceived =
|
20
|
-
switch
|
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
|
-
case "
|
40
|
-
this.emitEvent("error", e.data, e.data.domId);
|
41
|
-
break;
|
42
|
-
case "coordinates":
|
43
|
-
this.emitEvent("coordinates", e.data, e.data.domId);
|
44
|
-
break;
|
45
|
-
case "activeLayer":
|
46
|
-
this.emitEvent("activeLayer", e.data, e.data.domId);
|
47
|
-
break;
|
48
|
-
case "geolocation":
|
49
|
-
this.emitEvent("geolocation", e.data, e.data.domId);
|
50
|
-
break;
|
51
|
-
case "WMSInfoAvailable":
|
52
|
-
this.emitEvent("WMSInfoAvailable", e.data, e.data.domId);
|
53
|
-
break;
|
54
|
-
case "giswaterTiledBackgroundDisplayed":
|
55
|
-
this.emitEvent(
|
56
|
-
"giswaterTiledBackgroundDisplayed",
|
57
|
-
e.data,
|
58
|
-
e.data.domId
|
59
|
-
);
|
60
|
-
break;
|
61
|
-
case "giswaterTiledBackgroundAvailable":
|
62
|
-
this.emitEvent(
|
63
|
-
"giswaterTiledBackgroundAvailable",
|
64
|
-
e.data,
|
65
|
-
e.data.domId
|
66
|
-
);
|
67
|
-
break;
|
68
|
-
case "GiswaterLayerAvailableFilters":
|
69
|
-
this.emitEvent("GiswaterLayerAvailableFilters", e.data, e.data.domId);
|
70
|
-
break;
|
71
|
-
case "loaded":
|
72
|
-
this.emitEvent("loaded", e.data, e.data.domId);
|
73
|
-
break;
|
74
|
-
case "availableWMSLayers":
|
75
|
-
this.emitEvent("availableWMSLayers", e.data, e.data.domId);
|
76
|
-
break;
|
77
|
-
case "layerElements":
|
78
|
-
this.emitEvent("layerElements", e.data, e.data.domId);
|
79
|
-
break;
|
80
|
-
case "getToc":
|
81
|
-
this.emitEvent("getToc", e.data, e.data.domId);
|
82
|
-
break;
|
83
|
-
case "capabilities":
|
84
|
-
this.emitEvent("capabilities", e.data, e.data.domId);
|
85
|
-
break;
|
86
|
-
case "GiswaterFiltersApplied":
|
87
|
-
this.emitEvent("GiswaterFiltersApplied", e.data, e.data.domId);
|
88
|
-
break;
|
89
|
-
case "MeasureEnd":
|
90
|
-
this.emitEvent("MeasureEnd", e.data, e.data.domId);
|
91
|
-
break;
|
92
|
-
case "MeasureStart":
|
93
|
-
this.emitEvent("MeasureStart", e.data, e.data.domId);
|
94
|
-
break;
|
19
|
+
onMessageReceived = e => {
|
20
|
+
switch(e.data.type){
|
21
|
+
case "onZoomChange": this.emitEvent("onZoomChange", e.data.zoom,e.data.domId); break;
|
22
|
+
case "geomAdded": this.emitEvent("geomAdded", e.data.geom_astext,e.data.domId); break;
|
23
|
+
case "layers": this.emitEvent("layers", e.data.layers,e.data.domId); break;
|
24
|
+
case "geoJSONlayers": this.emitEvent("geoJSONlayers", e.data.layers,e.data.domId); break;
|
25
|
+
case "info": this.emitEvent("info", e.data,e.data.domId); break;
|
26
|
+
case "error": this.emitEvent("error", e.data,e.data.domId); break;
|
27
|
+
case "coordinates": this.emitEvent("coordinates", e.data,e.data.domId); break;
|
28
|
+
case "activeLayer": this.emitEvent("activeLayer", e.data,e.data.domId); break;
|
29
|
+
case "geolocation": this.emitEvent("geolocation", e.data,e.data.domId); break;
|
30
|
+
case "WMSInfoAvailable": this.emitEvent("WMSInfoAvailable", e.data,e.data.domId); break;
|
31
|
+
case "giswaterTiledBackgroundDisplayed": this.emitEvent("giswaterTiledBackgroundDisplayed", e.data,e.data.domId); break;
|
32
|
+
case "giswaterTiledBackgroundAvailable": this.emitEvent("giswaterTiledBackgroundAvailable", e.data,e.data.domId); break;
|
33
|
+
case "GiswaterLayerAvailableFilters": this.emitEvent("GiswaterLayerAvailableFilters", e.data,e.data.domId); break;
|
34
|
+
case "loaded": this.emitEvent("loaded", e.data,e.data.domId); break;
|
35
|
+
case "unloaded": this.emitEvent("unloaded", e.data,e.data.domId); break;
|
36
|
+
case "availableWMSLayers": this.emitEvent("availableWMSLayers", e.data.layers,e.data.domId); break;
|
37
|
+
case "layerElements": this.emitEvent("layerElements", e.data,e.data.domId); break;
|
38
|
+
case "getToc": this.emitEvent("getToc", e.data,e.data.domId); break;
|
39
|
+
//case "getLegend": this.emitEvent("getLegend", e.data,e.data.domId); break;
|
95
40
|
}
|
96
|
-
|
41
|
+
|
42
|
+
}
|
97
43
|
|
98
|
-
emitEvent = (type,
|
99
|
-
if
|
44
|
+
emitEvent = (type,data,domId)=>{
|
45
|
+
if(domId===this.domId){
|
100
46
|
delete data.domId;
|
101
|
-
this.emit(type, data);
|
47
|
+
this.emit(type, data);
|
102
48
|
}
|
103
|
-
}
|
49
|
+
}
|
104
50
|
|
105
51
|
ZoomIn = () => {
|
106
52
|
this.com.sendMessageToMap({
|
107
53
|
type: "zoomIn",
|
108
54
|
sessionToken: this.sessionToken,
|
109
|
-
});
|
110
|
-
};
|
55
|
+
});
|
111
56
|
|
57
|
+
}
|
58
|
+
|
112
59
|
ZoomOut = () => {
|
113
60
|
this.com.sendMessageToMap({
|
114
61
|
type: "zoomOut",
|
115
62
|
sessionToken: this.sessionToken,
|
116
|
-
});
|
117
|
-
}
|
63
|
+
});
|
64
|
+
}
|
118
65
|
|
119
66
|
AddGeom = (geomtype) => {
|
120
67
|
this.com.sendMessageToMap({
|
121
68
|
type: "AddGeom",
|
122
69
|
geom: geomtype,
|
123
70
|
sessionToken: this.sessionToken,
|
124
|
-
});
|
125
|
-
}
|
71
|
+
});
|
72
|
+
}
|
126
73
|
|
127
|
-
toggleLayer = (layer,
|
128
|
-
if
|
74
|
+
toggleLayer = (layer,properties) => {
|
75
|
+
if(typeof properties==='undefined'){
|
129
76
|
properties = {
|
130
77
|
gutter: null,
|
131
78
|
transparent: null,
|
132
|
-
singletile: null
|
133
|
-
layerType: null,
|
79
|
+
singletile: null
|
134
80
|
};
|
135
81
|
}
|
136
82
|
|
137
|
-
if
|
138
|
-
if
|
139
|
-
properties.layerType !== "wms" &&
|
140
|
-
properties.layerType !== "vector"
|
141
|
-
) {
|
142
|
-
this.emit("error", { error: "layerType must be 'wms' or 'vector'" });
|
143
|
-
return;
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
if (
|
148
|
-
properties.singletile !== null &&
|
149
|
-
properties.layerType !== "vector"
|
150
|
-
) {
|
151
|
-
if (typeof properties.singletile !== "boolean") {
|
83
|
+
if(properties.singletile!==null){
|
84
|
+
if(typeof properties.singletile!=='boolean'){
|
152
85
|
properties.singletile = null;
|
153
|
-
this.emit("error",
|
86
|
+
this.emit("error",{error:"singleTile must be a Boolean"});
|
154
87
|
}
|
155
|
-
}
|
156
|
-
if
|
157
|
-
if
|
88
|
+
}
|
89
|
+
if(properties.gutter!=='' && properties.gutter!==null){
|
90
|
+
if(isNaN(parseInt(properties.gutter))){
|
158
91
|
properties.gutter = null;
|
159
|
-
this.emit("error",
|
92
|
+
this.emit("error",{error:"Gutter must be a number"});
|
160
93
|
}
|
161
|
-
if
|
94
|
+
if(properties.singletile){
|
162
95
|
properties.gutter = null;
|
163
|
-
this.emit("error",
|
164
|
-
error:
|
165
|
-
"Gutter can only be user with multitile layers; set singletile to false",
|
166
|
-
});
|
96
|
+
this.emit("error",{error:"Gutter can only be user with multitile layers; set singletile to false"});
|
167
97
|
}
|
168
|
-
}
|
98
|
+
}
|
169
99
|
|
170
|
-
if
|
171
|
-
|
100
|
+
if(properties.transparent!==null){
|
101
|
+
if(typeof properties.transparent!=='boolean'){
|
172
102
|
properties.transparent = null;
|
173
|
-
this.emit("error",
|
103
|
+
this.emit("error",{error:"transparent must be a Boolean"});
|
174
104
|
}
|
175
|
-
}
|
176
|
-
|
105
|
+
}
|
177
106
|
this.com.sendMessageToMap({
|
178
107
|
type: "toggleLayer",
|
179
108
|
layer: layer,
|
180
|
-
gutter: !isNaN(parseInt(properties.gutter))
|
181
|
-
? parseInt(properties.gutter)
|
182
|
-
: null,
|
109
|
+
gutter: !isNaN(parseInt(properties.gutter)) ? parseInt(properties.gutter) : null,
|
183
110
|
transparent: properties.transparent,
|
184
111
|
singletile: properties.singletile,
|
185
|
-
layerType: properties.layerType,
|
186
112
|
sessionToken: this.sessionToken,
|
187
|
-
});
|
188
|
-
}
|
113
|
+
});
|
114
|
+
}
|
189
115
|
|
190
116
|
setActiveLayer = (layer) => {
|
191
117
|
this.com.sendMessageToMap({
|
192
118
|
type: "setActiveLayer",
|
193
119
|
layer: layer,
|
194
120
|
sessionToken: this.sessionToken,
|
195
|
-
});
|
196
|
-
}
|
121
|
+
});
|
122
|
+
}
|
197
123
|
|
198
124
|
getActiveLayer = () => {
|
199
125
|
this.com.sendMessageToMap({
|
200
126
|
type: "getActiveLayer",
|
201
127
|
sessionToken: this.sessionToken,
|
202
|
-
});
|
203
|
-
}
|
128
|
+
});
|
129
|
+
}
|
204
130
|
|
205
131
|
loadWMSAvailableLayers = () => {
|
206
132
|
this.com.sendMessageToMap({
|
207
133
|
type: "loadWMSAvailableLayers",
|
208
134
|
sessionToken: this.sessionToken,
|
209
|
-
});
|
210
|
-
}
|
135
|
+
});
|
136
|
+
}
|
211
137
|
|
212
138
|
clear = () => {
|
213
139
|
this.com.sendMessageToMap({
|
214
140
|
type: "clear",
|
215
141
|
sessionToken: this.sessionToken,
|
216
|
-
});
|
217
|
-
}
|
142
|
+
});
|
143
|
+
}
|
218
144
|
|
219
145
|
Highlight = (options) => {
|
220
146
|
this.com.sendMessageToMap({
|
@@ -222,39 +148,36 @@ class Communicator extends EventEmitter {
|
|
222
148
|
geom: options.geom,
|
223
149
|
zoom: options.zoom,
|
224
150
|
sessionToken: this.sessionToken,
|
225
|
-
});
|
226
|
-
}
|
151
|
+
});
|
152
|
+
}
|
227
153
|
|
228
154
|
zoomToExtent = () => {
|
229
155
|
this.com.sendMessageToMap({
|
230
156
|
type: "zoomToExtent",
|
231
157
|
sessionToken: this.sessionToken,
|
232
|
-
});
|
233
|
-
}
|
158
|
+
});
|
159
|
+
}
|
234
160
|
|
235
|
-
zoomToCoordinates
|
236
|
-
if
|
161
|
+
zoomToCoordinates= (lat,lon,zoomLevel) => {
|
162
|
+
if(!isNaN(parseInt(zoomLevel))){
|
237
163
|
this.com.sendMessageToMap({
|
238
164
|
type: "zoomToCoordinates",
|
239
165
|
sessionToken: this.sessionToken,
|
240
|
-
coordinates:
|
241
|
-
zoomLevel: zoomLevel
|
242
|
-
});
|
166
|
+
coordinates:[lat,lon],
|
167
|
+
zoomLevel: zoomLevel
|
168
|
+
});
|
243
169
|
}
|
244
|
-
}
|
245
|
-
|
246
|
-
infoFromCoordinates = (type,
|
247
|
-
const _layer = typeof layer
|
248
|
-
const _hitTolerance =
|
249
|
-
|
250
|
-
|
251
|
-
: parseInt(hitTolerance);
|
252
|
-
const _format = typeof format == "undefined" ? "xml" : format.toLowerCase();
|
253
|
-
if (_format !== "xml" && _format !== "json") {
|
170
|
+
}
|
171
|
+
|
172
|
+
infoFromCoordinates = (type,layer,hitTolerance,format) => {
|
173
|
+
const _layer = (typeof layer=='undefined') ? null : layer
|
174
|
+
const _hitTolerance = (typeof hitTolerance=='undefined' || !hitTolerance) ? 5 : parseInt(hitTolerance)
|
175
|
+
const _format = (typeof format=='undefined') ? 'xml' : format.toLowerCase();
|
176
|
+
if(_format!=="xml" && _format!=='json'){
|
254
177
|
console.error("Format must be 'xml' or 'json");
|
255
178
|
return;
|
256
179
|
}
|
257
|
-
if
|
180
|
+
if(isNaN(_hitTolerance)){
|
258
181
|
console.error("hitTolerance must be a number");
|
259
182
|
return;
|
260
183
|
}
|
@@ -265,262 +188,196 @@ class Communicator extends EventEmitter {
|
|
265
188
|
format: _format,
|
266
189
|
hitTolerance: _hitTolerance,
|
267
190
|
sessionToken: this.sessionToken,
|
268
|
-
});
|
269
|
-
}
|
191
|
+
});
|
192
|
+
}
|
270
193
|
|
271
|
-
getElementsFromLayer
|
272
|
-
const _format = typeof format
|
273
|
-
if
|
194
|
+
getElementsFromLayer= (layer,limit,format) => {
|
195
|
+
const _format = (typeof format=='undefined') ? 'xml' : format.toLowerCase();
|
196
|
+
if(_format!=="xml" && _format!=='json'){
|
274
197
|
console.error("Format must be 'xml' or 'json");
|
275
198
|
return;
|
276
199
|
}
|
277
|
-
if
|
278
|
-
|
200
|
+
if(isNaN(limit)){
|
201
|
+
console.error("Limit must be a number");
|
279
202
|
return;
|
280
203
|
}
|
281
|
-
const _layer = typeof layer
|
204
|
+
const _layer = (typeof layer=='undefined') ? null : layer
|
282
205
|
this.com.sendMessageToMap({
|
283
206
|
type: "getElementsFromLayer",
|
284
207
|
layer: _layer,
|
285
|
-
limit: typeof limit
|
208
|
+
limit: (typeof limit!='undefined') ? parseInt(limit) : 100,
|
286
209
|
format: format,
|
287
210
|
sessionToken: this.sessionToken,
|
288
|
-
});
|
289
|
-
}
|
211
|
+
});
|
212
|
+
}
|
290
213
|
|
291
214
|
Geolocalize = (toggle) => {
|
292
215
|
this.com.sendMessageToMap({
|
293
216
|
type: "Geolocalize",
|
294
217
|
toggle: toggle,
|
295
218
|
sessionToken: this.sessionToken,
|
296
|
-
});
|
297
|
-
}
|
219
|
+
});
|
220
|
+
}
|
298
221
|
|
299
|
-
toggleGiswaterTiled = (toggle,
|
222
|
+
toggleGiswaterTiled = (toggle,tiled) => {
|
300
223
|
this.com.sendMessageToMap({
|
301
224
|
type: "toggleGiswaterTiled",
|
302
225
|
toggle: toggle,
|
303
226
|
tiled: tiled,
|
304
227
|
sessionToken: this.sessionToken,
|
305
|
-
});
|
306
|
-
}
|
228
|
+
});
|
229
|
+
}
|
307
230
|
|
308
|
-
reloadDisplayedLayers = ()
|
231
|
+
reloadDisplayedLayers = ()=>{
|
309
232
|
return this.com.sendMessageToMap({
|
310
233
|
type: "reloadDisplayedLayers",
|
311
234
|
sessionToken: this.sessionToken,
|
312
|
-
});
|
313
|
-
}
|
235
|
+
});
|
236
|
+
}
|
314
237
|
|
315
|
-
addGeoJSON = (geoJSON,
|
316
|
-
if
|
238
|
+
addGeoJSON = (geoJSON,options, name)=>{
|
239
|
+
if(geoJSON){
|
317
240
|
return this.com.sendMessageToMap({
|
318
241
|
type: "addGeoJSON",
|
319
242
|
geoJSON: geoJSON,
|
320
|
-
options:
|
321
|
-
|
322
|
-
? options
|
323
|
-
: { fillcolor: null, strokecolor: null },
|
324
|
-
name: name ? name : Math.random().toString(36).substring(7),
|
243
|
+
options: (typeof options!='undefined') ? options : {fillcolor:null,strokecolor:null},
|
244
|
+
name: name ? name: Math.random().toString(36).substring(7),
|
325
245
|
sessionToken: this.sessionToken,
|
326
|
-
});
|
327
|
-
}
|
328
|
-
this.emit("error",
|
246
|
+
});
|
247
|
+
}else{
|
248
|
+
this.emit("error",{error:"No geoJSON data"});
|
329
249
|
return;
|
330
250
|
}
|
331
|
-
}
|
251
|
+
}
|
332
252
|
|
333
|
-
|
253
|
+
clearGeoJSON = ()=>{
|
334
254
|
return this.com.sendMessageToMap({
|
335
255
|
type: "clearGeoJSON",
|
336
256
|
sessionToken: this.sessionToken,
|
337
|
-
});
|
338
|
-
}
|
257
|
+
});
|
258
|
+
}
|
339
259
|
|
340
|
-
|
341
|
-
if
|
260
|
+
removeGeoJSONLayer = (name)=>{
|
261
|
+
if(name){
|
342
262
|
return this.com.sendMessageToMap({
|
343
263
|
type: "removeGeoJSONLayer",
|
344
264
|
name: name,
|
345
265
|
sessionToken: this.sessionToken,
|
346
|
-
});
|
347
|
-
}
|
348
|
-
this.emit("error",
|
266
|
+
});
|
267
|
+
}else{
|
268
|
+
this.emit("error",{error:"No geoJSON data"});
|
349
269
|
return;
|
350
270
|
}
|
351
|
-
}
|
352
|
-
|
353
|
-
setGiswaterFilters = (filters)
|
271
|
+
}
|
272
|
+
|
273
|
+
setGiswaterFilters = (filters)=>{
|
354
274
|
var filtersJson = filters;
|
355
|
-
if
|
356
|
-
if
|
357
|
-
filters = filters.trim()
|
358
|
-
filters = filters.replace(/^\s+|\s+$/g,
|
359
|
-
filters = filters.replace(/\\/g,
|
360
|
-
try
|
361
|
-
filtersJson = JSON.parse(filters);
|
362
|
-
}
|
363
|
-
this.emit("error",
|
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"});
|
364
284
|
return;
|
365
285
|
}
|
366
286
|
}
|
367
|
-
|
287
|
+
|
368
288
|
return this.com.sendMessageToMap({
|
369
289
|
type: "setGiswaterFilters",
|
370
290
|
filters: filtersJson,
|
371
291
|
sessionToken: this.sessionToken,
|
372
|
-
});
|
373
|
-
}
|
374
|
-
this.emit("error",
|
292
|
+
});
|
293
|
+
}else{
|
294
|
+
this.emit("error",{error:"No filters"});
|
375
295
|
return;
|
376
296
|
}
|
377
|
-
}
|
297
|
+
}
|
378
298
|
|
379
|
-
getGiswaterLayerAvailableFilters = (layer_name)
|
380
|
-
if
|
381
|
-
|
299
|
+
getGiswaterLayerAvailableFilters = (layer_name)=>{
|
300
|
+
if(layer_name){
|
301
|
+
return this.com.sendMessageToMap({
|
382
302
|
type: "getGiswaterLayerAvailableFilters",
|
383
303
|
name: layer_name,
|
384
304
|
sessionToken: this.sessionToken,
|
385
|
-
});
|
386
|
-
}
|
387
|
-
this.emit("error",
|
305
|
+
});
|
306
|
+
}else{
|
307
|
+
this.emit("error",{error:"No layer_name"});
|
388
308
|
return;
|
389
309
|
}
|
390
|
-
}
|
310
|
+
}
|
391
311
|
|
392
|
-
getToc = ()
|
312
|
+
getToc = ()=>{
|
393
313
|
return this.com.sendMessageToMap({
|
394
314
|
type: "getToc",
|
395
315
|
sessionToken: this.sessionToken,
|
396
|
-
});
|
397
|
-
}
|
316
|
+
});
|
317
|
+
}
|
398
318
|
|
399
|
-
setDebug = (what) =>
|
400
|
-
if
|
319
|
+
setDebug = (what) =>{
|
320
|
+
if(!isNaN(parseInt(what))){
|
401
321
|
this.com.sendMessageToMap({
|
402
322
|
type: "setDebug",
|
403
323
|
what: what,
|
404
324
|
sessionToken: this.sessionToken,
|
405
325
|
});
|
406
|
-
}
|
326
|
+
}else{
|
407
327
|
console.error("Debug is not a integer");
|
408
328
|
}
|
409
|
-
}
|
329
|
+
}
|
410
330
|
|
411
|
-
setCustomColors = (properties)
|
331
|
+
setCustomColors = (properties)=>{
|
412
332
|
//validate data
|
413
|
-
if
|
333
|
+
if(typeof properties!=='object'){
|
414
334
|
console.error("properties is not an object");
|
415
335
|
return;
|
416
336
|
}
|
417
|
-
if
|
418
|
-
if
|
337
|
+
if(properties.hasOwnProperty('geom_stroke_width')){
|
338
|
+
if(isNaN(parseInt(properties.geom_stroke_width))){
|
419
339
|
console.error("geom_stroke_width is not an number");
|
420
340
|
return;
|
421
|
-
}
|
341
|
+
}else{
|
422
342
|
properties.geom_stroke_width = parseInt(properties.geom_stroke_width);
|
423
343
|
}
|
424
|
-
}
|
344
|
+
}else{
|
425
345
|
properties.geom_stroke_width = 1;
|
426
346
|
}
|
427
|
-
if
|
428
|
-
if
|
347
|
+
if(properties.hasOwnProperty('geom_radius')){
|
348
|
+
if(isNaN(parseInt(properties.geom_radius))){
|
429
349
|
console.error("geom_stroke_width is not an number");
|
430
350
|
return;
|
431
|
-
}
|
351
|
+
}else{
|
432
352
|
properties.geom_radius = parseInt(properties.geom_radius);
|
433
353
|
}
|
434
|
-
}
|
354
|
+
}else{
|
435
355
|
properties.geom_radius = 4;
|
436
356
|
}
|
437
357
|
|
438
|
-
if
|
439
|
-
if
|
440
|
-
properties.geom_shape
|
441
|
-
properties.geom_shape !== "square"
|
442
|
-
) {
|
443
|
-
properties.geom_shape = "circle";
|
358
|
+
if(properties.hasOwnProperty('geom_shape')){
|
359
|
+
if(properties.geom_shape!=="circle" && properties.geom_shape!=="square"){
|
360
|
+
properties.geom_shape = 'circle';
|
444
361
|
console.error("geom_shape must be either 'circle' or 'square'");
|
445
362
|
}
|
446
363
|
}
|
447
364
|
this.com.sendMessageToMap({
|
448
|
-
|
449
|
-
|
450
|
-
|
365
|
+
type: "setCustomColors",
|
366
|
+
properties: properties,
|
367
|
+
sessionToken: this.sessionToken,
|
451
368
|
});
|
452
|
-
}
|
369
|
+
}
|
453
370
|
|
454
|
-
changeBackground = (newBackground)
|
371
|
+
changeBackground = (newBackground)=>{
|
455
372
|
return this.com.sendMessageToMap({
|
456
373
|
type: "changeBackground",
|
457
374
|
sessionToken: this.sessionToken,
|
458
|
-
newBackground: newBackground
|
459
|
-
});
|
460
|
-
};
|
461
|
-
|
462
|
-
centerMap = (coordinates) => {
|
463
|
-
//validate data
|
464
|
-
if (typeof coordinates !== "object") {
|
465
|
-
console.error("properties is not an object");
|
466
|
-
return;
|
467
|
-
}
|
468
|
-
return this.com.sendMessageToMap({
|
469
|
-
type: "centerMap",
|
470
|
-
sessionToken: this.sessionToken,
|
471
|
-
coordinates: coordinates,
|
472
|
-
});
|
473
|
-
};
|
474
|
-
|
475
|
-
drawGeometryInLayer = (uuid, layerName, geom_astext, label, style) => {
|
476
|
-
return this.com.sendMessageToMap({
|
477
|
-
type: "drawGeometryInLayer",
|
478
|
-
sessionToken: this.sessionToken,
|
479
|
-
uuid,
|
480
|
-
layerName,
|
481
|
-
geom_astext,
|
482
|
-
label,
|
483
|
-
style,
|
484
|
-
});
|
485
|
-
};
|
486
|
-
|
487
|
-
removeGeometryFromLayer = (uuid, layerName) => {
|
488
|
-
return this.com.sendMessageToMap({
|
489
|
-
type: "removeGeometryFromLayer",
|
490
|
-
sessionToken: this.sessionToken,
|
491
|
-
uuid,
|
492
|
-
layerName,
|
493
|
-
});
|
494
|
-
};
|
495
|
-
|
496
|
-
initMeasure = (type,textStart,textContinue)=>{
|
497
|
-
if(type!=='line' && type!=='area'){
|
498
|
-
console.error( );
|
499
|
-
return;
|
500
|
-
}
|
501
|
-
let text = null;
|
502
|
-
if(textStart && textContinue){
|
503
|
-
|
504
|
-
text = {
|
505
|
-
textStart: textStart,
|
506
|
-
textContinue: textContinue,
|
507
|
-
}
|
508
|
-
}
|
509
|
-
|
510
|
-
return this.com.sendMessageToMap({
|
511
|
-
type: "initMeasure",
|
512
|
-
sessionToken: this.sessionToken,
|
513
|
-
measure: type,
|
514
|
-
text: text ? text: null,
|
515
|
-
});
|
375
|
+
newBackground: newBackground
|
376
|
+
});
|
516
377
|
}
|
517
378
|
|
518
|
-
cancelMeasure= ()=>{
|
519
|
-
return this.com.sendMessageToMap({
|
520
|
-
type: "cancelMeasure",
|
521
|
-
sessionToken: this.sessionToken,
|
522
|
-
});
|
523
|
-
}
|
524
379
|
}
|
525
380
|
|
526
|
-
export {
|
381
|
+
export {
|
382
|
+
Communicator,
|
383
|
+
}
|