diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f33d40..24fdc25 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap
+ - v2.15.1 - Fix panit command to work, try to use alt units, popup alignments.
- v2.15.0 - let speed be text and specify units if required (kt,kn,knots,mph,kmh,kph) default m/s.
- v2.14.0 - Let geojson features be clickable if added as overlay.
- v2.13.4 - Fix list of map choices to be in sync. Fix popup auto sizing.
diff --git a/README.md b/README.md
index 68bf11e..26358d5 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ map web page for plotting "things" on.
### Updates
+- v2.15.1 - Fix panit command to work, try to use alt units, popup alignments.
- v2.15.0 - let speed be text and specify units if required (kt,kn,knots,mph,kmh,kph) default m/s.
- v2.14.0 - Let geojson features be clickable if added as overlay.
- v2.13.4 - Fix list of map choices to be in sync. Fix popup auto sizing.
@@ -394,6 +395,7 @@ Optional properties include
- **heatmap** - set heatmap options object see https://github.com/Leaflet/Leaflet.heat#reference
- **clear** - layer name - to clear a complete layer and remove from layer menu - `{"command":{"clear":"myOldLayer"}}`
- **panlock** - lock the map area to the current visible area. - `{"command":{"panlock":true}}`
+ - **panit** - auto pan to the latest marker updated. - `{"command":{"panit":true}}`
- **zoomlock** - locks the zoom control to the current value and removes zoom control - `{"command":{"zoomlock":true}}`
- **hiderightclick** - disables the right click that allows adding or deleting points on the map - `{"command":{"hiderightclick":true}}`
- **coords** - turns on and off a display of the current mouse co-ordinates. Values can be "deg", "dms", or "none" (default). - `{"command":{"coords":"deg"}}`
diff --git a/package.json b/package.json
index 0eddb22..4fa2cfd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
- "version": "2.15.0",
+ "version": "2.15.1",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"cgi": "0.3.1",
diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js
index 1166691..4d8d563 100644
--- a/worldmap/worldmap.js
+++ b/worldmap/worldmap.js
@@ -1748,9 +1748,22 @@ function setMarker(data) {
});
}
+ // tidy up altitude
+ if (data.hasOwnProperty("alt")) {
+ var reft = new RegExp('feet|ft','i');
+ var refm = new RegExp('metres|m','i');
+ if ( reft.test(""+data.alt) ) {
+ data.alt = (""+parseFloat(data.alt)).toFixed(2) + " ft";
+ }
+ else if ( refm.test(""+data.alt) ) {
+ data.alt = (""+parseFloat(data.alt)).toFixed(2) + " m";
+ }
+ else {
+ data.alt = (""+parseFloat(data.alt)).toFixed(2);
+ }
+ }
+
// remove icon from list of properties, then add all others to popup
- if (data.hasOwnProperty("alt")) { data.alt = (1*data.alt).toFixed(2); }
- //if (data.hasOwnProperty("speed")) { data.speed = parseFloat(data.speed).toFixed(2); }
if (data.hasOwnProperty("SIDC") && data.hasOwnProperty("options")) { delete data.options; }
if (data.hasOwnProperty("icon")) { delete data.icon; }
if (data.hasOwnProperty("iconColor")) { delete data.iconColor; }
@@ -1763,7 +1776,7 @@ function setMarker(data) {
delete data.photoUrl;
}
if (data.hasOwnProperty("videoUrl")) {
- words += '';
+ words += '';
delete data.videoUrl;
}
if (data.hasOwnProperty("ttl")) { // save expiry time for this marker
@@ -1777,21 +1790,23 @@ function setMarker(data) {
}
if (data.hasOwnProperty("weblink")) {
if (!Array.isArray(data.weblink) || !data.weblink.length) {
- if (typeof data.weblink === "string") {
- words += "more information... ";
- } else {
- var tgt = data.weblink.target || "_new";
- words += "" + data.weblink.name + " ";
- }
- } else {
- data.weblink.forEach(function(weblink){
- if (typeof weblink === "string") {
- words += "more information... ";
+ if (typeof data.weblink === "string") {
+ words += "more information... ";
} else {
- var tgt = weblink.target || "_new";
- words += "" + weblink.name + " ";
+ var tgt = data.weblink.target || "_new";
+ words += "" + data.weblink.name + " ";
}
- });
+ }
+ else {
+ data.weblink.forEach(function(weblink){
+ if (typeof weblink === "string") {
+ words += "more information... ";
+ }
+ else {
+ var tgt = weblink.target || "_new";
+ words += "" + weblink.name + " ";
+ }
+ });
}
delete data.weblink;
}
@@ -1929,7 +1944,7 @@ function setMarker(data) {
layers[lay].addLayer(polygon);
}
}
- if (panit) { map.setView(ll,map.getZoom()); }
+ if (panit === true) { map.setView(ll,map.getZoom()); }
if (p === true) { marker.openPopup(); }
}
@@ -1946,7 +1961,7 @@ function doCommand(cmd) {
doTidyUp(cmd.clear);
}
if (cmd.hasOwnProperty("panit")) {
- if (cmd.panit == "true") { panit = true; }
+ if (cmd.panit == true || cmd.panit === "true") { panit = true; }
else { panit = false; }
document.getElementById("panit").checked = panit;
}