enhancement - multiple weblink's (#155)
* enhancement - Multiple weblink's
This commit is contained in:
parent
f68cee3dce
commit
cfb9d96215
@ -61,7 +61,7 @@ Optional properties include
|
|||||||
- **ttl** : time to live, how long an individual marker stays on map in seconds (overrides general maxage setting, minimum 20 seconds)
|
- **ttl** : time to live, how long an individual marker stays on map in seconds (overrides general maxage setting, minimum 20 seconds)
|
||||||
- **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.
|
||||||
- **videoUrl** : adds an mp4 video pointed at by the url to the popup box. Ideally 320x240 in size.
|
- **videoUrl** : adds an mp4 video pointed at by the url to the popup box. Ideally 320x240 in size.
|
||||||
- **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":"https://news.bbc.co.uk", "target":"_new"}`
|
- **weblink** : adds a link to an external page. Either set a url as a *string*, or an *object* like `{"name":"BBC News", "url":"https://news.bbc.co.uk", "target":"_new"}`, or multiple links with an *array of objects* `[{"name":"BBC News", "url":"https://news.bbc.co.uk", "target":"_new"},{"name":"node-red", "url":"https://nodered.org", "target":"_new"}]`
|
||||||
- **addtoheatmap** : set to <i>false</i> to exclude point from contributing to the heatmap layer. (default true)
|
- **addtoheatmap** : set to <i>false</i> to exclude point from contributing to the heatmap layer. (default true)
|
||||||
- **intensity** : set to a value of 0.1 - 1.0 to set the intensity of the point on the heatmap layer. (default 1.0)
|
- **intensity** : set to a value of 0.1 - 1.0 to set the intensity of the point on the heatmap layer. (default 1.0)
|
||||||
- **popped** : set to true to automatically open the popup info box, set to false to close it.
|
- **popped** : set to true to automatically open the popup info box, set to false to close it.
|
||||||
|
@ -1734,12 +1734,23 @@ function setMarker(data) {
|
|||||||
marker.ts = parseInt(Date.now()/1000) + Number(maxage);
|
marker.ts = parseInt(Date.now()/1000) + Number(maxage);
|
||||||
}
|
}
|
||||||
if (data.hasOwnProperty("weblink")) {
|
if (data.hasOwnProperty("weblink")) {
|
||||||
|
if (!Array.isArray(data.weblink) || !data.weblink.length) {
|
||||||
if (typeof data.weblink === "string") {
|
if (typeof data.weblink === "string") {
|
||||||
words += "<b><a href='"+ data.weblink + "' target='_new'>more information...</a></b><br/>";
|
words += "<b><a href='"+ data.weblink + "' target='_new'>more information...</a></b><br/>";
|
||||||
} else {
|
} else {
|
||||||
var tgt = data.weblink.target || "_new";
|
var tgt = data.weblink.target || "_new";
|
||||||
words += "<b><a href='"+ data.weblink.url + "' target='"+ tgt + "'>" + data.weblink.name + "</a></b><br/>";
|
words += "<b><a href='"+ data.weblink.url + "' target='"+ tgt + "'>" + data.weblink.name + "</a></b><br/>";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
data.weblink.forEach(function(weblink){
|
||||||
|
if (typeof weblink === "string") {
|
||||||
|
words += "<b><a href='"+ weblink + "' target='_new'>more information...</a></b><br/>";
|
||||||
|
} else {
|
||||||
|
var tgt = weblink.target || "_new";
|
||||||
|
words += "<b><a href='"+ weblink.url + "' target='"+ tgt + "'>" + weblink.name + "</a></b><br/>";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
delete data.weblink;
|
delete data.weblink;
|
||||||
}
|
}
|
||||||
var p;
|
var p;
|
||||||
|
Loading…
Reference in New Issue
Block a user