node-red-contrib-web-worldmap 2.15.6 → 2.16.1

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 CHANGED
@@ -1,7 +1,9 @@
1
1
  ### Change Log for Node-RED Worldmap
2
2
 
3
- - v2.15.6 - Tidy up geoJson handling a bit more.
4
- - v2.15.5 - Fix SDIC icons to accept unicoded icons as labels.
3
+ - v2.16.0 - Allow specifying custom base map server.
4
+ - v2.15.8 - Adjust ui check timing for UI worldmap.
5
+ - v2.15.7 - Tidy up geoJson handling a bit more.
6
+ - v2.15.5 - Fix SIDC icons to accept unicoded icons as labels.
5
7
  - v2.15.4 - Let clear heatmap command do what it says.
6
8
  - v2.15.3 - Fix panit command to work, try to use alt units, popup alignments.
7
9
  - v2.15.0 - let speed be text and specify units if required (kt,kn,knots,mph,kmh,kph) default m/s.
package/README.md CHANGED
@@ -11,8 +11,10 @@ map web page for plotting "things" on.
11
11
 
12
12
  ### Updates
13
13
 
14
- - v2.15.6 - Tidy up geoJson handling a bit more.
15
- - v2.15.5 - Fix SDIC icons to accept unicoded icons as labels.
14
+ - v2.16.0 - Allow specifying custom base map server.
15
+ - v2.15.8 - Adjust ui check timing for UI worldmap.
16
+ - v2.15.7 - Tidy up geoJson handling a bit more.
17
+ - v2.15.5 - Fix SIDC icons to accept unicoded icons as labels.
16
18
  - v2.15.4 - Let clear heatmap command do what it says.
17
19
  - v2.15.3 - Fix panit command to work, try to use alt units, popup alignments.
18
20
  - v2.15.0 - let speed be text and specify units if required (kt,kn,knots,mph,kmh,kph) default m/s.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-web-worldmap",
3
- "version": "2.15.6",
3
+ "version": "2.16.1",
4
4
  "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
