Browse Source

feat: Only fly to latest marker if there was a new one

master
Konstantinos Kamaropoulos 5 years ago
parent
commit
33c4d5424b
  1. 14
      src/app/map/map.component.ts

14
src/app/map/map.component.ts

@ -50,8 +50,10 @@ export class MapComponent implements OnInit {
} else { } else {
data = await this.logsService.getUpdates(); data = await this.logsService.getUpdates();
} }
let newPointsCount = 0;
for (let log of data) { for (let log of data) {
if (log['gps_data']['status'] == 'A') { if (log['gps_data']['status'] == 'A') {
newPointsCount++;
let html = let html =
log['gps_data']['datestamp'] + log['gps_data']['datestamp'] +
' ' + ' ' +
@ -73,11 +75,13 @@ export class MapComponent implements OnInit {
} }
this.lastPoint = [log['gps_data']['longitude'], log['gps_data']['latitude']]; this.lastPoint = [log['gps_data']['longitude'], log['gps_data']['latitude']];
} }
this.map.flyTo({ if (newPointsCount) {
center: [this.lastPoint[0], this.lastPoint[1]], this.map.flyTo({
essential: true, // this animation is considered essential with respect to prefers-reduced-motion center: [this.lastPoint[0], this.lastPoint[1]],
zoom: 22 essential: true, // this animation is considered essential with respect to prefers-reduced-motion
}); zoom: 22
});
}
}); });
} }
} }

Loading…
Cancel
Save