Better options for tracks

bump version to 1.5.37
pull/88/head
Dave Conway-Jones 6 years ago
parent eda12d207b
commit ff7793b5dd
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap
- v1.5.37 - Add .trackpoints to override default in tracks node. Let tracks optionally be on different layers. Fix marker changing layers Issue #85
- v1.5.36 - Fix contextmenu $name substitution
- v1.5.35 - Add msp.delete command to remove any layers not needed at start (array of names). Issue #83.
- v1.5.34 - Add command.contextmenu to set non-marker context menu (defaults to add marker).

@ -9,6 +9,7 @@ map web page for plotting "things" on.
### Updates
- v1.5.37 - Add .trackpoints to override default in tracks node. Let tracks optionally be on different layers. Fix marker changing layers Issue #85
- v1.5.36 - Fix contextmenu $name substitution. Issue #84
- v1.5.35 - Add msg.delete command to remove any layers not needed at start (array of names). Issue #83.
- v1.5.34 - Add command.contextmenu to set non-marker context menu (defaults to add marker).

@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
"version": "1.5.36",
"version": "1.5.37",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"cgi": "0.3.1",

@ -268,6 +268,14 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
<label for="node-input-depth"><i class="fa fa-map-marker"></i> Number of</label>
points in track <input type="text" id="node-input-depth" style="width:50%" placeholder="number - default 20">
</div>
<div class="form-row">
<label for="node-input-layer"><i class="fa fa-map"></i> Track Layer</label>
<select id="node-input-layer">
<option value="combined">on marker layer</option>
<option value="separate">one per marker layer</option>
<option value="single">single Track layer</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-file"></i> Name</label>
<input type="text" id="node-input-name" placeholder="name">
@ -276,6 +284,8 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
<script type="text/x-red" data-help-name="worldmap-tracks">
<p>Creates tracks lines based on a specified number of previous locations.</p>
<p>The number of tracked points can be set per marker by specifying <code>msg.payload.trackpoints</code> as part of the update for a marker.</p>
<p>You can also specify the msg.payload.color, weight, opacity and dashArray properties for the track if required.</p>
<p>Holds all the points in memory, so if you have a lot of points held for a
large depth then memory usage may become excessive.</p>
<p>To delete a track send a msg.payload containing both the name of the object and
@ -287,8 +297,9 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
category: 'location',
color:"darksalmon",
defaults: {
name: {value:""},
depth: {value:20},
name: {value:""}
layer: {value:"combined"}
},
inputs:1,
outputs:1,

@ -163,8 +163,9 @@ module.exports = function(RED) {
var WorldMapTracks = function(n) {
RED.nodes.createNode(this,n);
this.depth = Number(n.depth) || 20;
this.depth = parseInt(Number(n.depth) || 20);
this.pointsarray = {};
this.layer = n.layer || "combined"; // separate, single
var node = this;
node.on("input", function(msg) {
@ -179,6 +180,16 @@ module.exports = function(RED) {
if (!node.pointsarray.hasOwnProperty(msg.payload.name)) {
node.pointsarray[msg.payload.name] = [];
}
if (msg.payload.hasOwnProperty("trackpoints") && !isNaN(parseInt(msg.payload.trackpoints)) ) {
var tl = parseInt(msg.payload.trackpoints);
if (tl < 0) { tl = 0; }
if (node.pointsarray[msg.payload.name].length > tl) {
node.pointsarray[msg.payload.name] = node.pointsarray[msg.payload.name].slice(-tl);
}
node.depth = tl;
}
if (node.depth < 2) { return; } // if set less than 2 then don't bother.
node.pointsarray[msg.payload.name].push(msg.payload);
if (node.pointsarray[msg.payload.name].length > node.depth) {
node.pointsarray[msg.payload.name].shift();
@ -204,6 +215,15 @@ module.exports = function(RED) {
if (line.length > 1) { // only send track if two points or more
newmsg.payload.line = line;
newmsg.payload.name = msg.payload.name + "_";
if (node.layer === "separate") {
newmsg.payload.layer = msg.payload.layer + " tracks";
if (newmsg.payload.layer.indexOf('_') === 0) {
newmsg.payload.layer = newmsg.payload.layer.substr(1);
}
}
if (node.layer === "single") {
newmsg.payload.layer = "Tracks";
}
node.send(newmsg); // send the track
}
}

Loading…
Cancel
Save