Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Affix user dot on screen in user tracking mode #3589

Merged
merged 13 commits into from
Jan 20, 2016
Merged
Prev Previous commit
Next Next commit
[ios] Eliminated jump after flight to first location
Don’t update the user location annotation’s coordinates until after the transition to the first reported location is complete.
  • Loading branch information
1ec5 committed Jan 20, 2016
commit 251925568c72dfe49cbb6b3a36dcc9fc7d80eb66
5 changes: 4 additions & 1 deletion platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3032,7 +3032,10 @@ - (void)locationManager:(__unused CLLocationManager *)manager didUpdateLocations

if (! oldLocation || ! CLLocationCoordinate2DIsValid(oldLocation.coordinate) || [newLocation distanceFromLocation:oldLocation])
{
self.userLocation.location = newLocation;
if (self.userTrackingState != MGLUserTrackingStateBegan)
{
self.userLocation.location = newLocation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we potentially drop a fresher location if the old transition is still in progress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for the transition to the initial location when user tracking is switched on. That transition may take longer than a second and shouldn't be interrupted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first location is also likely to be relatively inaccurate and get preempted quickly by another update. Don't think this is a blocker here, just another reason to do #3610.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MapKit does a simple, easeTo-style animation to the first location, which makes it easier to accommodate intervening updates. By contrast, this branch uses a Google-style flyTo, which wouldn't be easy to modify mid-flight even after implementing #3610.

In their own ways, both MapKit and Google Maps favor context and continuity over up-to-the-second precision. If a particular application needs to go immediately to the actual user location, it can pass NO into -setUserTrackingMode:animated:, which is being made public in this PR.

}

// deselect user if applicable since we don't do callout tracking yet
if (self.selectedAnnotation == self.userLocation
Expand Down