diff options
-rw-r--r-- | web/app/view/MapMarkerController.js | 34 | ||||
-rw-r--r-- | web/app/view/ReportController.js | 10 |
2 files changed, 22 insertions, 22 deletions
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index bda206e..97e7592 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -202,24 +202,26 @@ Ext.define('Traccar.view.MapMarkerController', { this.addReportMarkers(store, data); - 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([]) - })); - this.reportRoute[this.reportRoute.length - 1].setStyle(this.getRouteStyle(data[i].get('deviceId'))); - this.getView().getRouteSource().addFeature(this.reportRoute[this.reportRoute.length - 1]); + 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([]) + })); + this.reportRoute[this.reportRoute.length - 1].setStyle(this.getRouteStyle(data[i].get('deviceId'))); + this.getView().getRouteSource().addFeature(this.reportRoute[this.reportRoute.length - 1]); + } + this.reportRoute[this.reportRoute.length - 1].getGeometry().appendCoordinate(point); } - this.reportRoute[this.reportRoute.length - 1].getGeometry().appendCoordinate(point); - } - this.getView().getMapView().fit(this.reportRoute[0].getGeometry(), this.getView().getMap().getSize()); + this.getView().getMapView().fit(this.reportRoute[0].getGeometry(), this.getView().getMap().getSize()); + } }, addReportMarkers: function (store, data) { diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 50775ac..f8a01bc 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -197,12 +197,10 @@ Ext.define('Traccar.view.ReportController', { loadEvents: function (store, data) { var i, eventObject, positionIds = []; Ext.getStore('ReportRoute').removeAll(); - if (data.length > 0) { - for (i = 0; i < data.length; i++) { - eventObject = data[i]; - if (eventObject.get('positionId')) { - positionIds.push(eventObject.get('positionId')); - } + for (i = 0; i < data.length; i++) { + eventObject = data[i]; + if (eventObject.get('positionId')) { + positionIds.push(eventObject.get('positionId')); } } if (positionIds.length > 0) { |