aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/MapController.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/view/MapController.js')
-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) {