move open popup to requested marker

pull/66/head
Dave Conway-Jones 6 years ago
parent 738e953549
commit 57c27d0fd9
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

@ -1,6 +1,7 @@
### Change Log for Node-RED Worldmap
- v1.5.7 - tidy up sidc entry, and drag-ability of nodes on drawing layer.
- v1.5.9 - Allow latest mark added to open popup, and allow `popped=false` to close.
- v1.5.7 - Tidy up sidc entry, and drag-ability of nodes on drawing layer.
- v1.5.6 - Add search command and clear search functionality.
- v1.5.5 - Allow multiple overlays to be enabled at once - Issue #53
- v1.5.4 - Allow remote update of the split position via `msg.command.split`

@ -9,7 +9,8 @@ map web page for plotting "things" on.
### Updates
- v1.5.7 - tidy up sidc entry, and drag-ability of nodes on drawing layer.
- v1.5.9 - Allow latest mark added to open popup, and allow `popped=false` to close.
- v1.5.7 - Tidy up sidc entry, and drag-ability of nodes on drawing layer.
- v1.5.6 - Add search command and clear search functionality.
- v1.5.5 - Allow multiple overlays to be enabled at once - Issue #53
- v1.5.4 - Allow remote update of the split position via `msg.command.split`
@ -66,7 +67,7 @@ Optional properties include
- **weblink** : adds a link to an external page for more information. Either set a url as a *string*, or an *object* like `{name:"BBC News", url:"news.bbc.co.uk", target:"_new"}`
- **addtoheatmap** : set to <i>false</i> to exclude point from contributing to heatmap layer. (default true)
- **intensity** : set to a value of 0.1 - 1.0 to set the intensity of the point on heatmap layer. (default 1.0)
- **popped** : set to true to automatically open the popup info box.
- **popped** : set to true to automatically open the popup info box, set to false to close it.
- **popup** : html to fill the popup if you don't want the automatic default of the properties list.
Any other `msg.payload` properties will be added to the icon popup text box.

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

@ -144,7 +144,7 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
icon: "white-globe.png",
align: "right",
label: function() {
return this.name||"world map";
return this.name||this.path.substr(1)||"world map";
},
labelStyle: function() {
return this.name?"node_label_italic":"";

@ -112,6 +112,7 @@ var startpos = [51.03, -1.379]; // Start location - somewhere in UK :-)
var startzoom = 10;
var map;
var allData = {};
var markers = {};
var polygons = {};
var layers = {};
@ -844,6 +845,7 @@ var delMarker = function(dname) {
map.removeLayer(markers[dname]);
delete markers[dname];
}
delete allData[dname];
ws.send(JSON.stringify({action:"delete", name:dname}));
map.closePopup();
}
@ -851,9 +853,9 @@ var delMarker = function(dname) {
// the MAIN add something to map function
function setMarker(data) {
//console.log("DATA",typeof data, data);
data = allData[data.name] = Object.assign(allData[data.name]||{},data);
var ll;
var lli = null;
var stay = popped;
var opt = {};
opt.color = data.color || "#910000";
opt.fillColor = data.fillColor || "#910000";
@ -1210,12 +1212,17 @@ function setMarker(data) {
delete data.weblink;
}
popped = stay;
if (data.hasOwnProperty("popped") && (data.popped == true) ) {
if (data.hasOwnProperty("popped") && (data.popped === true)) {
popped = true;
popid = data.name;
delete data.popped;
}
if (data.hasOwnProperty("popped") && (data.popped === false)) {
if ((popid == data.name) && (popmark)) {
popped = false;
popmark.closePopup();
}
}
// Add any remaining properties to the info box
delete data.lat;
@ -1245,7 +1252,6 @@ function setMarker(data) {
markers[data.name] = marker;
layers[lay].addLayer(marker);
}
if ((data.hdg != null) && (data.bearing == null)) { data.bearing = data.hdg; delete data.hdg; }
if (data.bearing != null) { // if there is a heading
if (data.speed != null) { data.length = parseFloat(data.speed || "0") * 50; } // and a speed
@ -1284,10 +1290,17 @@ function setMarker(data) {
}
}
if (panit) {
map.setView(ll,map.getZoom());
if (popped) {
map.setView(ll,map.getZoom());
popped = true;
}
else { map.setView(ll,map.getZoom()); }
}
if (popped) {
if (popid == data.name) { marker.openPopup(); }
if (popped === true) {
if (popid == data.name) {
if (popmark) { popmark.closePopup(); }
marker.openPopup();
}
else { popmark.openPopup(); }
}
}

@ -1,5 +1,5 @@
CACHE MANIFEST
# date: Oct 17th 2018 - v1.5.6
# date: Nov 9th 2018 - v1.5.9
CACHE:
index.html

Loading…
Cancel
Save