node-red-contrib-web-worldmap 4.7.0 → 4.8.0
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/CHANGELOG.md +2 -0
- package/README.md +2 -0
- package/examples/feedback.json +129 -0
- package/package.json +1 -1
- package/worldmap/worldmap.js +17 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v4.8.0 - Merged PR for feedback functioanlity cleanup and example. PR #271 and #272
|
|
4
|
+
- v4.7.0 - Update pmtiles library, fix feedback function inconsistency. Issue #270
|
|
3
5
|
- v4.6.5 - Let geojson allow for generic overrides with .icon and .layer.
|
|
4
6
|
- v4.6.4 - Fix deletion of layers logic to actually fully remove points.
|
|
5
7
|
- v4.6.3 - Fix sending of layer events when not wanted. Issue #262
|
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ Feel free to [;\nmsg.payload = {\"command\":{\"zoom\":9.7}};\nnode.send(msg);\n\n\nvar popup = \"<button name=\\\"B1name\\\" onclick='feedback(\\\"${name}\\\",\\\"${name} sends {x} Hellow\\\",\\\"myAction\\\",true);'>Hellow1 from ${name}</button>\";\npopup += \"<button name=\\\"B2name\\\" onclick='feedback(this.name,\\\"${name} sends {x} Hellow\\\",\\\"myAction\\\",true);'>Hellow2 from ${name}</button>\";\n\nvar points = [ { \"lat\": 50.66, \"lng\": -1.59 }, { \"lat\": 50.60, \"lng\": -1.47 } ] ;\nmsg.payload = {\n popup: popup.replace(/\\{x\\}/,\"popup\"),\n contextmenu: popup.replace(/\\{x\\}/, \"context\"),\n name: \"myShape\",\n area: points,\n clickable:true,\n };\nnode.send(msg);\n\nmsg.payload = {\n popup: popup,\n contextmenu: popup,\n name: \"myMarker\",\n lat: 50.40,\n lon: -1.0,\n weight: 1,\n};\nnode.send(msg);\nreturn msg;",
|
|
67
|
+
"outputs": 1,
|
|
68
|
+
"timeout": "",
|
|
69
|
+
"noerr": 0,
|
|
70
|
+
"initialize": "",
|
|
71
|
+
"finalize": "",
|
|
72
|
+
"libs": [],
|
|
73
|
+
"x": 770,
|
|
74
|
+
"y": 480,
|
|
75
|
+
"wires": [
|
|
76
|
+
[
|
|
77
|
+
"c643e022.1816c",
|
|
78
|
+
"34ad8daae96efd3e"
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "32d7cc4d4db67f66",
|
|
84
|
+
"type": "worldmap in",
|
|
85
|
+
"z": "46f4b9ae1c66c1ba",
|
|
86
|
+
"name": "",
|
|
87
|
+
"path": "/worldmap",
|
|
88
|
+
"events": "connect,disconnect,point,layer,bounds,files,draw,other",
|
|
89
|
+
"x": 500,
|
|
90
|
+
"y": 540,
|
|
91
|
+
"wires": [
|
|
92
|
+
[
|
|
93
|
+
"32a2b83008623990"
|
|
94
|
+
]
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "32a2b83008623990",
|
|
99
|
+
"type": "debug",
|
|
100
|
+
"z": "46f4b9ae1c66c1ba",
|
|
101
|
+
"name": "debug 14",
|
|
102
|
+
"active": true,
|
|
103
|
+
"tosidebar": true,
|
|
104
|
+
"console": false,
|
|
105
|
+
"tostatus": false,
|
|
106
|
+
"complete": "false",
|
|
107
|
+
"statusVal": "",
|
|
108
|
+
"statusType": "auto",
|
|
109
|
+
"x": 680,
|
|
110
|
+
"y": 540,
|
|
111
|
+
"wires": []
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "34ad8daae96efd3e",
|
|
115
|
+
"type": "debug",
|
|
116
|
+
"z": "46f4b9ae1c66c1ba",
|
|
117
|
+
"name": "debug 15",
|
|
118
|
+
"active": true,
|
|
119
|
+
"tosidebar": true,
|
|
120
|
+
"console": false,
|
|
121
|
+
"tostatus": false,
|
|
122
|
+
"complete": "false",
|
|
123
|
+
"statusVal": "",
|
|
124
|
+
"statusType": "auto",
|
|
125
|
+
"x": 980,
|
|
126
|
+
"y": 400,
|
|
127
|
+
"wires": []
|
|
128
|
+
}
|
|
129
|
+
]
|
package/package.json
CHANGED
package/worldmap/worldmap.js
CHANGED
|
@@ -865,6 +865,10 @@ var addThing = function() {
|
|
|
865
865
|
var form = {};
|
|
866
866
|
var addToForm = function(n,v) { form[n] = v; }
|
|
867
867
|
var feedback = function(n,v,a,c) {
|
|
868
|
+
/*
|
|
869
|
+
// suggest to reove all the special handling for simplification, no reason to send information
|
|
870
|
+
// about entities that the backend generaed, the need is only to get recognizable actions from the frontend
|
|
871
|
+
//
|
|
868
872
|
if (v === "_form") { v = form; }
|
|
869
873
|
if (markers[n]) {
|
|
870
874
|
console.log("FB1",n,v,a,c)
|
|
@@ -875,8 +879,10 @@ var feedback = function(n,v,a,c) {
|
|
|
875
879
|
setMarker(allData[n]);
|
|
876
880
|
}
|
|
877
881
|
else if (polygons[n]) {
|
|
878
|
-
console.log("FB2",n,v,a)
|
|
879
|
-
|
|
882
|
+
console.log("FB2", n, v, a);
|
|
883
|
+
const polyData = { "name": n, "action": a || "feedback", "value": v || null };
|
|
884
|
+
//sendDrawing(n,v,a)
|
|
885
|
+
ws.send(JSON.stringify(polyData));
|
|
880
886
|
}
|
|
881
887
|
else {
|
|
882
888
|
if (n === undefined) { n = "map"; }
|
|
@@ -884,6 +890,10 @@ var feedback = function(n,v,a,c) {
|
|
|
884
890
|
rmenudata = v;
|
|
885
891
|
ws.send(JSON.stringify({action:a||"feedback", name:n, value:v, lat:rclk.lat, lon:rclk.lng}));
|
|
886
892
|
}
|
|
893
|
+
*/
|
|
894
|
+
|
|
895
|
+
const dataToSend = { "name": n, "action": a || "feedback", "value": v || null };
|
|
896
|
+
ws.send(JSON.stringify(dataToSend));
|
|
887
897
|
if (c === true) { map.closePopup(); }
|
|
888
898
|
}
|
|
889
899
|
|
|
@@ -1188,7 +1198,7 @@ var addOverlays = function(overlist) {
|
|
|
1188
1198
|
rightmenuMarker = L.popup({offset:[0,-12]}).setContent(drawcontextmenu.replace(/\${name}/g,name).replace(/\${.*?}/g,'') || "<input type='text' autofocus value='"+name+"' id='dinput' placeholder='name (,icon, layer)'/><br/><button onclick='editPoly(\""+name+"\");'>Edit points</button><button onclick='editPoly(\""+name+"\",\"drag\");'>Drag</button><button onclick='editPoly(\""+name+"\",\"rot\");'>Rotate</button><button onclick='delMarker(\""+name+"\",true);'>Delete</button><button onclick='sendRoute(\""+name+"\");'>Route</button><button onclick='sendDrawing(\""+name+"\");'>OK</button>");
|
|
1189
1199
|
}
|
|
1190
1200
|
rightmenuMarker.setLatLng(cent);
|
|
1191
|
-
setTimeout(function() {map.openPopup(rightmenuMarker)},25);
|
|
1201
|
+
setTimeout(function() {map.openPopup(rightmenuMarker).replace(/\${name}/g,name)},25);
|
|
1192
1202
|
});
|
|
1193
1203
|
|
|
1194
1204
|
sendDrawing = function(n,v,a) {
|
|
@@ -1510,7 +1520,8 @@ function setMarker(data) {
|
|
|
1510
1520
|
m.on('click', function(e) {
|
|
1511
1521
|
var fb = allData[data["name"]];
|
|
1512
1522
|
fb.action = "click";
|
|
1513
|
-
|
|
1523
|
+
if (fb.sendOnClick ?? true)
|
|
1524
|
+
ws.send(JSON.stringify(fb));
|
|
1514
1525
|
});
|
|
1515
1526
|
// customise right click context menu
|
|
1516
1527
|
var rightcontext = "";
|
|
@@ -1529,7 +1540,7 @@ function setMarker(data) {
|
|
|
1529
1540
|
rightcontext = rightcontext.replace(new RegExp("\\${"+item+"}","g"),allData[data["name"]].value[item]);
|
|
1530
1541
|
}
|
|
1531
1542
|
}
|
|
1532
|
-
rightcontext = rightcontext.replace(/\${.*?}/g,'')
|
|
1543
|
+
rightcontext = rightcontext.replace(/\${.*?}/g,'').replace(/\${name}/g,data["name"])
|
|
1533
1544
|
if (rightcontext.length > 0) {
|
|
1534
1545
|
var rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<b>"+data["name"]+"</b><br/>"+rightcontext);
|
|
1535
1546
|
if (hiderightclick !== true) {
|
|
@@ -1698,7 +1709,7 @@ function setMarker(data) {
|
|
|
1698
1709
|
// if clickable then add popup
|
|
1699
1710
|
if (opt.clickable === true) {
|
|
1700
1711
|
var words = "<b>"+data["name"]+"</b>";
|
|
1701
|
-
if (data.popup) { words = words + "<br/>" + data.popup; }
|
|
1712
|
+
if (data.popup) { words = words + "<br/>" + data.popup.replace(/\${name}/g,data["name"]); }
|
|
1702
1713
|
polygons[data["name"]].bindPopup(words, {autoClose:false, closeButton:true, closeOnClick:true, minWidth:200});
|
|
1703
1714
|
}
|
|
1704
1715
|
// add a tooltip (if supplied)
|