@vidro/map-handler 1.0.18 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +51 -5
- package/dist/map-handler.js +1 -1
- package/examples/full/cachedToken.dat +1 -1
- package/examples/full/index.php +238 -168
- package/examples/full/tester.js +161 -17
- package/package.json +1 -1
- package/src/index.js +309 -186
package/examples/full/tester.js
CHANGED
@@ -43,6 +43,7 @@ var btDebug = document.querySelector("#btDebug");
|
|
43
43
|
var btAddGeoJSONFromGiswater = document.querySelector(
|
44
44
|
"#btAddGeoJSONFromGiswater"
|
45
45
|
);
|
46
|
+
var btCenterToCoordinates = document.querySelector("#btCenterToCoordinates");
|
46
47
|
//override layer properties
|
47
48
|
var overrideLayerProperties = document.querySelector(
|
48
49
|
"#overrideLayerProperties"
|
@@ -63,6 +64,38 @@ var btGetElementsFromLayer = document.querySelector("#btGetElementsFromLayer");
|
|
63
64
|
var btGetToc = document.querySelector("#btGetToc");
|
64
65
|
var btChangeBackground = document.querySelector("#btChangeBackground");
|
65
66
|
var newBackground = document.querySelector("#newBackground");
|
67
|
+
//vector layer create
|
68
|
+
var btAddVectorLayer = document.querySelector("#btAddVectorLayer");
|
69
|
+
var vectorLayerName = document.querySelector("#vectorLayerName");
|
70
|
+
var btRemoveVectorLayer = document.querySelector("#btRemoveVectorLayer");
|
71
|
+
|
72
|
+
var btMeasureDistance = document.querySelector("#btMeasureDistance");
|
73
|
+
var btMeasureArea = document.querySelector("#btMeasureArea");
|
74
|
+
var btCancelMeasure = document.querySelector("#btCancelMeasure");
|
75
|
+
|
76
|
+
var btDrawGeometryInLayer = document.querySelector("#btDrawGeometryInLayer");
|
77
|
+
var geomAstext = document.querySelector("#geomAstext");
|
78
|
+
var geomLabel = document.querySelector("#geomLabel");
|
79
|
+
var layerToDraw = document.querySelector("#layerToDraw");
|
80
|
+
var uuid = document.querySelector("#uuid");
|
81
|
+
var btRemoveGeometryInLayer = document.querySelector(
|
82
|
+
"#btRemoveGeometryInLayer"
|
83
|
+
);
|
84
|
+
var fillcolor = document.querySelector("#fillcolor");
|
85
|
+
var strokecolor = document.querySelector("#strokecolor");
|
86
|
+
var radius = document.querySelector("#radius");
|
87
|
+
var strokeWidth = document.querySelector("#strokeWidth");
|
88
|
+
var font = document.querySelector("#font");
|
89
|
+
var fontSize = document.querySelector("#fontSize");
|
90
|
+
var fontStrokeColor = document.querySelector("#fontStrokeColor");
|
91
|
+
var fontFillColor = document.querySelector("#fontFillColor");
|
92
|
+
var fontStrokeWidth = document.querySelector("#fontStrokeWidth");
|
93
|
+
var labelPlacement = document.querySelector("#labelPlacementfont");
|
94
|
+
var fontSize = document.querySelector("#fontSize");
|
95
|
+
var labelBaseline = document.querySelector("#labelBaseline");
|
96
|
+
var labelAlign = document.querySelector("#labelAlign");
|
97
|
+
var display = document.querySelector("#display");
|
98
|
+
var maxReso = document.querySelector("#maxReso");
|
66
99
|
|
67
100
|
var geoJSONName = null; //geoJSON file name
|
68
101
|
var geoJSONContent = null; // geojson file content
|
@@ -102,12 +135,13 @@ communicator.on("loaded", function (data) {
|
|
102
135
|
geom_stroke_width: 1,
|
103
136
|
geom_shape: "circle",
|
104
137
|
geom_radius: 200,
|
138
|
+
measure_fill_color: "rgba(222,218,125,0.63)",
|
139
|
+
measure_stroke_color: "rgba(255,0,0,1)",
|
105
140
|
});
|
106
141
|
});
|
107
142
|
communicator.on("capabilities", function (data) {
|
108
143
|
console.log("capabilities", data);
|
109
|
-
|
110
|
-
})
|
144
|
+
});
|
111
145
|
|
112
146
|
communicator.on("layers", function (data) {
|
113
147
|
console.log("layers received", data);
|
@@ -136,6 +170,8 @@ communicator.on("coordinates", function (data) {
|
|
136
170
|
cleanContainers();
|
137
171
|
clickedCoordinates = [data.coordinates[0], data.coordinates[1]];
|
138
172
|
Result_container.innerHTML = `Clicked coordinates -> x: ${data.coordinates[0]}, y: ${data.coordinates[1]}`;
|
173
|
+
if (geomAstext)
|
174
|
+
geomAstext.value = `POINT(${data.coordinates[0]} ${data.coordinates[1]})`;
|
139
175
|
});
|
140
176
|
|
141
177
|
communicator.on("activeLayer", function (data) {
|
@@ -204,6 +240,12 @@ communicator.on("availableWMSLayers", function (data) {
|
|
204
240
|
console.log("availableWMSLayers", data);
|
205
241
|
fillLayersSelect(data);
|
206
242
|
});
|
243
|
+
communicator.on("MeasureEnd", function (data) {
|
244
|
+
console.log("MeasureEnd", data);
|
245
|
+
|
246
|
+
});
|
247
|
+
|
248
|
+
|
207
249
|
|
208
250
|
function fillLayersSelect(options) {
|
209
251
|
console.log("fillLayersSelect", options);
|
@@ -275,6 +317,16 @@ if (btZoomToCoordinates) {
|
|
275
317
|
});
|
276
318
|
}
|
277
319
|
|
320
|
+
if (btCenterToCoordinates) {
|
321
|
+
btCenterToCoordinates.addEventListener("click", function () {
|
322
|
+
if (clickedCoordinates) {
|
323
|
+
communicator.centerMap(clickedCoordinates);
|
324
|
+
} else {
|
325
|
+
console.warn("No coordinates provided");
|
326
|
+
Error_container.innerHTML = "No coordinates provided";
|
327
|
+
}
|
328
|
+
});
|
329
|
+
}
|
278
330
|
if (btAddPoint) {
|
279
331
|
btAddPoint.addEventListener("click", function () {
|
280
332
|
communicator.AddGeom("Point");
|
@@ -362,23 +414,45 @@ if (btGetToc) {
|
|
362
414
|
communicator.getToc();
|
363
415
|
});
|
364
416
|
}
|
365
|
-
|
366
|
-
if(btChangeBackground){
|
417
|
+
if (btChangeBackground) {
|
367
418
|
btChangeBackground.addEventListener("click", function (evt) {
|
368
|
-
if(newBackground.value){
|
369
|
-
console.log("btChangeBackground",newBackground.value);
|
419
|
+
if (newBackground.value) {
|
420
|
+
console.log("btChangeBackground", newBackground.value);
|
370
421
|
communicator.changeBackground(newBackground.value);
|
371
|
-
}else{
|
372
|
-
console.warn("no active layer")
|
422
|
+
} else {
|
423
|
+
console.warn("no active layer");
|
424
|
+
}
|
425
|
+
});
|
426
|
+
}
|
427
|
+
|
428
|
+
//************* Vector layers create and delete */
|
429
|
+
|
430
|
+
if (btAddVectorLayer) {
|
431
|
+
btAddVectorLayer.addEventListener("click", function (evt) {
|
432
|
+
if (vectorLayerName.value) {
|
433
|
+
console.log("btAddVectorLayer", vectorLayerName.value);
|
434
|
+
|
435
|
+
communicator.toggleLayer(vectorLayerName.value, {
|
436
|
+
gutter: gutter ? gutter.value : 5,
|
437
|
+
transparent: toggleTransparentLayer.checked,
|
438
|
+
layerType: "vector",
|
439
|
+
});
|
440
|
+
if (layerToDraw) layerToDraw.value = vectorLayerName.value;
|
441
|
+
} else {
|
442
|
+
console.warn("no vector layer name");
|
443
|
+
}
|
444
|
+
});
|
445
|
+
}
|
446
|
+
if (btRemoveVectorLayer) {
|
447
|
+
btRemoveVectorLayer.addEventListener("click", function (evt) {
|
448
|
+
if (vectorLayerName.value) {
|
449
|
+
console.log("btRemoveVectorLayer", vectorLayerName.value);
|
450
|
+
//communicator.changeBackground(newBackground.value);
|
451
|
+
} else {
|
452
|
+
console.warn("no vector layer name");
|
373
453
|
}
|
374
454
|
});
|
375
455
|
}
|
376
|
-
/*
|
377
|
-
overrideLayerProperties
|
378
|
-
gutter
|
379
|
-
toggleTransparentLayer
|
380
|
-
toggleSingleTile
|
381
|
-
containerOverride*/
|
382
456
|
|
383
457
|
//**********************************************************
|
384
458
|
//************** END LAYERS ****************
|
@@ -502,9 +576,6 @@ if (btAddGeoJSON) {
|
|
502
576
|
console.log("using geoJSON file");
|
503
577
|
geoToSend = geoJSONContent;
|
504
578
|
}
|
505
|
-
var fillcolor = document.querySelector("#fillcolor");
|
506
|
-
var strokecolor = document.querySelector("#strokecolor");
|
507
|
-
|
508
579
|
//Check JSON
|
509
580
|
try {
|
510
581
|
let options = {
|
@@ -667,3 +738,76 @@ if (btGetElementsFromLayer) {
|
|
667
738
|
//**********************************************************
|
668
739
|
//************** END WMS TABLE ****************
|
669
740
|
//**********************************************************
|
741
|
+
if (btDrawGeometryInLayer) {
|
742
|
+
btDrawGeometryInLayer.addEventListener("click", function () {
|
743
|
+
let geomAstext = document.getElementById("geomAstext").value;
|
744
|
+
let geomLabel = document.getElementById("geomLabel").value;
|
745
|
+
let layerToDraw = document.getElementById("layerToDraw").value;
|
746
|
+
let uuid = document.getElementById("uuid").value
|
747
|
+
? document.getElementById("uuid").value
|
748
|
+
: Math.floor(Math.random() * 100);
|
749
|
+
|
750
|
+
let style = {
|
751
|
+
geom_stroke_color: strokecolor.value ? strokecolor.value : null,
|
752
|
+
geom_fill_color: fillcolor.value ? fillcolor.value : null,
|
753
|
+
geom_radius: radius.value ? Number(radius.value) : null,
|
754
|
+
geom_stroke_width: strokeWidth.value ? Number(strokeWidth.value) : null,
|
755
|
+
font: font.value ? font.value : "arial",
|
756
|
+
fontSize: fontSize.value ? fontSize.value : 12,
|
757
|
+
fontStrokeColor: fontStrokeColor ? fontStrokeColor.value : null,
|
758
|
+
fontFillColor: fontFillColor ? fontFillColor.value : null,
|
759
|
+
fontStrokeWidth: fontStrokeWidth ? fontStrokeWidth.value : null,
|
760
|
+
placement: labelPlacement ? labelPlacement.value : null,
|
761
|
+
baseline: labelBaseline ? labelBaseline.value : null,
|
762
|
+
align: labelAlign ? labelAlign.value : null,
|
763
|
+
maxReso: maxReso ? maxReso.value : null,
|
764
|
+
display: display ? display.value : null,
|
765
|
+
};
|
766
|
+
|
767
|
+
communicator.drawGeometryInLayer(
|
768
|
+
uuid,
|
769
|
+
layerToDraw,
|
770
|
+
geomAstext,
|
771
|
+
geomLabel,
|
772
|
+
style
|
773
|
+
);
|
774
|
+
});
|
775
|
+
}
|
776
|
+
if (btRemoveGeometryInLayer) {
|
777
|
+
btRemoveGeometryInLayer.addEventListener("click", function () {
|
778
|
+
let layer = document.getElementById("layerToDraw").value;
|
779
|
+
let uuid = document.getElementById("uuid").value
|
780
|
+
? document.getElementById("uuid").value
|
781
|
+
: Math.floor(Math.random() * 100);
|
782
|
+
|
783
|
+
communicator.removeGeometryFromLayer(uuid, layer);
|
784
|
+
});
|
785
|
+
btRemoveGeometryInLayer;
|
786
|
+
}
|
787
|
+
|
788
|
+
//**********************************************************
|
789
|
+
//************** MEASURE ****************
|
790
|
+
//**********************************************************
|
791
|
+
if (btMeasureDistance) {
|
792
|
+
btMeasureDistance.addEventListener("click", function () {
|
793
|
+
console.log("Button measureDistance clicked");
|
794
|
+
communicator.initMeasure('line','Clica para empezar a medir','Clica para continuar midiendo','Clica para continuar midiendo');
|
795
|
+
|
796
|
+
});
|
797
|
+
}
|
798
|
+
if (btMeasureArea) {
|
799
|
+
btMeasureArea.addEventListener("click", function () {
|
800
|
+
console.log("Button btMeasureArea clicked");
|
801
|
+
communicator.initMeasure('area','Clica para empezar a medir','Clica para continuar midiendo','Clica para continuar midiendo');
|
802
|
+
});
|
803
|
+
}
|
804
|
+
if (btCancelMeasure) {
|
805
|
+
btCancelMeasure.addEventListener("click", function () {
|
806
|
+
console.log("Button btCancelMeasure clicked");
|
807
|
+
communicator.cancelMeasure();
|
808
|
+
});
|
809
|
+
}
|
810
|
+
|
811
|
+
|
812
|
+
|
813
|
+
|
package/package.json
CHANGED