diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-26 23:17:37 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-26 23:17:37 -0700 |
commit | d86a3ef187359fbe83a5dd950295868c4ef39d09 (patch) | |
tree | 9dab403a24a75bc9d25e0c9ae6af29c6d5341682 /modern/src/map/PositionsMap.js | |
parent | de199fa668b61ca1def0b8d18de8d666d8148361 (diff) | |
download | trackermap-web-d86a3ef187359fbe83a5dd950295868c4ef39d09.tar.gz trackermap-web-d86a3ef187359fbe83a5dd950295868c4ef39d09.tar.bz2 trackermap-web-d86a3ef187359fbe83a5dd950295868c4ef39d09.zip |
Implement marker colors
Diffstat (limited to 'modern/src/map/PositionsMap.js')
-rw-r--r-- | modern/src/map/PositionsMap.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/modern/src/map/PositionsMap.js b/modern/src/map/PositionsMap.js index 4a590b7b..a953ce3d 100644 --- a/modern/src/map/PositionsMap.js +++ b/modern/src/map/PositionsMap.js @@ -15,12 +15,24 @@ const PositionsMap = ({ positions }) => { const history = useHistory(); const devices = useSelector(state => state.devices.items); + const deviceColor = device => { + switch (device.status) { + case 'online': + return 'green'; + case 'offline': + return 'red'; + default: + return 'gray'; + } + }; + const createFeature = (devices, position) => { const device = devices[position.deviceId] || null; return { deviceId: position.deviceId, name: device ? device.name : '', category: device && (device.category || 'default'), + color: deviceColor(device), } }; @@ -81,7 +93,7 @@ const PositionsMap = ({ positions }) => { 'source': id, 'filter': ['!', ['has', 'point_count']], 'layout': { - 'icon-image': '{category}', + 'icon-image': '{category}-{color}', 'icon-allow-overlap': true, 'text-field': '{name}', 'text-allow-overlap': true, |