aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-08-28 10:23:46 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-08-28 10:23:46 -0700
commitc9e4d721718b8ba8c418f27e214c49a370924e71 (patch)
treef9aeeb9234cbe57929b2b4816bdd2f165804f085
parente83a51c9f14b7ddb45e4de155741e37df3e25c25 (diff)
downloadtrackermap-web-c9e4d721718b8ba8c418f27e214c49a370924e71.tar.gz
trackermap-web-c9e4d721718b8ba8c418f27e214c49a370924e71.tar.bz2
trackermap-web-c9e4d721718b8ba8c418f27e214c49a370924e71.zip
Fix device following
-rw-r--r--web/app/view/map/MapMarkerController.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/web/app/view/map/MapMarkerController.js b/web/app/view/map/MapMarkerController.js
index 15b1aec1..2fef4870 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());
+ }
}
},