Add weblink property to msg to setup a link to external page

to close #11
This commit is contained in:
Dave Conway-Jones 2017-03-20 16:05:40 +00:00
parent 3618cb85fb
commit 6dc383c497
4 changed files with 20 additions and 9 deletions

View File

@ -7,6 +7,7 @@ map web page for plotting "things" on.
![Map Image](https://dceejay.github.io/pages/images/redmap.png) ![Map Image](https://dceejay.github.io/pages/images/redmap.png)
### Changes ### 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.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.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. - 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** : <a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_new">font awesome</a> icon name. - **icon** : <a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_new">font awesome</a> icon name.
- **iconColor** : Standard CSS color name or #rrggbb hex value. - **iconColor** : Standard CSS color name or #rrggbb hex value.
- **photoUrl** : adds an image pointed at by the url to the popup box. - **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 <i>true</i> to remove the named marker. (default false) - **deleted** : set to <i>true</i> to remove the named marker. (default false)
- **addtoheatmap** : set to <i>false</i> to exlcude point from contributing to heatmap layer. (default true) - **addtoheatmap** : set to <i>false</i> 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) - **intensity** : set to a value of 0.1 - 1.0 to set the intensity of the point on heatmap layer. (default 1.0)

View File

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

View File

@ -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'}}); 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); layers["heat"] = new L.LayerGroup().addLayer(heat);
overlays["heatmap"] = layers["heat"]; overlays["heatmap"] = layers["heat"];
console.log("HEAT",heat);
// Add the drawing layer for fun... // Add the drawing layer for fun...
layers["drawing"] = new L.FeatureGroup(); layers["drawing"] = new L.FeatureGroup();
@ -872,6 +871,22 @@ function setMarker(data) {
if (data.hasOwnProperty("icon") || (!data.hasOwnProperty("radius"))) { if (data.hasOwnProperty("icon") || (!data.hasOwnProperty("radius"))) {
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; }
if (data.hasOwnProperty("photourl")) {
words += "<img src=\"" + data.photourl + "\" style=\"width:100%; margin-top:10px;\">";
delete data.photourl;
}
if (data.hasOwnProperty("photoUrl")) {
words += "<img src=\"" + data.photoUrl + "\" style=\"width:100%; margin-top:10px;\">";
delete data.photoUrl;
}
if (data.hasOwnProperty("weblink")) {
if (typeof data.weblink === "string") {
words += "<b><a href='"+ data.weblink + "' target='_new'>more information...</a></b><br/>";
} else {
words += "<b><a href='"+ data.weblink.url + "' target='_new'>" + data.weblink.name + "</a></b><br/>";
}
delete data.weblink;
}
for (var i in data) { for (var i in data) {
if (i != "name") { if (i != "name") {
if (typeof data[i] === "object") { if (typeof data[i] === "object") {
@ -881,12 +896,6 @@ function setMarker(data) {
} }
} }
} }
if (data.hasOwnProperty("photourl")) {
words += "<img src=\"" + data.photourl + "\" style=\"width:100%; margin-top:10px;\">";
}
if (data.hasOwnProperty("photoUrl")) {
words += "<img src=\"" + data.photoUrl + "\" style=\"width:100%; margin-top:10px;\">";
}
marker.bindPopup(words); marker.bindPopup(words);
marker._popup.dname = data.name; marker._popup.dname = data.name;
marker.ts = parseInt(Date.now()/1000); // save time we got this marker marker.ts = parseInt(Date.now()/1000); // save time we got this marker

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# date: Mar 4th 2017 - v1.0.23 # date: Mar 4th 2017 - v1.0.24
CACHE: CACHE:
index.html index.html