enhancement - multiple weblink's (#155)

* enhancement - Multiple weblink's
This commit is contained in:
meeki007 2021-03-07 11:52:27 -05:00 committed by GitHub
parent f68cee3dce
commit cfb9d96215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -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.

View File

@ -1734,11 +1734,22 @@ 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 (typeof data.weblink === "string") { if (!Array.isArray(data.weblink) || !data.weblink.length) {
words += "<b><a href='"+ data.weblink + "' target='_new'>more information...</a></b><br/>"; if (typeof data.weblink === "string") {
words += "<b><a href='"+ data.weblink + "' target='_new'>more information...</a></b><br/>";
} else {
var tgt = data.weblink.target || "_new";
words += "<b><a href='"+ data.weblink.url + "' target='"+ tgt + "'>" + data.weblink.name + "</a></b><br/>";
}
} else { } else {
var tgt = data.weblink.target || "_new"; data.weblink.forEach(function(weblink){
words += "<b><a href='"+ data.weblink.url + "' target='"+ tgt + "'>" + data.weblink.name + "</a></b><br/>"; 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;
} }