From 1b8b172eaaab2aa738f45e39e3ca86a42d494bdd Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 29 Dec 2016 14:02:35 +0500 Subject: Add support for geofence colors --- web/app/view/MapController.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'web/app/view/MapController.js') diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index b8e2657..9929524 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -86,13 +86,22 @@ Ext.define('Traccar.view.MapController', { this.fireEvent('togglestate', state); }, - getGeofenceStyle: function (label) { + getGeofenceStyle: function (label, color) { + var fillColor, strokeColor; + if (color) { + fillColor = ol.color.asArray(color); + strokeColor = color; + } else { + fillColor = ol.color.asArray(Traccar.Style.mapGeofenceColor); + strokeColor = Traccar.Style.mapGeofenceColor; + } + fillColor[3] = Traccar.Style.mapGeofenceOverlayOpacity; return new ol.style.Style({ fill: new ol.style.Fill({ - color: Traccar.Style.mapGeofenceOverlay + color: fillColor }), stroke: new ol.style.Stroke({ - color: Traccar.Style.mapGeofenceColor, + color: strokeColor, width: Traccar.Style.mapGeofenceWidth }), text: new ol.style.Text({ @@ -114,7 +123,8 @@ Ext.define('Traccar.view.MapController', { Ext.getStore('Geofences').each(function (geofence) { var feature = new ol.Feature(Traccar.GeofenceConverter .wktToGeometry(this.getView().getMapView(), geofence.get('area'))); - feature.setStyle(this.getGeofenceStyle(geofence.get('name'))); + feature.setStyle(this.getGeofenceStyle(geofence.get('name'), + geofence.get('attributes') !== undefined ? geofence.get('attributes').color : undefined)); this.getView().getGeofencesSource().addFeature(feature); return true; }, this); -- cgit v1.2.3