diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-30 19:25:46 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 19:25:46 +1300 |
commit | 1ffe251cbc09e2199c936d68f5c1f82363436da1 (patch) | |
tree | 0a1962ef178fa3c051c28e95b9a0101ed1d12e19 /web/app/view/MapMarkerController.js | |
parent | d10d51eb9def4e9ce77d053503ba3eccd3ad23aa (diff) | |
parent | 60fe1537206e2286423a7bc1ed5591b1f9c7a1d7 (diff) | |
download | etbsa-traccar-web-1ffe251cbc09e2199c936d68f5c1f82363436da1.tar.gz etbsa-traccar-web-1ffe251cbc09e2199c936d68f5c1f82363436da1.tar.bz2 etbsa-traccar-web-1ffe251cbc09e2199c936d68f5c1f82363436da1.zip |
Merge pull request #345 from Abyss777/show_events
Show events on map
Diffstat (limited to 'web/app/view/MapMarkerController.js')
-rw-r--r-- | web/app/view/MapMarkerController.js | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index 4ef55bb..97e7592 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -45,6 +45,7 @@ Ext.define('Traccar.view.MapMarkerController', { update: 'updateLatest' }, '#ReportRoute': { + add: 'addReportMarkers', load: 'loadReport', clear: 'clearReport' } @@ -197,13 +198,18 @@ Ext.define('Traccar.view.MapMarkerController', { }, loadReport: function (store, data) { - var i, position, point, geometry, marker, style; + var i, position, point; - this.clearReport(store); + this.addReportMarkers(store, data); if (data.length > 0) { this.reportRoute = []; for (i = 0; i < data.length; i++) { + position = data[i]; + point = ol.proj.fromLonLat([ + position.get('longitude'), + position.get('latitude') + ]); if (i === 0 || data[i].get('deviceId') !== data[i - 1].get('deviceId')) { this.reportRoute.push(new ol.Feature({ geometry: new ol.geom.LineString([]) @@ -211,25 +217,6 @@ Ext.define('Traccar.view.MapMarkerController', { this.reportRoute[this.reportRoute.length - 1].setStyle(this.getRouteStyle(data[i].get('deviceId'))); this.getView().getRouteSource().addFeature(this.reportRoute[this.reportRoute.length - 1]); } - position = data[i]; - - point = ol.proj.fromLonLat([ - position.get('longitude'), - position.get('latitude') - ]); - geometry = new ol.geom.Point(point); - - marker = new ol.Feature(geometry); - marker.set('record', position); - this.reportMarkers[position.get('id')] = marker; - this.getView().getReportSource().addFeature(marker); - - style = this.getReportMarker(position.get('deviceId'), position.get('course')); - /*style.getText().setText( - Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/ - - marker.setStyle(style); - this.reportRoute[this.reportRoute.length - 1].getGeometry().appendCoordinate(point); } @@ -237,7 +224,28 @@ Ext.define('Traccar.view.MapMarkerController', { } }, - clearReport: function (store) { + addReportMarkers: function (store, data) { + var i, position, point, geometry, marker, style; + this.clearReport(); + for (i = 0; i < data.length; i++) { + position = data[i]; + point = ol.proj.fromLonLat([ + position.get('longitude'), + position.get('latitude') + ]); + geometry = new ol.geom.Point(point); + marker = new ol.Feature(geometry); + marker.set('record', position); + style = this.getReportMarker(position.get('deviceId'), position.get('course')); + /*style.getText().setText( + Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/ + marker.setStyle(style); + this.reportMarkers[position.get('id')] = marker; + this.getView().getReportSource().addFeature(marker); + } + }, + + clearReport: function () { var key, i; if (this.reportRoute) { |