From c9e4d721718b8ba8c418f27e214c49a370924e71 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 28 Aug 2021 10:23:46 -0700 Subject: Fix device following --- web/app/view/map/MapMarkerController.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'web') diff --git a/web/app/view/map/MapMarkerController.js b/web/app/view/map/MapMarkerController.js index 15b1aec..2fef487 100644 --- a/web/app/view/map/MapMarkerController.js +++ b/web/app/view/map/MapMarkerController.js @@ -238,7 +238,7 @@ Ext.define('Traccar.view.map.MapMarkerController', { }, animateMarker: function (marker, geometry, course) { - var start, end, duration, timeout, line, updatePosition, self; + var start, end, duration, timeout, line, updatePosition, self, follow; start = marker.getGeometry().getCoordinates(); end = geometry.getCoordinates(); @@ -246,12 +246,16 @@ Ext.define('Traccar.view.map.MapMarkerController', { duration = Traccar.Style.mapAnimateMarkerDuration; timeout = Traccar.Style.mapAnimateMarkerTimeout; self = this; + follow = this.lookupReference('deviceFollowButton').pressed; updatePosition = function (position, marker) { var coordinate, style; coordinate = marker.get('line').getCoordinateAt(position / (duration / timeout)); style = marker.getStyle(); marker.setGeometry(new ol.geom.Point(coordinate)); + if (marker === self.selectedMarker && follow) { + self.getView().getMapView().setCenter(marker.getGeometry().getCoordinates()); + } if (position < duration / timeout) { setTimeout(updatePosition, timeout, position + 1, marker); } else { @@ -344,10 +348,9 @@ Ext.define('Traccar.view.map.MapMarkerController', { if (this.isDeviceVisible(device)) { this.getView().getMarkersSource().addFeature(marker); } - } - - if (marker === this.selectedMarker && this.lookupReference('deviceFollowButton').pressed) { - this.getView().getMapView().setCenter(marker.getGeometry().getCoordinates()); + if (marker === this.selectedMarker && this.lookupReference('deviceFollowButton').pressed) { + this.getView().getMapView().setCenter(marker.getGeometry().getCoordinates()); + } } }, -- cgit v1.2.3