5
5
  "dependencies": {
6
6
  "cgi": "0.3.1",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "author": {
34
34
  "name": "Dave Conway-Jones",
35
- "email": "ceejay@vnet.ibm.com",
35
+ "email": "dceejay@gmail.com",
36
36
  "url": "http://nodered.org"
37
37
  },
38
38
  "contributors": [
@@ -662,7 +662,7 @@ map.on('moveend', function() {
662
662
  var addmenu = "<b>Add marker</b><br><input type='text' id='rinput' autofocus onkeydown='if (event.keyCode == 13) addThing();' placeholder='name (,icon, layer, colour, heading)'/>";
663
663
  var rightmenuMap = L.popup({keepInView:true, minWidth:250}).setContent(addmenu);
664
664
 
665
- var rclk;
665
+ var rclk = {};
666
666
  var hiderightclick = false;
667
667
  var addThing = function() {
668
668
  var thing = document.getElementById('rinput').value;
@@ -697,7 +697,7 @@ var feedback = function(n,v,a,c) {
697
697
  }
698
698
  else {
699
699
  if (n === undefined) { n = "map"; }
700
- ws.send(JSON.stringify({action:a||"feedback", name:n, value:v, lat:rclk.lat, lon:rclk.lng,}));
700
+ ws.send(JSON.stringify({action:a||"feedback", name:n, value:v, lat:rclk.lat, lon:rclk.lng}));
701
701
  }
702
702
  if (c === true) { map.closePopup(); }
703
703
  }
@@ -2532,7 +2532,6 @@ function doGeojson(n,g,l,o) {
2532
2532
  l.bindPopup('<pre style="overflow-x: scroll">'+JSON.stringify(f.properties,null,' ').replace(/[\{\}"]/g,'')+'</pre>');
2533
2533
  }
2534
2534
  }
2535
-
2536
2535
  if (o && o.hasOwnProperty("clickable") && o.clickable === true) {
2537
2536
  l.on('click', function (e) {
2538
2537
  ws.send(JSON.stringify({action:"clickgeo",name:n,type:f.type,properties:f.properties,geometry:f.geometry}));
package/worldmap.html CHANGED
@@ -1,20 +1,4 @@
1
1
  <!DOCTYPE html>
2
- <!--
3
- Copyright 2015, 2021 IBM Corp.
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
-
18
2
  <script type="text/html" data-template-name="worldmap">
19
3
  <div class="form-row">
20
4
  <table border="0" width="96%">
@@ -28,7 +12,7 @@
28
12
  </div>
29
13
  <div class="form-row">
30
14
  <label for="node-input-layer"><i class="fa fa-map"></i> Base map</label>
31
- <select id="node-input-layer">
15
+ <select id="node-input-layer" style="width:70%;">
32
16
  <option value="OSM grey">OpenStreetMap Greyscale</option>
33
17
  <option value="OSM">OpenStreetMap</option>
34
18
  <option value="Esri">ESRI Streetmap</option>
@@ -42,8 +26,20 @@
42
26
  <option value="Hike Bike">Hike Bike OSM</option>
43
27
  <option value="Terrain">Terrain</option>
44
28
  <option value="Watercolor">Stamen Watercolor</option>
29
+ <option value="Custom">Custom Map Provider</option>
45
30
  </select>
46
31
  </div>
32
+ <div class="form-row" id="customMap">
33
+ <label for="node-input-mapname">&nbsp;&nbsp;&nbsp;Map name</label>
34
+ <input type="text" id="node-input-mapname" placeholder="name for Layer Menu"><br/>
35
+ <label for="node-input-mapurl">&nbsp;&nbsp;&nbsp;Map URL</label>
36
+ <input type="text" id="node-input-mapurl" placeholder="URL"><br/>
37
+ <label for="node-input-mapopt">&nbsp;&nbsp;&nbsp;Map options</label>
38
+ <input type="text" id="node-input-mapopt" placeholder="options (Leaflet JSON string)"><br/>
39
+ <label for="node-input-mapwms">&nbsp;&nbsp;&nbsp;</label>
40
+ <input type="checkbox" id="node-input-mapwms" style="display:inline-block; width:20px; vertical-align:baseline;">
41
+ Map server uses WMS
42
+ </div>
47
43
  <div class="form-row">
48
44
  <label for="node-input-cluster"><i class="fa fa-dot-circle-o"></i>Cluster when</label>
49
45
  zoom level is less than <input type="text" id="node-input-cluster" placeholder="0 (0,off - 19)" style="width:100px;">
@@ -90,13 +86,13 @@
90
86
  </div>
91
87
  <div class="form-row">
92
88
  <label for="node-input-coords"><i class="fa fa-compass"></i> Co-ordinates</label>
93
- <select id="node-input-coords" style="width:95px;">
89
+ <select id="node-input-coords" style="width:101px;">
94
90
  <option value="none">Not shown</option>
95
91
  <option value="deg">Degrees</option>
96
92
  <option value="dms">D.M.S</option>
97
93
  </select>
98
94
  <i class="fa fa-th" style="margin-left:22px;"></i> Graticule
99
- <select id="node-input-showgrid" style="width:95px;">
95
+ <select id="node-input-showgrid" style="width:101px;">
100
96
  <option value="false">Not shown</option>
101
97
  <option value="true">Visible</option>
102
98
  </select>
@@ -114,8 +110,8 @@
114
110
  <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
115
111
  <input type="text" id="node-input-name" placeholder="name">
116
112
  </div>
117
- <div class="form-tips">Set <i>Cluster when</i> to 0 to disable clustering of points.<br/>If <i>Path</i> is left empty,
118
- then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>
113
+ <div class="form-tips">Set <i>Cluster when</i> to 0 to disable clustering of points.<br/>
114
+ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>
119
115
  </script>
120
116
 
121
117
  <script type="text/html" data-help-name="worldmap">
@@ -193,8 +189,20 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
193
189
  <option value="Hike Bike">Hike Bike OSM</option>
194
190
  <option value="Terrain">Terrain</option>
195
191
  <option value="Watercolor">Stamen Watercolor</option>
192
+ <option value="Custom">Custom Map Provider</option>
196
193
  </select>
197
194
  </div>
195
+ <div class="form-row" id="customMap">
196
+ <label for="node-input-mapname">&nbsp;&nbsp;&nbsp;Map name</label>
197
+ <input type="text" id="node-input-mapname" placeholder="name for Layer Menu"><br/>
198
+ <label for="node-input-mapurl">&nbsp;&nbsp;&nbsp;Map URL</label>
199
+ <input type="text" id="node-input-mapurl" placeholder="URL"><br/>
200
+ <label for="node-input-mapopt">&nbsp;&nbsp;&nbsp;Map options</label>
201
+ <input type="text" id="node-input-mapopt" placeholder="options (Leaflet JSON string)"><br/>
202
+ <label for="node-input-mapwms">&nbsp;&nbsp;&nbsp;</label>
203
+ <input type="checkbox" id="node-input-mapwms" style="display:inline-block; width:20px; vertical-align:baseline;">
204
+ Map server uses WMS
205
+ </div>
198
206
  <div class="form-row">
199
207
  <label for="node-input-cluster"><i class="fa fa-dot-circle-o"></i>Cluster when</label>
200
208
  zoom level is less than <input type="text" id="node-input-cluster" placeholder="0 (0,off - 19)" style="width:100px;">
@@ -241,13 +249,13 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
241
249
  </div>
242
250
  <div class="form-row">
243
251
  <label for="node-input-coords"><i class="fa fa-compass"></i> Co-ordinates</label>
244
- <select id="node-input-coords" style="width:95px;">
252
+ <select id="node-input-coords" style="width:101px;">
245
253
  <option value="none">Not shown</option>
246
254
  <option value="deg">Degrees</option>
247
255
  <option value="dms">D.M.S</option>
248
256
  </select>
249
257
  <i class="fa fa-th" style="margin-left:22px;"></i> Graticule
250
- <select id="node-input-showgrid" style="width:95px;">
258
+ <select id="node-input-showgrid" style="width:101px;">
251
259
  <option value="false">Not shown</option>
252
260
  <option value="true">Visible</option>
253
261
  </select>
@@ -265,8 +273,8 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
265
273
  <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
266
274
  <input type="text" id="node-input-name" placeholder="name">
267
275
  </div>
268
- <div class="form-tips">Set <i>Cluster when</i> to 0 to disable clustering of points.<br/>If <i>Path</i> is left empty,
269
- then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>
276
+ <div class="form-tips">Set <i>Cluster when</i> to 0 to disable clustering of points.<br/>
277
+ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>
270
278
  </script>
271
279
 
272
280
  <script type="text/html" data-help-name="ui_worldmap">
@@ -336,7 +344,11 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
336
344
  coords: {value:"false"},
337
345
  showgrid: {value:"false"},
338
346
  allowFileDrop: {value:"false"},
339
- path: {value:"/worldmap"}
347
+ path: {value:"/worldmap"},
348
+ mapname: {value:""},
349
+ mapurl: {value:""},
350
+ mapopt: {value:"", validate:function(v) {try{ v.length===0 || JSON.parse(v); return true;} catch(e) {return false;}}},
351
+ mapwms: {value:false}
340
352
  },
341
353
  inputs:1,
342
354
  outputs:0,
@@ -366,6 +378,13 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
366
378
  }
367
379
  $("#node-input-zoom").spinner({min:0, max:18});
368
380
  $("#node-input-cluster").spinner({min:0, max:19});
381
+ $("#node-input-layer").on("change",function() {
382
+ if ($("#node-input-layer").val() === "Custom") {
383
+ $("#customMap").show();
384
+ } else {
385
+ $("#customMap").hide();
386
+ }
387
+ });
369
388
  }
370
389
  });
371
390
 
@@ -405,7 +424,11 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
405
424
  coords: {value:"false"},
406
425
  showgrid: {value:"false"},
407
426
  allowFileDrop: {value:"false"},
408
- path: {value:"/worldmap"}
427
+ path: {value:"/worldmap"},
428
+ mapname: {value:""},
429
+ mapurl: {value:""},
430
+ mapopt: {value:""},
431
+ mapwms: {value:false}
409
432
  },
410
433
  inputs:1,
411
434
  outputs:0,
@@ -438,6 +461,13 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
438
461
  }
439
462
  $("#node-input-zoom").spinner({min:0, max:18});
440
463
  $("#node-input-cluster").spinner({min:0, max:19});
464
+ $("#node-input-layer").on("change",function() {
465
+ if ($("#node-input-layer").val() === "Custom") {
466
+ $("#customMap").show();
467
+ } else {
468
+ $("#customMap").hide();
469
+ }
470
+ });
441
471
  }
442
472
  });
