mirror of
https://github.com/brianshea2/meshmap.net.git
synced 2024-11-13 17:14:23 -08:00
set marker opacity based on last seen time
This commit is contained in:
parent
6b366e8f6b
commit
3d290d47ec
|
@ -239,7 +239,9 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const position = L.latLng([latitude, longitude].map(x => x / 10000000))
|
const position = L.latLng([latitude, longitude].map(x => x / 10000000))
|
||||||
const tooltipContent = `${html(longName)} (${html(shortName)}) ${since(Math.max(...Object.values(seenBy)))}`
|
const lastSeen = Math.max(...Object.values(seenBy))
|
||||||
|
const opacity = 1.0 - (Date.now() / 1000 - lastSeen) / 172800
|
||||||
|
const tooltipContent = `${html(longName)} (${html(shortName)}) ${since(lastSeen)}`
|
||||||
const popupContent = `
|
const popupContent = `
|
||||||
<div class="title">${html(longName)} (${html(shortName)})</div>
|
<div class="title">${html(longName)} (${html(shortName)})</div>
|
||||||
<div>${nodeLink(nodeNum, id)} | ${html(role)} | ${html(hwModel)}</div>
|
<div>${nodeLink(nodeNum, id)} | ${html(role)} | ${html(hwModel)}</div>
|
||||||
|
@ -307,7 +309,7 @@
|
||||||
if (markersByNode[nodeNum] === undefined) {
|
if (markersByNode[nodeNum] === undefined) {
|
||||||
const searchString = `${longName} (${shortName}) ${id}`
|
const searchString = `${longName} (${shortName}) ${id}`
|
||||||
nodesBySearchString[searchString] = nodeNum
|
nodesBySearchString[searchString] = nodeNum
|
||||||
markersByNode[nodeNum] = L.marker(position, {alt: 'Node', searchString})
|
markersByNode[nodeNum] = L.marker(position, {alt: 'Node', opacity, searchString})
|
||||||
.bindTooltip(tooltipContent)
|
.bindTooltip(tooltipContent)
|
||||||
.bindPopup(popupContent, {maxWidth: 500})
|
.bindPopup(popupContent, {maxWidth: 500})
|
||||||
.on('popupopen', () => {
|
.on('popupopen', () => {
|
||||||
|
@ -316,6 +318,7 @@
|
||||||
})
|
})
|
||||||
.addTo(markers)
|
.addTo(markers)
|
||||||
} else {
|
} else {
|
||||||
|
markersByNode[nodeNum].setOpacity(opacity)
|
||||||
markersByNode[nodeNum].setTooltipContent(tooltipContent)
|
markersByNode[nodeNum].setTooltipContent(tooltipContent)
|
||||||
markersByNode[nodeNum].setPopupContent(popupContent)
|
markersByNode[nodeNum].setPopupContent(popupContent)
|
||||||
markersByNode[nodeNum].setLatLng(position)
|
markersByNode[nodeNum].setLatLng(position)
|
||||||
|
|
Loading…
Reference in a new issue