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/Style.js | 2 +- web/app/view/GeofenceDialog.js | 5 ++++- web/app/view/GeofenceMap.js | 6 ++++-- web/app/view/MapController.js | 18 ++++++++++++++---- 4 files changed, 23 insertions(+), 8 deletions(-) (limited to 'web') diff --git a/web/app/Style.js b/web/app/Style.js index 4a77f56..302e6d4 100644 --- a/web/app/Style.js +++ b/web/app/Style.js @@ -71,7 +71,7 @@ Ext.define('Traccar.Style', { mapGeofenceTextColor: 'rgba(14, 88, 141, 1.0)', mapGeofenceColor: 'rgba(21, 127, 204, 1.0)', - mapGeofenceOverlay: 'rgba(21, 127, 204, 0.2)', + mapGeofenceOverlayOpacity: 0.2, mapGeofenceWidth: 5, mapGeofenceRadius: 9, diff --git a/web/app/view/GeofenceDialog.js b/web/app/view/GeofenceDialog.js index 7b2112b..f55a8b2 100644 --- a/web/app/view/GeofenceDialog.js +++ b/web/app/view/GeofenceDialog.js @@ -16,7 +16,7 @@ */ Ext.define('Traccar.view.GeofenceDialog', { - extend: 'Traccar.view.BaseDialog', + extend: 'Traccar.view.BaseEditDialog', requires: [ 'Traccar.view.GeofenceDialogController' @@ -55,6 +55,9 @@ Ext.define('Traccar.view.GeofenceDialog', { text: Strings.sharedArea, glyph: 'xf21d@FontAwesome', handler: 'onAreaClick' + }, { + text: Strings.sharedAttributes, + handler: 'showAttributesView' }, { xtype: 'tbfill' }, { diff --git a/web/app/view/GeofenceMap.js b/web/app/view/GeofenceMap.js index ad21f70..0a56b33 100644 --- a/web/app/view/GeofenceMap.js +++ b/web/app/view/GeofenceMap.js @@ -59,7 +59,7 @@ Ext.define('Traccar.view.GeofenceMap', { }, initMap: function () { - var map, featureOverlay, geometry; + var map, featureOverlay, geometry, fillColor; this.callParent(); map = this.map; @@ -74,13 +74,15 @@ Ext.define('Traccar.view.GeofenceMap', { this.mapView.setCenter(geometry.getCoordinates()[0][0]); } } + fillColor = ol.color.asArray(Traccar.Style.mapGeofenceColor); + fillColor[3] = Traccar.Style.mapGeofenceOverlayOpacity; featureOverlay = new ol.layer.Vector({ source: new ol.source.Vector({ features: this.features }), style: new ol.style.Style({ fill: new ol.style.Fill({ - color: Traccar.Style.mapGeofenceOverlay + color: fillColor }), stroke: new ol.style.Stroke({ color: Traccar.Style.mapGeofenceColor, 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 From 9099fd92f984b26090072f6553dff55b713589d7 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 29 Dec 2016 14:36:00 +0500 Subject: Do check in better way --- web/app/view/MapController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web') diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index 9929524..66d6809 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -124,7 +124,7 @@ Ext.define('Traccar.view.MapController', { var feature = new ol.Feature(Traccar.GeofenceConverter .wktToGeometry(this.getView().getMapView(), geofence.get('area'))); feature.setStyle(this.getGeofenceStyle(geofence.get('name'), - geofence.get('attributes') !== undefined ? geofence.get('attributes').color : undefined)); + geofence.get('attributes') ? geofence.get('attributes').color : null)); this.getView().getGeofencesSource().addFeature(feature); return true; }, this); -- cgit v1.2.3