From 6dc383c49759e3d6bc6d52daeb067dc4036f0729 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 20 Mar 2017 16:05:40 +0000 Subject: [PATCH] Add weblink property to msg to setup a link to external page to close #11 --- README.md | 2 ++ package.json | 2 +- worldmap/index.html | 23 ++++++++++++++++------- worldmap/worldmap.appcache | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0e27190..a2d842a 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ map web page for plotting "things" on. ![Map Image](https://dceejay.github.io/pages/images/redmap.png) ### Changes + - v1.0.24 - Add `.weblink` property to allow links out to other information. Add more heatmap layer control - v1.0.23 - Add msg.payload.command.heatmap to allow setting of heatmap config. - v1.0.22 - Add example how to embed into Node-RED-Dashboard template. - v1.0.21 - If you specify range and icon then you get a marker and a range circle, if you just specify range with no icon, you just get a circle, and vice versa. @@ -45,6 +46,7 @@ Optional properties include - **icon** : font awesome icon name. - **iconColor** : Standard CSS color name or #rrggbb hex value. - **photoUrl** : adds an image pointed at by the url to the popup box. + - **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"}` - **deleted** : set to true to remove the named marker. (default false) - **addtoheatmap** : set to false to exlcude 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) diff --git a/package.json b/package.json index 1b15e3a..d451354 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-contrib-web-worldmap", - "version" : "1.0.23", + "version" : "1.0.24", "description" : "A Node-RED node to provide a web page of a world map for plotting things on.", "dependencies" : { "express": "^4.15.0", diff --git a/worldmap/index.html b/worldmap/index.html index b530366..25e56ec 100644 --- a/worldmap/index.html +++ b/worldmap/index.html @@ -619,7 +619,6 @@ overlays["day/night"] = layers["_daynight"]; var heat = L.heatLayer([], {radius:60, gradient:{0.2:'blue', 0.4:'lime', 0.6:'red', 0.8:'yellow', 1:'white'}}); layers["heat"] = new L.LayerGroup().addLayer(heat); overlays["heatmap"] = layers["heat"]; -console.log("HEAT",heat); // Add the drawing layer for fun... layers["drawing"] = new L.FeatureGroup(); @@ -872,6 +871,22 @@ function setMarker(data) { if (data.hasOwnProperty("icon") || (!data.hasOwnProperty("radius"))) { if (data.hasOwnProperty("icon")) { delete data.icon; } if (data.hasOwnProperty("iconColor")) { delete data.iconColor; } + if (data.hasOwnProperty("photourl")) { + words += ""; + delete data.photourl; + } + if (data.hasOwnProperty("photoUrl")) { + words += ""; + delete data.photoUrl; + } + if (data.hasOwnProperty("weblink")) { + if (typeof data.weblink === "string") { + words += "more information...
"; + } else { + words += "" + data.weblink.name + "
"; + } + delete data.weblink; + } for (var i in data) { if (i != "name") { if (typeof data[i] === "object") { @@ -881,12 +896,6 @@ function setMarker(data) { } } } - if (data.hasOwnProperty("photourl")) { - words += ""; - } - if (data.hasOwnProperty("photoUrl")) { - words += ""; - } marker.bindPopup(words); marker._popup.dname = data.name; marker.ts = parseInt(Date.now()/1000); // save time we got this marker diff --git a/worldmap/worldmap.appcache b/worldmap/worldmap.appcache index bc9da4b..9eaf8f6 100644 --- a/worldmap/worldmap.appcache +++ b/worldmap/worldmap.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# date: Mar 4th 2017 - v1.0.23 +# date: Mar 4th 2017 - v1.0.24 CACHE: index.html