Fix: follow with heading tracking mode cancels user location indicator update (#3401)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
Evgenii Khrushchev
2025-05-05 13:54:06 +02:00
committed by GitHub
parent 3a3e90879c
commit a41da826d0

View File

@@ -4098,10 +4098,10 @@ static void *windowScreenContext = &windowScreenContext;
self.userTrackingMode = MLNUserTrackingModeFollow;
}
[self _setDirection:direction animated:animated];
[self _setDirection:direction center:kCLLocationCoordinate2DInvalid animated:animated];
}
- (void)_setDirection:(CLLocationDirection)direction animated:(BOOL)animated
- (void)_setDirection:(CLLocationDirection)direction center:(CLLocationCoordinate2D)center animated:(BOOL)animated
{
if (!_mbglMap)
{
@@ -4123,10 +4123,26 @@ static void *windowScreenContext = &windowScreenContext;
else
{
CGPoint anchor = self.userLocationAnnotationViewCenter;
self.mbglMap.easeTo(mbgl::CameraOptions()
.withBearing(direction)
.withAnchor(mbgl::ScreenCoordinate { anchor.x, anchor.y }),
MLNDurationFromTimeInterval(duration));
mbgl::CameraOptions cameraOptions = mbgl::CameraOptions()
.withBearing(direction)
.withAnchor(mbgl::ScreenCoordinate { anchor.x, anchor.y });
mbgl::AnimationOptions animationOptions;
animationOptions.duration.emplace(MLNDurationFromTimeInterval(duration));
if (CLLocationCoordinate2DIsValid(center))
{
cameraOptions.center = MLNLatLngFromLocationCoordinate2D(center);
if (duration)
{
CAMediaTimingFunction *function = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animationOptions.easing.emplace(MLNUnitBezierForMediaTimingFunction(function));
}
}
self.mbglMap.easeTo(cameraOptions, animationOptions);
}
}
@@ -6460,7 +6476,7 @@ static void *windowScreenContext = &windowScreenContext;
if (headingDirection >= 0 && self.userTrackingMode == MLNUserTrackingModeFollowWithHeading
&& self.userTrackingState != MLNUserTrackingStateBegan)
{
[self _setDirection:headingDirection animated:YES];
[self _setDirection:headingDirection center:self.userLocation.coordinate animated:YES];
[self updateUserLocationAnnotationView];
}
});