Set Esc key to close all popups. And let feedback also close popup if rqd.

To close #146
This commit is contained in:
Dave Conway-Jones 2020-08-25 18:13:25 +01:00
parent 139f901928
commit 8d04663ee5
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
4 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v2.5.2 - Add boolean parameter to feedback call to allow auto close of popup on click. Set Esc key to close all open popups. Issue #146
- v2.5.1 - Add lat, lng and layer to feedback function. - v2.5.1 - Add lat, lng and layer to feedback function.
- v2.5.0 - Add minimap capability. - v2.5.0 - Add minimap capability.
- v2.4.2 - Fix editing injected shapes. - v2.4.2 - Fix editing injected shapes.

View File

@ -11,6 +11,7 @@ map web page for plotting "things" on.
### Updates ### Updates
- v2.5.2 - Add boolean parameter to feedback call to allow auto close of popup on click. Set Esc key to close all open popups. Issue #146
- v2.5.1 - Add lat, lng and layer to feedback function. - v2.5.1 - Add lat, lng and layer to feedback function.
- v2.5.0 - Add minimap capability. - v2.5.0 - Add minimap capability.
- v2.4.2 - Fix editing injected shapes. - v2.4.2 - Fix editing injected shapes.
@ -353,7 +354,7 @@ All actions also include a `msg._sessionid` property that indicates which client
There are some internal functions available to make interacting with Node-RED easier (e.g. from inside a user defined popup., these include: There are some internal functions available to make interacting with Node-RED easier (e.g. from inside a user defined popup., these include:
- **feedback()** : it takes two (or three) parameters, name, value, and optionally an action name (defaults to "feedback"), and can be used inside something like an input tag - `onchange='feedback(this.name,this.value)'`. Value can be a more complex object if required as long as it is serialisable. - **feedback()** : it takes 2, 3, or 4 parameters, name, value, and optionally an action name (defaults to "feedback"), and optional boolean to close the popup on calling this function, and can be used inside something like an input tag - `onchange='feedback(this.name,this.value,null,true)'`. Value can be a more complex object if required as long as it is serialisable.
- **delMarker()** : takes the name of the marker as a parameter. In a popup this can be specified as `$name` for dynamic substitution. - **delMarker()** : takes the name of the marker as a parameter. In a popup this can be specified as `$name` for dynamic substitution.

View File

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

@ -128,12 +128,18 @@ window.onunload = function() { if (ws) ws.close(); }
var onoffline = function() { if (!navigator.onLine) map.addLayer(layers["_countries"]); } var onoffline = function() { if (!navigator.onLine) map.addLayer(layers["_countries"]); }
// Set Ctl-Alt-3 to switch to 3d view
document.addEventListener ("keydown", function (ev) { document.addEventListener ("keydown", function (ev) {
// Set Ctl-Alt-3 to switch to 3d view
if (ev.ctrlKey && ev.altKey && ev.code === "Digit3") { if (ev.ctrlKey && ev.altKey && ev.code === "Digit3") {
ws.close(); ws.close();
window.location.href = "index3d.html"; window.location.href = "index3d.html";
} }
// Set Esc key to close all open popups
if (ev.keyCode === 27) {
map.eachLayer(function (layer) {
layer.closePopup();
});
}
}); });
// Create the Initial Map object. // Create the Initial Map object.
@ -576,9 +582,10 @@ var addThing = function() {
map.addLayer(layers[lay]); map.addLayer(layers[lay]);
} }
var feedback = function(n,v,a) { var feedback = function(n,v,a,c) {
var fp = markers[n]._latlng; var fp = markers[n]._latlng;
ws.send(JSON.stringify({action:a||"feedback", name:n, layer:markers[n].lay, lat:fp.lat, lon:fp.lng, value:v})); ws.send(JSON.stringify({action:a||"feedback", name:n, layer:markers[n].lay, lat:fp.lat, lon:fp.lng, value:v}));
if (c === true) { map.closePopup(); }
} }
// allow double right click to zoom out (if enabled) // allow double right click to zoom out (if enabled)