443
473
  }
package/worldmap.js CHANGED
@@ -1,19 +1,4 @@
1
1
  /* eslint-disable no-inner-declarations */
2
- /**
3
- * Copyright 2015, 2021 IBM Corp.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- **/
17
2
 
18
3
  module.exports = function(RED) {
19
4
  "use strict";
@@ -37,7 +22,6 @@ module.exports = function(RED) {
37
22
  node.layer = n.layer || "";
38
23
  node.cluster = n.cluster || "";
39
24
  node.maxage = n.maxage || "";
40
- if (n.maxage == 0) { node.maxage = "0"; }
41
25
  node.showmenu = n.usermenu || "show";
42
26
  node.layers = n.layers || "show";
43
27
  node.panlock = n.panlock || "false";
@@ -48,6 +32,13 @@ module.exports = function(RED) {
48
32
  node.showgrid = n.showgrid || "false";
49
33
  node.allowFileDrop = n.allowFileDrop || "false";
50
34
  node.path = n.path || "/worldmap";
35
+ node.mapname = n.mapname || "";
36
+ node.mapurl = n.mapurl || "";
37
+ node.mapopt = n.mapopt || "";
38
+ node.mapwms = n.mapwms || false;
39
+ try { node.mapopt2 = JSON.parse(node.mapopt); }
40
+ catch(e) { node.mapopt2 = null; }
41
+
51
42
  if (node.path.charAt(0) != "/") { node.path = "/" + node.path; }
52
43
  if (!sockets[node.path]) {
53
44
  var libPath = path.posix.join(RED.settings.httpNodeRoot, node.path, 'leaflet', 'sockjs.min.js');
@@ -69,11 +60,22 @@ module.exports = function(RED) {
69
60
  client.on('data', function(message) {
70
61
  message = JSON.parse(message);
71
62
  if (message.action === "connected") {
63
+ var m = {};
72
64
  var c = {init:true};
65
+ if (node.layer && node.layer == "Custom") {
66
+ m.name = node.mapname;
67
+ m.url = node.mapurl;
68
+ m.opt = node.mapopt2;
69
+ if (node.mapwms === true) { m.wms = true; }
70
+ client.write(JSON.stringify({command:{map:m}}));
71
+ c.layer = m.name;
72
+ }
73
+ else {
74
+ if (node.layer && node.layer.length > 0) { c.layer = node.layer; }
75
+ }
73
76
  if (node.lat && node.lat.length > 0) { c.lat = node.lat; }
74
77
  if (node.lon && node.lon.length > 0) { c.lon = node.lon; }
75
78
  if (node.zoom && node.zoom.length > 0) { c.zoom = node.zoom; }
76
- if (node.layer && node.layer.length > 0) { c.layer = node.layer; }
77
79
  if (node.cluster && node.cluster.length > 0) { c.cluster = node.cluster; }
78
80
  if (node.maxage && node.maxage.length > 0) { c.maxage = node.maxage; }
79
81
  c.showmenu = node.showmenu;
@@ -127,7 +129,6 @@ module.exports = function(RED) {
127
129
  });
128
130
  sockets[node.path].on('connection', callback);
129
131
  }
130
-
131
132
  var WorldMap = function(n) {
132
133
  worldMap(this, n);
133
134
  }
@@ -161,54 +162,54 @@ module.exports = function(RED) {
161
162
  }
162
163
 
163
164
  var ui = undefined;
165
+ try {
166
+ ui = RED.require("node-red-dashboard")(RED);
167
+ }
168
+ catch(e) {
169
+ RED.log.info("Node-RED Dashboard not found - ui_worldmap not installed.");
170
+ }
164
171
  setTimeout( function() {
165
- try {
166
- ui = RED.require("node-red-dashboard")(RED);
167
- if (ui) {
168
- function UIWorldMap(config) {
169
- try {
170
- var node = this;
171
- worldMap(node, config);
172
- var done = null;
173
- if (checkConfig(node, config)) {
174
- var html = HTML(ui, config);
175
- done = ui.addWidget({
176
- node: node,
177
- order: config.order,
178
- group: config.group,
179
- width: config.width,
180
- height: config.height,
181
- format: html,
182
- templateScope: "local",
183
- emitOnlyNewValues: false,
184
- forwardInputMessages: false,
185
- storeFrontEndInputAsState: false,
186
- convertBack: function (value) {
187
- return value;
188
- },
189
- beforeEmit: function(msg, value) {
190
- return { msg: { items: value } };
191
- },
192
- beforeSend: function (msg, orig) {
193
- if (orig) { return orig.msg; }
194
- },
195
- initController: function($scope, events) {
196
- }
197
- });
198
- }
199
- }
200
- catch (e) {
201
- console.log(e);
172
+ if (ui) {
173
+ function UIWorldMap(config) {
174
+ try {
175
+ var node = this;
176
+ worldMap(node, config);
177
+ var done = null;
178
+ if (checkConfig(node, config)) {
179
+ var html = HTML(ui, config);
180
+ done = ui.addWidget({
181
+ node: node,
182
+ order: config.order,
183
+ group: config.group,
184
+ width: config.width,
185
+ height: config.height,
186
+ format: html,
187
+ templateScope: "local",
188
+ emitOnlyNewValues: false,
189
+ forwardInputMessages: false,
190
+ storeFrontEndInputAsState: false,
191
+ convertBack: function (value) {
192
+ return value;
193
+ },
194
+ beforeEmit: function(msg, value) {
195
+ return { msg: { items: value } };
196
+ },
197
+ beforeSend: function (msg, orig) {
198
+ if (orig) { return orig.msg; }
199
+ },
200
+ initController: function($scope, events) {
201
+ }
202
+ });
202
203
  }
203
- node.on("close", function() {
204
- if (done) { done(); }
205
- });
206
204
  }
207
- setImmediate(function() { RED.nodes.registerType("ui_worldmap", UIWorldMap) });
205
+ catch (e) {
206
+ console.log(e);
207
+ }
208
+ node.on("close", function() {
209
+ if (done) { done(); }
210
+ });
208
211
  }
209
- }
210
- catch(e) {
211
- RED.log.info("Node-RED Dashboard not found - ui_worldmap not installed.");
212
+ setImmediate(function() { RED.nodes.registerType("ui_worldmap", UIWorldMap) });
212
213
  }
213
214
  }, 250);
214
215
 
@@ -503,7 +504,6 @@ module.exports = function(RED) {
503
504
  }
504
505
  RED.nodes.registerType("worldmap-hull",WorldMapHull);
505
506
 
506
-
507
507
  RED.httpNode.get("/.ui-worldmap", function(req, res) {
508
508
  res.send(ui ? "true": "false");
509
509
  });