summaryrefslogtreecommitdiff
path: root/platform/ios/src
diff options
context:
space:
mode:
authorNadia Barbosa <nadiabarbosa@me.com>2018-09-17 15:45:22 -0700
committerNadia Barbosa <captainbarbosa@users.noreply.github.com>2018-10-02 18:28:53 -0400
commit7b243392e366907b35f819ac2d416475287d74ea (patch)
tree14d6ab0d322a9d33c51c903cbf0d1e90ac33ccd3 /platform/ios/src
parent41dd886ce5e0b20657d7b859b775949055129906 (diff)
downloadqtlocation-mapboxgl-7b243392e366907b35f819ac2d416475287d74ea.tar.gz
[ios] Add delegate method to specify the user location annotation’s position
Update method name More API drafting Add deprecation flag Add Swift delegate integration test Update method name and documentation Update deprecation notices Update method name Offset anchor point relative to contentFrame Update docs Only run through switch statement if delegate is unimplemented Account for content inset + refactor logic Adjust edgePaddingForFollowing Fix Swift delegate integration test Set up integration test Set up test location manager . Remove unused file reference from test Return CGPoint value from delegate method within integration test setup Test anchor points Make updateUserLocationAnnotationView public Refactor test Update test location manager Changelog entry Doc fixes
Diffstat (limited to 'platform/ios/src')
-rw-r--r--platform/ios/src/MGLMapView.h17
-rw-r--r--platform/ios/src/MGLMapView.mm18
-rw-r--r--platform/ios/src/MGLMapViewDelegate.h15
3 files changed, 42 insertions, 8 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index 02d146edcb..5312804cd2 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -416,7 +416,7 @@ MGL_EXPORT IB_DESIGNABLE
transition. If you don’t want to animate the change, use the
`-setUserLocationVerticalAlignment:animated:` method instead.
*/
-@property (nonatomic, assign) MGLAnnotationVerticalAlignment userLocationVerticalAlignment;
+@property (nonatomic, assign) MGLAnnotationVerticalAlignment userLocationVerticalAlignment __attribute__((deprecated("Use -[MGLMapViewDelegate mapViewUserLocationAnchorPoint:] instead.")));
/**
Sets the vertical alignment of the user location annotation within the
@@ -427,7 +427,20 @@ MGL_EXPORT IB_DESIGNABLE
position within the map view. If `NO`, the user location annotation
instantaneously moves to its new position.
*/
-- (void)setUserLocationVerticalAlignment:(MGLAnnotationVerticalAlignment)alignment animated:(BOOL)animated;
+- (void)setUserLocationVerticalAlignment:(MGLAnnotationVerticalAlignment)alignment animated:(BOOL)animated __attribute__((deprecated("Use -[MGLMapViewDelegate mapViewUserLocationAnchorPoint:] instead.")));
+
+/**
+ Updates the position of the user location annotation view by retreiving the user's last
+ known location.
+ */
+- (void)updateUserLocationAnnotationView;
+
+/**
+ Updates the position of the user location annotation view by retreiving the user's last
+ known location with a specified duration.
+ @param duration The duration to animate the change in seconds.
+*/
+- (void)updateUserLocationAnnotationViewAnimatedWithDuration:(NSTimeInterval)duration;
/**
A Boolean value indicating whether the user location annotation may display a
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 12c86f1d97..8fdd393e48 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -5280,9 +5280,9 @@ public:
correctPoint.x - CGRectGetMidX(bounds),
correctPoint.y - CGRectGetMidY(bounds));
return UIEdgeInsetsMake(CGRectGetMinY(boundsAroundCorrectPoint) - CGRectGetMinY(bounds),
- self.contentInset.left,
+ CGRectGetMaxX(boundsAroundCorrectPoint) - CGRectGetMaxX(bounds),
CGRectGetMaxY(bounds) - CGRectGetMaxY(boundsAroundCorrectPoint),
- self.contentInset.right);
+ CGRectGetMaxX(bounds) - CGRectGetMaxX(boundsAroundCorrectPoint));
}
/// Returns the edge padding to apply during bifocal course tracking.
@@ -5998,15 +5998,21 @@ public:
/// the overall map view (but respecting the content inset).
- (CGPoint)userLocationAnnotationViewCenter
{
+ if ([self.delegate respondsToSelector:@selector(mapViewUserLocationAnchorPoint:)])
+ {
+ CGPoint anchorPoint = [self.delegate mapViewUserLocationAnchorPoint:self];
+ return CGPointMake(anchorPoint.x + self.contentInset.left, anchorPoint.y + self.contentInset.top);
+ }
+
CGRect contentFrame = UIEdgeInsetsInsetRect(self.contentFrame, self.edgePaddingForFollowingWithCourse);
+
if (CGRectIsEmpty(contentFrame))
{
contentFrame = self.contentFrame;
}
+
CGPoint center = CGPointMake(CGRectGetMidX(contentFrame), CGRectGetMidY(contentFrame));
-
- // When tracking course, it’s more important to see the road ahead, so
- // weight the user dot down towards the bottom.
+
switch (self.userLocationVerticalAlignment) {
case MGLAnnotationVerticalAlignmentCenter:
break;
@@ -6017,7 +6023,7 @@ public:
center.y = CGRectGetMaxY(contentFrame);
break;
}
-
+
return center;
}
diff --git a/platform/ios/src/MGLMapViewDelegate.h b/platform/ios/src/MGLMapViewDelegate.h
index 4bd1a95c9b..77dd2e4ef4 100644
--- a/platform/ios/src/MGLMapViewDelegate.h
+++ b/platform/ios/src/MGLMapViewDelegate.h
@@ -308,6 +308,21 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)mapView:(MGLMapView *)mapView didChangeUserTrackingMode:(MGLUserTrackingMode)mode animated:(BOOL)animated;
+/**
+ Returns a screen coordinate at which to position the user location annotation.
+ This coordinate is relative to the map view’s origin after applying the map view’s
+ content insets.
+
+ When unimplemented, the user location annotation is aligned within the center of
+ the map view with respect to the content insets.
+
+ This method will override any values set by `MGLMapView.userLocationVerticalAlignment`
+ or `-[MGLMapView setUserLocationVerticalAlignment:]`.
+
+ @param mapView The map view that is tracking the user's location.
+ */
+- (CGPoint)mapViewUserLocationAnchorPoint:(MGLMapView *)mapView;
+
#pragma mark Managing the Appearance of Annotations
/**