aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-26 13:03:48 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-26 13:04:10 +1200
commit914abce63e9f85d13d0b6ee53ea55eb70643d71e (patch)
treef149a3b85a5cb82b69bb9ff1859c4b68127d8bf4 /web/app
parent7bbeccee30f5fa207d2754d977d9e5b7c4c857d8 (diff)
downloadtrackermap-server-914abce63e9f85d13d0b6ee53ea55eb70643d71e.tar.gz
trackermap-server-914abce63e9f85d13d0b6ee53ea55eb70643d71e.tar.bz2
trackermap-server-914abce63e9f85d13d0b6ee53ea55eb70643d71e.zip
Handle correctly empty report
Diffstat (limited to 'web/app')
-rw-r--r--web/app/view/MapController.js50
1 files changed, 26 insertions, 24 deletions
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index eee74099f..6ef9f91e6 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -147,37 +147,39 @@ Ext.define('Traccar.view.MapController', {
this.clearReport(store);
- this.reportRoute = new ol.Feature({
- geometry: new ol.geom.LineString([])
- });
- this.reportRoute.setStyle(this.getRouteStyle());
- this.getView().getRouteSource().addFeature(this.reportRoute);
+ if (data.length > 0) {
+ this.reportRoute = new ol.Feature({
+ geometry: new ol.geom.LineString([])
+ });
+ this.reportRoute.setStyle(this.getRouteStyle());
+ this.getView().getRouteSource().addFeature(this.reportRoute);
- for (i = 0; i < data.length; i++) {
- position = data[i];
+ 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);
- 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);
- marker = new ol.Feature(geometry);
- marker.set('record', position);
- this.reportMarkers[position.get('id')] = marker;
- this.getView().getReportSource().addFeature(marker);
+ style = this.getReportMarker();
+ style.getImage().setRotation(position.get('course') * Math.PI / 180);
+ /*style.getText().setText(
+ Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/
- style = this.getReportMarker();
- style.getImage().setRotation(position.get('course') * Math.PI / 180);
- /*style.getText().setText(
- Ext.Date.format(position.get('fixTime'), Traccar.Style.dateTimeFormat24));*/
+ marker.setStyle(style);
- marker.setStyle(style);
+ this.reportRoute.getGeometry().appendCoordinate(point);
+ }
- this.reportRoute.getGeometry().appendCoordinate(point);
+ this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize());
}
-
- this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize());
},
clearReport: function (store) {