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

Commit

Permalink
[ios] Use content inset to calculate edge padding (#6313)
Browse files Browse the repository at this point in the history
This reverts a previous change that used only the contentInset
when setting the center coordinate of the map view.
Instead of contentInset, edgePaddingForFollowing is used. This fixes
a regression that caused the user dot annotation to be misplaced
when the map was configured to show the annotation in any place other
than in the center of the map.

In addition, edgePaddingForFollowing is updated to account for
contentInset when it calculates its UIEdgeInsets. This fixes a bug
where the user dot would move to the center of the content frame
(when it was adjusted for content insets) but the map would not scroll
along with it yielding the effect of the user dot being misplaced.
  • Loading branch information
boundsj authored Sep 14, 2016
1 parent 8f3736f commit 922bb3b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4085,7 +4085,7 @@ - (void)didUpdateLocationWithUserTrackingAnimated:(BOOL)animated
- (void)didUpdateLocationIncrementallyAnimated:(BOOL)animated
{
[self _setCenterCoordinate:self.userLocation.location.coordinate
edgePadding:self.contentInset
edgePadding:self.edgePaddingForFollowing
zoomLevel:self.zoomLevel
direction:self.directionByFollowingWithCourse
duration:animated ? MGLUserLocationAnimationDuration : 0
Expand All @@ -4112,7 +4112,7 @@ - (void)didUpdateLocationSignificantlyAnimated:(BOOL)animated

__weak MGLMapView *weakSelf = self;
[self _flyToCamera:camera
edgePadding:self.contentInset
edgePadding:self.edgePaddingForFollowing
withDuration:animated ? -1 : 0
peakAltitude:-1
completionHandler:^{
Expand Down Expand Up @@ -4173,8 +4173,10 @@ - (UIEdgeInsets)edgePaddingForFollowing
CGRect boundsAroundCorrectPoint = CGRectOffset(bounds,
correctPoint.x - CGRectGetMidX(bounds),
correctPoint.y - CGRectGetMidY(bounds));
return UIEdgeInsetsMake(CGRectGetMinY(boundsAroundCorrectPoint) - CGRectGetMinY(bounds), 0,
CGRectGetMaxY(bounds) - CGRectGetMaxY(boundsAroundCorrectPoint), 0);
return UIEdgeInsetsMake(CGRectGetMinY(boundsAroundCorrectPoint) - CGRectGetMinY(bounds) + self.contentInset.top,
self.contentInset.left,
CGRectGetMaxY(bounds) - CGRectGetMaxY(boundsAroundCorrectPoint) + self.contentInset.bottom,
self.contentInset.right);
}

/// Returns the edge padding to apply during bifocal course tracking.
Expand Down

0 comments on commit 922bb3b

Please sign in to comment.