diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-22 22:11:50 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 22:11:50 +1300 |
commit | 987f2aad51e825eba983517b113412ff49777c42 (patch) | |
tree | a4922661ae14f4c7c3516023bf347445bb632ae9 /web/app | |
parent | 5bccab1d99586777b346d474b34b764e3b595a92 (diff) | |
parent | ca3109cce72bfc780960d468c2fcf6a75f39a859 (diff) | |
download | trackermap-web-987f2aad51e825eba983517b113412ff49777c42.tar.gz trackermap-web-987f2aad51e825eba983517b113412ff49777c42.tar.bz2 trackermap-web-987f2aad51e825eba983517b113412ff49777c42.zip |
Merge pull request #367 from Abyss777/custom_report_color
Add support for custom report colors
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/view/MapMarkerController.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index b978aafd..510e11bd 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -276,14 +276,26 @@ Ext.define('Traccar.view.MapMarkerController', { } }, - getRouteStyle: function (deviceId) { - var index = 0; - if (deviceId !== undefined) { - index = deviceId % Traccar.Style.mapRouteColor.length; + getReportColor: function (deviceId) { + var index, reportColor, device = Ext.getStore('Devices').getById(deviceId); + if (device) { + reportColor = device.get('attributes')['web.reportColor']; + } + if (reportColor) { + return reportColor; + } else { + index = 0; + if (deviceId !== undefined) { + index = deviceId % Traccar.Style.mapRouteColor.length; + } + return Traccar.Style.mapRouteColor[index]; } + }, + + getRouteStyle: function (deviceId) { return new ol.style.Style({ stroke: new ol.style.Stroke({ - color: Traccar.Style.mapRouteColor[index], + color: this.getReportColor(deviceId), width: Traccar.Style.mapRouteWidth }) }); @@ -313,11 +325,7 @@ Ext.define('Traccar.view.MapMarkerController', { }, getReportMarker: function (deviceId, angle) { - var index = 0; - if (deviceId !== undefined) { - index = deviceId % Traccar.Style.mapRouteColor.length; - } - return this.getMarkerStyle(false, Traccar.Style.mapRouteColor[index], angle, 'arrow'); + return this.getMarkerStyle(false, this.getReportColor(deviceId), angle, 'arrow'); }, resizeMarker: function (style, zoom) { |