tidy up popup location and timing

Add countries layer if no internet
This commit is contained in:
Dave Conway-Jones 2019-02-28 18:58:45 +00:00
parent ac7ace9094
commit 677177575b
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
5 changed files with 38 additions and 16 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v1.5.28 - Tidy up popup location and timing. Auto add countries overlay if no internet.
- v1.5.27 - Add hide right click option to config panel - v1.5.27 - Add hide right click option to config panel
- v1.5.26 - Ensure all map tiles loaded over https - v1.5.26 - Ensure all map tiles loaded over https
- v1.5.25 - Add button command to allow user to add and remove buttons - v1.5.25 - Add button command to allow user to add and remove buttons

View File

@ -9,6 +9,7 @@ map web page for plotting "things" on.
### Updates ### Updates
- v1.5.28 - Tidy up popup location and timing. Auto add countries overlay if no internet.
- v1.5.27 - Add hide right click option to config panel - v1.5.27 - Add hide right click option to config panel
- v1.5.26 - Ensure all map tiles loaded over https - v1.5.26 - Ensure all map tiles loaded over https
- v1.5.25 - Add button command to allow user to add and remove buttons - v1.5.25 - Add button command to allow user to add and remove buttons

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "name": "node-red-contrib-web-worldmap",
"version": "1.5.27", "version": "1.5.28",
"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

@ -164,6 +164,7 @@ var connect = function() {
document.getElementById("foot").innerHTML = "<font color='#494'>"+ibmfoot+"</font>"; document.getElementById("foot").innerHTML = "<font color='#494'>"+ibmfoot+"</font>";
} }
ws.send(JSON.stringify({action:"connected"})); ws.send(JSON.stringify({action:"connected"}));
onoffline();
}; };
ws.onclose = function() { ws.onclose = function() {
console.log("DISCONNECTED"); console.log("DISCONNECTED");
@ -198,6 +199,10 @@ var connect = function() {
console.log("CONNECT TO",location.pathname + 'socket'); console.log("CONNECT TO",location.pathname + 'socket');
connect(); connect();
var onoffline = function() {
if (!navigator.onLine) { map.addLayer(layers["_countries"]); }
}
document.addEventListener ("keydown", function (ev) { document.addEventListener ("keydown", function (ev) {
if (ev.ctrlKey && ev.altKey && ev.code === "Digit3") { if (ev.ctrlKey && ev.altKey && ev.code === "Digit3") {
ws.close(); ws.close();
@ -1195,18 +1200,6 @@ function setMarker(data) {
}); });
marker = L.marker(ll, { title:data.name, icon:myicon, draggable:drag }); marker = L.marker(ll, { title:data.name, icon:myicon, draggable:drag });
} }
else if (data.icon && (data.icon.substr(0,3) === "fa-")) {
var col = data.iconColor || "#910000";
var imod = "";
if (data.icon.indexOf(" ") === -1) { imod = "fa-2x "; }
myMarker = L.divIcon({
className:"faicon",
html: '<center><i class="fa fa-fw '+imod+data.icon+'" style="color:'+col+'"></i></center>',
iconSize: [30, 30]
});
marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag});
labelOffset = [14,-16];
}
else if (data.icon && (data.icon.match(/^:.*:$/g))) { else if (data.icon && (data.icon.match(/^:.*:$/g))) {
var em = emojify(data.icon); var em = emojify(data.icon);
var col = data.iconColor || "#910000"; var col = data.iconColor || "#910000";
@ -1218,6 +1211,29 @@ function setMarker(data) {
marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag}); marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag});
labelOffset = [20,-12]; labelOffset = [20,-12];
} }
else if (data.icon && (data.icon.match(/^https?:.*$/))) {
myMarker = L.icon({
iconUrl: data.icon,
iconSize: [32, 32],
iconAnchor: [16, 16],
popupAnchor: [0, -16]
});
marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag});
labelOffset = [20,-12];
}
else if (data.icon && (data.icon.substr(0,3) === "fa-")) {
var col = data.iconColor || "#910000";
var imod = "";
if (data.icon.indexOf(" ") === -1) { imod = "fa-2x "; }
myMarker = L.divIcon({
className:"faicon",
html: '<center><i class="fa fa-fw '+imod+data.icon+'" style="color:'+col+'"></i></center>',
iconSize: [32, 32],
popupAnchor: [0, -16]
});
marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag});
labelOffset = [16,-16];
}
else { else {
myMarker = L.VectorMarkers.icon({ myMarker = L.VectorMarkers.icon({
icon: data.icon || "circle", icon: data.icon || "circle",
@ -1310,7 +1326,8 @@ function setMarker(data) {
var llc = data.lineColor; var llc = data.lineColor;
delete data.lat; delete data.lat;
delete data.lon; delete data.lon;
delete data.lineColor; if (data.layer) { delete data.layer; }
if (data.lineColor) { delete data.lineColor; }
if (data.draggable) { delete data.draggable; } if (data.draggable) { delete data.draggable; }
for (var i in data) { for (var i in data) {
if ((i != "name") && (i != "length")) { if ((i != "name") && (i != "length")) {
@ -1390,7 +1407,10 @@ function setMarker(data) {
} }
if (popped === true) { if (popped === true) {
if (popid == data.name) { if (popid == data.name) {
if (popmark) { popmark.closePopup(); } if (popmark) {
popmark.closePopup();
setTimeout(function() { marker.openPopup(); },100);
}
marker.openPopup(); marker.openPopup();
} }
else { popmark.openPopup(); } else { popmark.openPopup(); }

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# date: Feb 25th 2019 - v1.5.27 # date: Feb 28th 2019 - v1.5.28
CACHE: CACHE:
index.html index.html