fix panit, use alt units, tweak popup alignments

This commit is contained in:
Dave Conway-Jones 2021-06-04 10:40:55 +01:00
parent ae359e37d0
commit 9592153fe8
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
4 changed files with 37 additions and 19 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### 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.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.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. - v2.13.4 - Fix list of map choices to be in sync. Fix popup auto sizing.

View File

@ -11,6 +11,7 @@ map web page for plotting "things" on.
### Updates ### 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.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.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. - 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 - **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"}}` - **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}}` - **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}}` - **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}}` - **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"}}` - **coords** - turns on and off a display of the current mouse co-ordinates. Values can be "deg", "dms", or "none" (default). - `{"command":{"coords":"deg"}}`

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "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.", "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": { "dependencies": {
"cgi": "0.3.1", "cgi": "0.3.1",

View File

@ -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 // 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("SIDC") && data.hasOwnProperty("options")) { delete data.options; }
if (data.hasOwnProperty("icon")) { delete data.icon; } if (data.hasOwnProperty("icon")) { delete data.icon; }
if (data.hasOwnProperty("iconColor")) { delete data.iconColor; } if (data.hasOwnProperty("iconColor")) { delete data.iconColor; }
@ -1763,7 +1776,7 @@ function setMarker(data) {
delete data.photoUrl; delete data.photoUrl;
} }
if (data.hasOwnProperty("videoUrl")) { if (data.hasOwnProperty("videoUrl")) {
words += '<video controls muted autoplay width="320"><source src="'+data.videoUrl+'" type="video/mp4">Your browser does not support the video tag.</video>'; words += '<video controls muted autoplay width="320" height="240"><source src="'+data.videoUrl+'" type="video/mp4">Your browser does not support the video tag.</video>';
delete data.videoUrl; delete data.videoUrl;
} }
if (data.hasOwnProperty("ttl")) { // save expiry time for this marker if (data.hasOwnProperty("ttl")) { // save expiry time for this marker
@ -1783,11 +1796,13 @@ function setMarker(data) {
var tgt = data.weblink.target || "_new"; var tgt = data.weblink.target || "_new";
words += "<b><a href='"+ data.weblink.url + "' target='"+ tgt + "'>" + data.weblink.name + "</a></b><br/>"; words += "<b><a href='"+ data.weblink.url + "' target='"+ tgt + "'>" + data.weblink.name + "</a></b><br/>";
} }
} else { }
else {
data.weblink.forEach(function(weblink){ data.weblink.forEach(function(weblink){
if (typeof weblink === "string") { if (typeof weblink === "string") {
words += "<b><a href='"+ weblink + "' target='_new'>more information...</a></b><br/>"; words += "<b><a href='"+ weblink + "' target='_new'>more information...</a></b><br/>";
} else { }
else {
var tgt = weblink.target || "_new"; var tgt = weblink.target || "_new";
words += "<b><a href='"+ weblink.url + "' target='"+ tgt + "'>" + weblink.name + "</a></b><br/>"; words += "<b><a href='"+ weblink.url + "' target='"+ tgt + "'>" + weblink.name + "</a></b><br/>";
} }
@ -1929,7 +1944,7 @@ function setMarker(data) {
layers[lay].addLayer(polygon); layers[lay].addLayer(polygon);
} }
} }
if (panit) { map.setView(ll,map.getZoom()); } if (panit === true) { map.setView(ll,map.getZoom()); }
if (p === true) { marker.openPopup(); } if (p === true) { marker.openPopup(); }
} }
@ -1946,7 +1961,7 @@ function doCommand(cmd) {
doTidyUp(cmd.clear); doTidyUp(cmd.clear);
} }
if (cmd.hasOwnProperty("panit")) { if (cmd.hasOwnProperty("panit")) {
if (cmd.panit == "true") { panit = true; } if (cmd.panit == true || cmd.panit === "true") { panit = true; }
else { panit = false; } else { panit = false; }
document.getElementById("panit").checked = panit; document.getElementById("panit").checked = panit;
} }