diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-05-22 16:31:47 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-05-22 16:31:47 +1200 |
commit | f965e1b5de4010162bf4c132645a6ee7c6348b5d (patch) | |
tree | 24752f195c5a0c2c6ee8a8ae0125f919278c362e /web/app/view | |
parent | 96f34858dd2d095c75a72da6d10f5661ac51c042 (diff) | |
download | trackermap-server-f965e1b5de4010162bf4c132645a6ee7c6348b5d.tar.gz trackermap-server-f965e1b5de4010162bf4c132645a6ee7c6348b5d.tar.bz2 trackermap-server-f965e1b5de4010162bf4c132645a6ee7c6348b5d.zip |
Add functions to create style
Diffstat (limited to 'web/app/view')
-rw-r--r-- | web/app/view/map/MapController.js | 64 | ||||
-rw-r--r-- | web/app/view/report/ReportController.js | 7 |
2 files changed, 43 insertions, 28 deletions
diff --git a/web/app/view/map/MapController.js b/web/app/view/map/MapController.js index f141b6646..cfc669d4d 100644 --- a/web/app/view/map/MapController.js +++ b/web/app/view/map/MapController.js @@ -28,11 +28,47 @@ Ext.define('Traccar.view.map.MapController', { } } }, + + getLineStyle: function(color) { + return new ol.style.Style({ + stroke: new ol.style.Stroke({ + color: color, + width: 2 + }) + }); + }, + + getMarkerStyle: function(color) { + return new ol.style.Style({ + text: new ol.style.Text({ + text: '\uf041', + font: 'normal 32px FontAwesome', + textBaseline: 'Bottom', + fill: new ol.style.Fill({ + color: color + }), + stroke: new ol.style.Stroke({ + color: 'black', + width: 2 + }) + }) + }); + }, reportShow: function() { - var vectorSource = this.getView().vectorSource; + var data = Ext.getStore('Positions').getData().splice(); + data.sort(function(l, r) { + if (l < r) return -1; + if (r < l) return 1; + return 0; + }); + + var positions = []; + + //for (let p of data) + this.iconFeature = new ol.Feature({ //geometry: new ol.geom.Point(ol.proj.fromLonLat([-1.257778, 51.751944])) geometry: new ol.geom.LineString([ @@ -41,14 +77,7 @@ Ext.define('Traccar.view.map.MapController', { ]) }); - this.iconFeature.setStyle( - new ol.style.Style({ - stroke: new ol.style.Stroke({ - color: 'black', - width: 2 - }) - }) - ); + this.iconFeature.setStyle(this.getLineStyle('black')); vectorSource.addFeature(this.iconFeature); }, @@ -57,22 +86,7 @@ Ext.define('Traccar.view.map.MapController', { //this.getView().vectorSource.clear(); this.iconFeature.setGeometry(new ol.geom.Point(ol.proj.fromLonLat([-5.257778, 51.751944]))); - this.iconFeature.setStyle( - new ol.style.Style({ - text: new ol.style.Text({ - text: '\uf041', - font: 'normal 32px FontAwesome', - textBaseline: 'Bottom', - fill: new ol.style.Fill({ - color: 'red' - }), - stroke: new ol.style.Stroke({ - color: 'black', - width: 2 - }) - }) - }) - ); + this.iconFeature.setStyle(this.getMarkerStyle('red')); } }); diff --git a/web/app/view/report/ReportController.js b/web/app/view/report/ReportController.js index d62e87973..415cdfe3a 100644 --- a/web/app/view/report/ReportController.js +++ b/web/app/view/report/ReportController.js @@ -41,15 +41,16 @@ Ext.define('Traccar.view.report.ReportController', { deviceId: deviceId, from: from, to: to + }, + scope: this, + callback: function() { + this.fireEvent("reportShow"); } }); - - this.fireEvent("reportShow"); }, onClearClick: function() { Ext.getStore('Positions').removeAll(); - this.fireEvent("reportClear"); } |