@vidro/map-handler 1.0.6 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +187 -10
- package/dist/map-handler.js +1 -1
- package/doc/giswater.png +0 -0
- package/doc/giswaterInfo.png +0 -0
- package/doc/giswaterInfoApi.png +0 -0
- package/doc/giswatergeojson.png +0 -0
- package/doc/multiTile.png +0 -0
- package/doc/multiTileNoGutter.png +0 -0
- package/doc/togglelayergiswater.png +0 -0
- package/doc/vidromaps-basic.png +0 -0
- package/examples/externalwms/index.js +20 -0
- package/examples/externalwms/index.php +88 -0
- package/examples/full/apidemo.js +43 -1
- package/examples/full/cachedToken.dat +1 -1
- package/examples/full/cachedTokenData.dat +1 -1
- package/examples/full/index.php +31 -16
- package/examples/full/tester.js +172 -12
- package/examples/integration/tool/css/dist/home.css.min.css +0 -0
- package/examples/integration/tool/css/dist/home.min.css +1 -0
- package/examples/integration/tool/css/dist/home.min.css.map +10 -0
- package/examples/integration/tool/css/dist/style-login.css.min.css +0 -0
- package/examples/integration/tool/css/dist/style-login.min.css +1 -0
- package/examples/integration/tool/css/dist/style-login.min.css.map +10 -0
- package/examples/integration/tool/css/dist/style.css.min.css +0 -0
- package/examples/integration/tool/css/dist/style.min.css +1 -0
- package/examples/integration/tool/css/dist/style.min.css.map +23 -0
- package/examples/integration/tool/css/master/_bottom-sheet-2.scss +103 -0
- package/examples/integration/tool/css/master/_bottom-sheet.scss +142 -0
- package/examples/integration/tool/css/master/_colors.scss +35 -0
- package/examples/integration/tool/css/master/_dropdown-form.scss +167 -0
- package/examples/integration/tool/css/master/_forms.scss +416 -0
- package/examples/integration/tool/css/master/_header.scss +134 -0
- package/examples/integration/tool/css/master/_menu-toc.scss +135 -0
- package/examples/integration/tool/css/master/_menu-tools.scss +187 -0
- package/examples/integration/tool/css/master/_mixins.scss +42 -0
- package/examples/integration/tool/css/master/_notifyjs.scss +39 -0
- package/examples/integration/tool/css/master/_ol-map-controls.scss +117 -0
- package/examples/integration/tool/css/master/_simplelightbox.scss +287 -0
- package/examples/integration/tool/css/master/_toc-config.scss +28 -0
- package/examples/integration/tool/css/master/_toc-layouts.scss +173 -0
- package/examples/integration/tool/css/master/_tooltip.scss +34 -0
- package/examples/integration/tool/css/master/home.scss +266 -0
- package/examples/integration/tool/css/master/style-login.scss +240 -0
- package/examples/integration/tool/css/master/style.scss +166 -0
- package/examples/integration/tool/img/doc-gallery-placeholder.svg +3 -0
- package/examples/integration/tool/img/home/ic_calendar-clock.svg +1 -0
- package/examples/integration/tool/img/home/ic_caret-down.svg +1 -0
- package/examples/integration/tool/img/home/ic_cog.svg +1 -0
- package/examples/integration/tool/img/home/ic_marker.svg +1 -0
- package/examples/integration/tool/img/home/ic_play-circle.svg +1 -0
- package/examples/integration/tool/img/home/ic_power.svg +1 -0
- package/examples/integration/tool/img/home/ic_squares.svg +1 -0
- package/examples/integration/tool/img/home/ic_user-pointer.svg +1 -0
- package/examples/integration/tool/img/home/ic_user-square.svg +1 -0
- package/examples/integration/tool/img/home/logo_footer.svg +1 -0
- package/examples/integration/tool/img/ic/accessControl.svg +1 -0
- package/examples/integration/tool/img/ic/account-location.svg +1 -0
- package/examples/integration/tool/img/ic/actionDelete.svg +64 -0
- package/examples/integration/tool/img/ic/actionOpen.svg +64 -0
- package/examples/integration/tool/img/ic/addFile.svg +100 -0
- package/examples/integration/tool/img/ic/addFile_off.svg +102 -0
- package/examples/integration/tool/img/ic/arrow-left.svg +1 -0
- package/examples/integration/tool/img/ic/arrow-right-drop-circle-outline.svg +1 -0
- package/examples/integration/tool/img/ic/bt_add_photo.svg +3 -0
- package/examples/integration/tool/img/ic/bug.svg +1 -0
- package/examples/integration/tool/img/ic/caret-down-bottomsheet.svg +3 -0
- package/examples/integration/tool/img/ic/checkbox-blank-outline-grey.svg +8 -0
- package/examples/integration/tool/img/ic/checkbox-blank-outline-white.svg +8 -0
- package/examples/integration/tool/img/ic/checkbox-blank-outline.svg +1 -0
- package/examples/integration/tool/img/ic/checkbox-marked-outline-grey.svg +8 -0
- package/examples/integration/tool/img/ic/checkbox-marked-outline-white.svg +8 -0
- package/examples/integration/tool/img/ic/checkbox-marked-outline.svg +1 -0
- package/examples/integration/tool/img/ic/chevron-down-grey.svg +7 -0
- package/examples/integration/tool/img/ic/chevron-down-white.svg +7 -0
- package/examples/integration/tool/img/ic/chevron-down.svg +1 -0
- package/examples/integration/tool/img/ic/chevron-right-grey.svg +7 -0
- package/examples/integration/tool/img/ic/chevron-right-white.svg +7 -0
- package/examples/integration/tool/img/ic/chevron-right.svg +1 -0
- package/examples/integration/tool/img/ic/comment-text-outline.svg +1 -0
- package/examples/integration/tool/img/ic/cookie.svg +1 -0
- package/examples/integration/tool/img/ic/delete.svg +1 -0
- package/examples/integration/tool/img/ic/dot.svg +1 -0
- package/examples/integration/tool/img/ic/dump.svg +1 -0
- package/examples/integration/tool/img/ic/e.svg +9 -0
- package/examples/integration/tool/img/ic/eye-off.svg +1 -0
- package/examples/integration/tool/img/ic/eye.svg +1 -0
- package/examples/integration/tool/img/ic/forbidden.svg +1 -0
- package/examples/integration/tool/img/ic/form-title-1.svg +3 -0
- package/examples/integration/tool/img/ic/group.svg +1 -0
- package/examples/integration/tool/img/ic/hamburger.svg +1 -0
- package/examples/integration/tool/img/ic/ic-users.svg +1 -0
- package/examples/integration/tool/img/ic/ic_dropdown-form-close.svg +3 -0
- package/examples/integration/tool/img/ic/ic_dropdown-form-link.svg +3 -0
- package/examples/integration/tool/img/ic/ic_feature-edit-cancel.svg +14 -0
- package/examples/integration/tool/img/ic/ic_feature-edit-save.svg +14 -0
- package/examples/integration/tool/img/ic/ic_gallery-item-delete.svg +3 -0
- package/examples/integration/tool/img/ic/ic_gallery-item-view.svg +3 -0
- package/examples/integration/tool/img/ic/ic_gps.svg +3 -0
- package/examples/integration/tool/img/ic/ic_search.svg +5 -0
- package/examples/integration/tool/img/ic/ic_selector_fechas.svg +63 -0
- package/examples/integration/tool/img/ic/ic_zoom-to-extent.svg +3 -0
- package/examples/integration/tool/img/ic/icon_reminder.png +0 -0
- package/examples/integration/tool/img/ic/image-gallery-placeholder.svg +55 -0
- package/examples/integration/tool/img/ic/imaqua.svg +87 -0
- package/examples/integration/tool/img/ic/incidencia.svg +77 -0
- package/examples/integration/tool/img/ic/info_multi_selection.svg +230 -0
- package/examples/integration/tool/img/ic/layers.svg +1 -0
- package/examples/integration/tool/img/ic/map-marker.svg +3 -0
- package/examples/integration/tool/img/ic/map.svg +1 -0
- package/examples/integration/tool/img/ic/measure_area.svg +111 -0
- package/examples/integration/tool/img/ic/minus.svg +7 -0
- package/examples/integration/tool/img/ic/notification.svg +1 -0
- package/examples/integration/tool/img/ic/offline.svg +3 -0
- package/examples/integration/tool/img/ic/online.svg +1 -0
- package/examples/integration/tool/img/ic/pencil.svg +3 -0
- package/examples/integration/tool/img/ic/plus.svg +1 -0
- package/examples/integration/tool/img/ic/polygon_selection.svg +68 -0
- package/examples/integration/tool/img/ic/power.svg +1 -0
- package/examples/integration/tool/img/ic/remoteLocalized.svg +4 -0
- package/examples/integration/tool/img/ic/remoteStartLocalize.svg +4 -0
- package/examples/integration/tool/img/ic/ruler.svg +125 -0
- package/examples/integration/tool/img/ic/selection-plus.svg +10 -0
- package/examples/integration/tool/img/ic/selection.svg +1 -0
- package/examples/integration/tool/img/ic/settings.svg +1 -0
- package/examples/integration/tool/img/ic/sort.svg +1 -0
- package/examples/integration/tool/img/ic/sort_asc.svg +1 -0
- package/examples/integration/tool/img/ic/sort_desc.svg +1 -0
- package/examples/integration/tool/img/ic/spreadsheet.svg +3 -0
- package/examples/integration/tool/img/ic/times.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/AB3.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/AB4.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/IC1.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB1.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB11.svg +5 -0
- package/examples/integration/tool/img/ic/toolbar/TB2.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB20.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB21.svg +54 -0
- package/examples/integration/tool/img/ic/toolbar/TB3.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB31.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB32.svg +57 -0
- package/examples/integration/tool/img/ic/toolbar/TB4.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB5.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB6.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB7.svg +1 -0
- package/examples/integration/tool/img/ic/toolbar/TB8.svg +1 -0
- package/examples/integration/tool/img/ic/tools.svg +28 -0
- package/examples/integration/tool/img/ic/user.svg +1 -0
- package/examples/integration/tool/img/ic/vector-polygon.svg +1 -0
- package/examples/integration/tool/img/ic/visit_manager.svg +135 -0
- 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 +3 -0
- package/examples/integration/tool/img/pixel.png +0 -0
- package/examples/integration/tool/index.html +228 -0
- package/examples/integration/tool/js/demo.js +238 -0
- package/examples/integration/tool/js/interface.js +147 -0
- package/examples/integration/tool/js/jquery.js +4 -0
- package/examples/integration/vanguardia.html +6636 -0
- package/examples/multipleIframes/index.js +82 -0
- package/examples/multipleIframes/index.php +52 -0
- package/examples/serverLess/dist/index.23420cfa.js +120 -117
- package/examples/serverLess/dist/index.23420cfa.js.map +1 -1
- package/examples/serverLess/dist/index.html +38 -1
- package/examples/serverLess/index.html +2 -1
- package/examples/serverLess/main.js +2 -2
- package/examples/simple/index.html +1 -1
- package/examples/taigua/index.html +15 -0
- package/examples/taigua/main.js +44 -0
- package/examples/vidromap/index.js +12 -79
- package/examples/vidromap/index.php +63 -48
- package/examples/xavi/index.html +37 -0
- package/examples/xavi/main.js +160 -0
- package/flows.md +73 -0
- package/package.json +1 -1
- package/src/index.js +160 -44
- package/src/shared/iframe-communicator.js +12 -5
- package/examples/vidromap/vidromap.js +0 -13
- package/examples/vidromap/vidromap.php +0 -59
package/src/index.js
CHANGED
@@ -1,71 +1,117 @@
|
|
1
1
|
import { EventEmitter } from "events"
|
2
|
-
import {
|
3
|
-
|
2
|
+
import { iframeCommunicator } from "./shared/iframe-communicator";
|
4
3
|
class Communicator extends EventEmitter {
|
5
4
|
|
6
|
-
constructor(
|
5
|
+
constructor(data){
|
7
6
|
super();
|
8
|
-
|
7
|
+
this.domId = 'map-frame';
|
9
8
|
if(typeof window === 'undefined'){
|
10
9
|
return;
|
11
10
|
};
|
12
|
-
|
11
|
+
if(typeof data.id==="string"){
|
12
|
+
this.domId = data.id;
|
13
|
+
}
|
14
|
+
this.com = new iframeCommunicator(data)
|
13
15
|
window.addEventListener("message", e => this.onMessageReceived(e));
|
14
|
-
this.sessionToken = sessionToken;
|
15
|
-
|
16
|
+
this.sessionToken = data.sessionToken;
|
16
17
|
}
|
17
18
|
|
18
19
|
onMessageReceived = e => {
|
19
20
|
switch(e.data.type){
|
20
|
-
case "onZoomChange": this.
|
21
|
-
case "geomAdded": this.
|
22
|
-
case "layers": this.
|
23
|
-
case "geoJSONlayers": this.
|
24
|
-
case "info": this.
|
25
|
-
case "error": this.
|
26
|
-
case "coordinates": this.
|
27
|
-
case "activeLayer": this.
|
28
|
-
case "geolocation": this.
|
29
|
-
case "WMSInfoAvailable": this.
|
30
|
-
case "giswaterTiledBackgroundDisplayed": this.
|
31
|
-
case "giswaterTiledBackgroundAvailable": this.
|
32
|
-
case "GiswaterLayerAvailableFilters": this.
|
33
|
-
case "loaded": this.
|
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 "availableWMSLayers": this.emitEvent("availableWMSLayers", e.data.layers,e.data.domId); break;
|
36
|
+
case "layerElements": this.emitEvent("layerElements", e.data,e.data.domId); break;
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
emitEvent = (type,data,domId)=>{
|
42
|
+
if(domId===this.domId){
|
43
|
+
delete data.domId;
|
44
|
+
this.emit(type, data);
|
34
45
|
}
|
35
46
|
}
|
36
47
|
|
37
48
|
ZoomIn = () => {
|
38
|
-
sendMessageToMap({
|
49
|
+
this.com.sendMessageToMap({
|
39
50
|
type: "zoomIn",
|
40
51
|
sessionToken: this.sessionToken,
|
41
|
-
});
|
52
|
+
});
|
53
|
+
|
42
54
|
}
|
43
55
|
|
44
56
|
ZoomOut = () => {
|
45
|
-
sendMessageToMap({
|
57
|
+
this.com.sendMessageToMap({
|
46
58
|
type: "zoomOut",
|
47
59
|
sessionToken: this.sessionToken,
|
48
60
|
});
|
49
61
|
}
|
50
62
|
|
51
63
|
AddGeom = (geomtype) => {
|
52
|
-
sendMessageToMap({
|
64
|
+
this.com.sendMessageToMap({
|
53
65
|
type: "AddGeom",
|
54
66
|
geom: geomtype,
|
55
67
|
sessionToken: this.sessionToken,
|
56
68
|
});
|
57
69
|
}
|
58
70
|
|
59
|
-
toggleLayer = (layer) => {
|
60
|
-
|
71
|
+
toggleLayer = (layer,properties) => {
|
72
|
+
if(typeof properties==='undefined'){
|
73
|
+
properties = {
|
74
|
+
gutter: null,
|
75
|
+
transparent: null,
|
76
|
+
singletile: null
|
77
|
+
};
|
78
|
+
}
|
79
|
+
|
80
|
+
if(properties.singletile!==null){
|
81
|
+
if(typeof properties.singletile!=='boolean'){
|
82
|
+
properties.singletile = null;
|
83
|
+
this.emit("error",{error:"singleTile must be a Boolean"});
|
84
|
+
}
|
85
|
+
}
|
86
|
+
if(properties.gutter!=='' && properties.gutter!==null){
|
87
|
+
if(isNaN(parseInt(properties.gutter))){
|
88
|
+
properties.gutter = null;
|
89
|
+
this.emit("error",{error:"Gutter must be a number"});
|
90
|
+
}
|
91
|
+
if(properties.singletile){
|
92
|
+
properties.gutter = null;
|
93
|
+
this.emit("error",{error:"Gutter can only be user with multitile layers; set singletile to false"});
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
if(properties.transparent!==null){
|
98
|
+
if(typeof properties.transparent!=='boolean'){
|
99
|
+
properties.transparent = null;
|
100
|
+
this.emit("error",{error:"transparent must be a Boolean"});
|
101
|
+
}
|
102
|
+
}
|
103
|
+
this.com.sendMessageToMap({
|
61
104
|
type: "toggleLayer",
|
62
105
|
layer: layer,
|
106
|
+
gutter: !isNaN(parseInt(properties.gutter)) ? parseInt(properties.gutter) : null,
|
107
|
+
transparent: properties.transparent,
|
108
|
+
singletile: properties.singletile,
|
63
109
|
sessionToken: this.sessionToken,
|
64
110
|
});
|
65
111
|
}
|
66
112
|
|
67
113
|
setActiveLayer = (layer) => {
|
68
|
-
sendMessageToMap({
|
114
|
+
this.com.sendMessageToMap({
|
69
115
|
type: "setActiveLayer",
|
70
116
|
layer: layer,
|
71
117
|
sessionToken: this.sessionToken,
|
@@ -73,21 +119,28 @@ class Communicator extends EventEmitter {
|
|
73
119
|
}
|
74
120
|
|
75
121
|
getActiveLayer = () => {
|
76
|
-
sendMessageToMap({
|
122
|
+
this.com.sendMessageToMap({
|
77
123
|
type: "getActiveLayer",
|
78
124
|
sessionToken: this.sessionToken,
|
79
125
|
});
|
80
126
|
}
|
81
127
|
|
128
|
+
loadWMSAvailableLayers = () => {
|
129
|
+
this.com.sendMessageToMap({
|
130
|
+
type: "loadWMSAvailableLayers",
|
131
|
+
sessionToken: this.sessionToken,
|
132
|
+
});
|
133
|
+
}
|
134
|
+
|
82
135
|
clear = () => {
|
83
|
-
sendMessageToMap({
|
136
|
+
this.com.sendMessageToMap({
|
84
137
|
type: "clear",
|
85
138
|
sessionToken: this.sessionToken,
|
86
139
|
});
|
87
140
|
}
|
88
141
|
|
89
142
|
Highlight = (options) => {
|
90
|
-
sendMessageToMap({
|
143
|
+
this.com.sendMessageToMap({
|
91
144
|
type: "highlight",
|
92
145
|
geom: options.geom,
|
93
146
|
zoom: options.zoom,
|
@@ -96,7 +149,7 @@ class Communicator extends EventEmitter {
|
|
96
149
|
}
|
97
150
|
|
98
151
|
zoomToExtent = () => {
|
99
|
-
sendMessageToMap({
|
152
|
+
this.com.sendMessageToMap({
|
100
153
|
type: "zoomToExtent",
|
101
154
|
sessionToken: this.sessionToken,
|
102
155
|
});
|
@@ -104,7 +157,7 @@ class Communicator extends EventEmitter {
|
|
104
157
|
|
105
158
|
zoomToCoordinates= (lat,lon,zoomLevel) => {
|
106
159
|
if(!isNaN(parseInt(zoomLevel))){
|
107
|
-
sendMessageToMap({
|
160
|
+
this.com.sendMessageToMap({
|
108
161
|
type: "zoomToCoordinates",
|
109
162
|
sessionToken: this.sessionToken,
|
110
163
|
coordinates:[lat,lon],
|
@@ -115,7 +168,7 @@ class Communicator extends EventEmitter {
|
|
115
168
|
|
116
169
|
infoFromCoordinates = (type,layer,hitTolerance) => {
|
117
170
|
const _layer = (typeof layer=='undefined') ? null : layer
|
118
|
-
sendMessageToMap({
|
171
|
+
this.com.sendMessageToMap({
|
119
172
|
type: "infoFromCoordinates",
|
120
173
|
info: type,
|
121
174
|
layer: _layer,
|
@@ -124,8 +177,29 @@ class Communicator extends EventEmitter {
|
|
124
177
|
});
|
125
178
|
}
|
126
179
|
|
180
|
+
getElementsFromLayer= (layer,limit,format) => {
|
181
|
+
const _format = (typeof format=='undefined') ? 'xml' : format.toLowerCase();
|
182
|
+
console.log(_format)
|
183
|
+
if(_format!=="xml" && _format!=='json'){
|
184
|
+
console.error("Format must be 'xml' or 'json");
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
if(isNaN(limit)){
|
188
|
+
console.error("Limit must be a number");
|
189
|
+
return;
|
190
|
+
}
|
191
|
+
const _layer = (typeof layer=='undefined') ? null : layer
|
192
|
+
this.com.sendMessageToMap({
|
193
|
+
type: "getElementsFromLayer",
|
194
|
+
layer: _layer,
|
195
|
+
limit: (typeof limit!='undefined') ? parseInt(limit) : 100,
|
196
|
+
format: format,
|
197
|
+
sessionToken: this.sessionToken,
|
198
|
+
});
|
199
|
+
}
|
200
|
+
|
127
201
|
Geolocalize = (toggle) => {
|
128
|
-
sendMessageToMap({
|
202
|
+
this.com.sendMessageToMap({
|
129
203
|
type: "Geolocalize",
|
130
204
|
toggle: toggle,
|
131
205
|
sessionToken: this.sessionToken,
|
@@ -133,7 +207,7 @@ class Communicator extends EventEmitter {
|
|
133
207
|
}
|
134
208
|
|
135
209
|
toggleGiswaterTiled = (toggle) => {
|
136
|
-
sendMessageToMap({
|
210
|
+
this.com.sendMessageToMap({
|
137
211
|
type: "toggleGiswaterTiled",
|
138
212
|
toggle: toggle,
|
139
213
|
sessionToken: this.sessionToken,
|
@@ -141,7 +215,7 @@ class Communicator extends EventEmitter {
|
|
141
215
|
}
|
142
216
|
|
143
217
|
reloadDisplayedLayers = ()=>{
|
144
|
-
return sendMessageToMap({
|
218
|
+
return this.com.sendMessageToMap({
|
145
219
|
type: "reloadDisplayedLayers",
|
146
220
|
sessionToken: this.sessionToken,
|
147
221
|
});
|
@@ -149,7 +223,7 @@ class Communicator extends EventEmitter {
|
|
149
223
|
|
150
224
|
addGeoJSON = (geoJSON,options, name)=>{
|
151
225
|
if(geoJSON){
|
152
|
-
return sendMessageToMap({
|
226
|
+
return this.com.sendMessageToMap({
|
153
227
|
type: "addGeoJSON",
|
154
228
|
geoJSON: geoJSON,
|
155
229
|
options: (typeof options!='undefined') ? options : {fillcolor:null,strokecolor:null},
|
@@ -163,7 +237,7 @@ class Communicator extends EventEmitter {
|
|
163
237
|
}
|
164
238
|
|
165
239
|
clearGeoJSON = ()=>{
|
166
|
-
return sendMessageToMap({
|
240
|
+
return this.com.sendMessageToMap({
|
167
241
|
type: "clearGeoJSON",
|
168
242
|
sessionToken: this.sessionToken,
|
169
243
|
});
|
@@ -171,7 +245,7 @@ class Communicator extends EventEmitter {
|
|
171
245
|
|
172
246
|
removeGeoJSONLayer = (name)=>{
|
173
247
|
if(name){
|
174
|
-
return sendMessageToMap({
|
248
|
+
return this.com.sendMessageToMap({
|
175
249
|
type: "removeGeoJSONLayer",
|
176
250
|
name: name,
|
177
251
|
sessionToken: this.sessionToken,
|
@@ -197,7 +271,7 @@ class Communicator extends EventEmitter {
|
|
197
271
|
}
|
198
272
|
}
|
199
273
|
|
200
|
-
return sendMessageToMap({
|
274
|
+
return this.com.sendMessageToMap({
|
201
275
|
type: "setGiswaterFilters",
|
202
276
|
filters: filtersJson,
|
203
277
|
sessionToken: this.sessionToken,
|
@@ -210,7 +284,7 @@ class Communicator extends EventEmitter {
|
|
210
284
|
|
211
285
|
getGiswaterLayerAvailableFilters = (layer_name)=>{
|
212
286
|
if(layer_name){
|
213
|
-
return sendMessageToMap({
|
287
|
+
return this.com.sendMessageToMap({
|
214
288
|
type: "getGiswaterLayerAvailableFilters",
|
215
289
|
name: layer_name,
|
216
290
|
sessionToken: this.sessionToken,
|
@@ -223,14 +297,56 @@ class Communicator extends EventEmitter {
|
|
223
297
|
|
224
298
|
setDebug = (what) =>{
|
225
299
|
if(!isNaN(parseInt(what))){
|
226
|
-
|
300
|
+
this.com.sendMessageToMap({
|
227
301
|
type: "setDebug",
|
228
302
|
what: what,
|
229
303
|
sessionToken: this.sessionToken,
|
230
304
|
});
|
305
|
+
}else{
|
306
|
+
console.error("Debug is not a integer");
|
231
307
|
}
|
232
308
|
}
|
233
|
-
|
309
|
+
|
310
|
+
setCustomColors = (properties)=>{
|
311
|
+
//validate data
|
312
|
+
if(typeof properties!=='object'){
|
313
|
+
console.error("properties is not an object");
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
if(properties.hasOwnProperty('geom_stroke_width')){
|
317
|
+
if(isNaN(parseInt(properties.geom_stroke_width))){
|
318
|
+
console.error("geom_stroke_width is not an number");
|
319
|
+
return;
|
320
|
+
}else{
|
321
|
+
properties.geom_stroke_width = parseInt(properties.geom_stroke_width);
|
322
|
+
}
|
323
|
+
}else{
|
324
|
+
properties.geom_stroke_width = 1;
|
325
|
+
}
|
326
|
+
if(properties.hasOwnProperty('geom_radius')){
|
327
|
+
if(isNaN(parseInt(properties.geom_radius))){
|
328
|
+
console.error("geom_stroke_width is not an number");
|
329
|
+
return;
|
330
|
+
}else{
|
331
|
+
properties.geom_radius = parseInt(properties.geom_radius);
|
332
|
+
}
|
333
|
+
}else{
|
334
|
+
properties.geom_radius = 4;
|
335
|
+
}
|
336
|
+
|
337
|
+
if(properties.hasOwnProperty('geom_shape')){
|
338
|
+
if(properties.geom_shape!=="circle" && properties.geom_shape!=="square"){
|
339
|
+
properties.geom_shape = 'circle';
|
340
|
+
console.error("geom_shape must be either 'circle' or 'square'");
|
341
|
+
}
|
342
|
+
}
|
343
|
+
this.com.sendMessageToMap({
|
344
|
+
type: "setCustomColors",
|
345
|
+
properties: properties,
|
346
|
+
sessionToken: this.sessionToken,
|
347
|
+
});
|
348
|
+
}
|
349
|
+
|
234
350
|
}
|
235
351
|
|
236
352
|
export {
|
@@ -1,11 +1,18 @@
|
|
1
1
|
const isSSR = typeof window === 'undefined';
|
2
|
+
class iframeCommunicator {
|
3
|
+
constructor(data){
|
4
|
+
this.domId = 'map-frame';
|
5
|
+
if(typeof data.id==="string"){
|
6
|
+
this.domId = data.id;
|
7
|
+
}
|
8
|
+
}
|
2
9
|
|
3
|
-
|
4
|
-
|
5
|
-
|
10
|
+
sendMessageToMap = message => {
|
11
|
+
if(isSSR) return;
|
12
|
+
window.top.frames[this.domId].postMessage(message, "*");
|
13
|
+
}
|
6
14
|
}
|
7
15
|
|
8
|
-
|
9
16
|
export {
|
10
|
-
|
17
|
+
iframeCommunicator,
|
11
18
|
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
|
2
|
-
var sessionToken = document.querySelector("#sessionToken");
|
3
|
-
var mapContainer = document.querySelector("#mapContainer");
|
4
|
-
var iframe = document.querySelector("#map-frame");
|
5
|
-
var host = document.querySelector("#overrideHost");
|
6
|
-
//************** MAP EXAMPLE
|
7
|
-
console.log("Load",`${host.value}?sessionToken=${sessionToken.value}`)
|
8
|
-
iframe.src = `${host.value}?sessionToken=${sessionToken.value}`;
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
@@ -1,59 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>🛠️ MAP TESTER - Vidro Map</title>
|
4
|
-
<link rel="stylesheet" href="../tester.css"></link>
|
5
|
-
<link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-32x32.png" sizes="32x32" />
|
6
|
-
<link rel="icon" type="image/png" href="https://www.vidrosoftware.com/favicon/favicon-16x16.png" sizes="16x16" />
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<div class="form" id="userData">
|
13
|
-
<h1>Map Properties</h1>
|
14
|
-
<div>
|
15
|
-
Override iframe url: <input type="text" name="overrideHost" id="overrideHost" size="25" value="http://localhost:3000">
|
16
|
-
</div>
|
17
|
-
<div>
|
18
|
-
Session Token: <textarea name="sessionToken" id="sessionToken" rows="4" cols="50" placeholder="">eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2MzEzNTM3NTksImF1ZCI6IjA0MWZkOWE2NWEyYzRlZDUxNjk5OTBkZWY1NGNiZWI4NmM1ZmNhYzgiLCJkYXRhIjp7Inpvb20iOjQsImJhY2tncm91bmQiOiJDYXJ0b0RCTGlnaHQiLCJzcmlkIjpudWxsLCJleHRlbnQiOm51bGwsImdlb3NlcnZpY2UiOiJRR0lTIiwibmFtZSI6Im5leHQiLCJwcmV2aWV3IjpudWxsLCJhcGkiOiJodHRwczpcL1wvZGV2YXBpLnZpZHJvc29mdHdhcmUuY29tXC8iLCJ0eXBlIjoidmlkcm9tYXAiLCJ0b2tlbiI6IjllNDlhOTQ2MmFhZjFkYjcwMjgxMjFhMDk0NDRlNWJkIiwic2hvd19sYXllcnMiOiIiLCJpZCI6OCwibG9nbyI6Imh0dHBzOlwvXC93d3cudmlkcm9zb2Z0d2FyZS5jb21cL2xvZ29zXC9WSURSTy5zdmcifX0.FJhMMjgvXBIvaDgroq2eZtnER6qKoIDtfm7-8ofjl_TXHB9GLAVKOAfKibEGCjPTaMlG9K4CT4zPzF9Y98Hp333Qk2_hmKKofDYLw1Zoce2hYQKXFUDcY-nMoN39Yxq_dT-txUkMjhGqVDFk0vlcweoUwsJcvRdPXmj4nweCh4Q5MNTFh9i9VKongZ4XY4w2IZnxtwFB2onjMR0G7p_qzYp0g6rcpFIlo2enzVFH9_8H0nlcQYXi7FikaTQRDCf6NX2WFRGjd5LN4ruUXwxtxsmqFcc4EmgqiwrgqIbv75d_udeCszVdJCCFExcfAyzjhSkrSZtiCvkq763SQNcCZcc_pyDzWKhLaDMgXlapafWfYpTQUQaE4G88AdjV8MVeqd46yn9qJN2kzHiDKUnFfj8QGGkkDMz6QVXDxcdsOOCOc1NIN-pH0hPF0biaDosKZ1mWyk3xNM74Pet8m2qfzMDfcHiOzDWuNqr_QRJiV4HTmBJfegB72vwKaBleNCQoG-H1ukpwWuHJouoUpYrlz5pOrTWHAUERr9bMp0usf_r8X_IZtfbrF3gxuA6b8hvz1APd2E8ZmHpTBx6nMxuhdtUS2UE9RQgefkp4UbWjwdxmTkLEtNBM1_W_avoaL5RTMOHs96-i7IO5rVFwE18K9n-kLmVzcZ2oiL5Rtbt2tII</textarea>
|
19
|
-
</div>
|
20
|
-
|
21
|
-
</div>
|
22
|
-
<div id="Error_container"></div>
|
23
|
-
<div id="mapContainer">
|
24
|
-
|
25
|
-
<div id="iframes-container">
|
26
|
-
<iframe id="map-frame" name="map-frame" src="" style="width:100%; height:600px;" allow="geolocation"></iframe>
|
27
|
-
</div>
|
28
|
-
<hr />
|
29
|
-
<pre id="Result_container"></pre>
|
30
|
-
<hr/>
|
31
|
-
<h2>Zoom</h2>
|
32
|
-
<button id="btZoomIn">Zoom In</button>
|
33
|
-
<button id="btZoomOut">Zoom Out</button>
|
34
|
-
<button id="btZoomToExtent">Zoom to extent</button>
|
35
|
-
<h2>Info</h2>
|
36
|
-
<button id="btWMSInfo" disabled="true">WMS Info</button>
|
37
|
-
<button id="btGiswaterInfo">Giswater Info</button>
|
38
|
-
<h2>Layers</h2>
|
39
|
-
Project Layers: <select id="projectlayers"></select> - <small>click on "Load Project Layers button</small> <button id="btToggleLayer">Add / Remove Layer</button><br><br>
|
40
|
-
Displayed Layers: <select id="layers"></select> -
|
41
|
-
<button id="btActiveLayer">Set Active Layer</button>
|
42
|
-
<button id="btGetActiveLayer">Get Active Layer</button>
|
43
|
-
<span id="currentActiveLayer"></span>
|
44
|
-
|
45
|
-
|
46
|
-
<h2>GeoJSON</h2>
|
47
|
-
|
48
|
-
<input type="file" id="geojsonfile" name="geojsonfile" accept="application/json"><small> Select geoJSON file</small><br><br>
|
49
|
-
<small>Or paste geoJSON content</small><br><br>
|
50
|
-
<textarea name="geojsondata" id="geojsondata" rows="10" cols="80" placeholder=""></textarea> <br><br>
|
51
|
-
<button id="btAddGeoJSON">Add GeoJSON </button><br><br>
|
52
|
-
</div>
|
53
|
-
|
54
|
-
<!--<script src="https://unpkg.com/@vidro/map-handler@1.0.1/dist/map-handler.js"></script>-->
|
55
|
-
<script src="../../dist/map-handler.js"></script>
|
56
|
-
<script src="../full/tester.js"></script>
|
57
|
-
<script src="./vidromap.js"></script>
|
58
|
-
</body>
|
59
|
-
</html>
|