summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2018-02-09 10:05:12 -0500
committerJulian Rex <julian.rex@mapbox.com>2018-02-09 16:33:29 -0500
commited00f2516b4b49fd2f847b42b0636790a90babf6 (patch)
tree55a734a72cbbddc4c8090957a5995d043dbf1c5f
parent324b7580403de343f02147941eec3bb7b5cc9e9a (diff)
downloadqtlocation-mapboxgl-ed00f2516b4b49fd2f847b42b0636790a90babf6.tar.gz
[ios] Switched MGLCameraChangeReason to use NS_OPTIONS to allow multiple reasons to be specified (e.g. concurrent pan/rotate)
-rw-r--r--platform/ios/app/MBXViewController.m37
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj6
-rw-r--r--platform/ios/src/MGLCameraChange.h45
-rw-r--r--platform/ios/src/MGLCameraChange.m16
-rw-r--r--platform/ios/src/MGLMapView.mm61
-rw-r--r--platform/ios/src/MGLMapViewDelegate.h56
-rw-r--r--platform/ios/test/MGLMapViewDelegateIntegrationTests.swift6
-rw-r--r--platform/ios/uitest/MapViewTests.m2
8 files changed, 91 insertions, 138 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 03931170c4..dedf148123 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -204,22 +204,6 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
}
[self presentViewController:alertController animated:YES completion:nil];
}
-
- // Add fall-through single tap gesture recognizer. This will be called when
- // the map view's tap recognizers fail.
-
- // NOTE: Since MBXViewController implements `mapView:didSingleTapAtCoordinate` the following
- // gesture recognizer WILL NOT be triggered, since the default single tap gesture does not fail.
- //
- // If you need a custom tap gesture to be trigger consider not implementing `mapView:didSingleTapAtCoordinate`
-
- UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
- for (UIGestureRecognizer *gesture in self.mapView.gestureRecognizers) {
- if ([gesture isKindOfClass:[UITapGestureRecognizer class]]) {
- [singleTap requireGestureRecognizerToFail:gesture];
- }
- }
- [self.mapView addGestureRecognizer:singleTap];
}
- (void)saveState:(__unused NSNotification *)notification
@@ -1574,14 +1558,6 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
#pragma mark - User Actions
-- (void)handleSingleTap:(UITapGestureRecognizer *)singleTap {
- [self.navigationController setNavigationBarHidden:!self.navigationController.navigationBarHidden animated:YES];
-
- // This is how you'd get the coordinate for the point where the user tapped:
- // CGPoint tapPoint = [singleTap locationInView:self.mapView];
- // CLLocationCoordinate2D tapCoordinate = [self.mapView convertPoint:tapPoint toCoordinateFromView:nil];
-}
-
- (IBAction)handleLongPress:(UILongPressGestureRecognizer *)longPress
{
if (longPress.state == UIGestureRecognizerStateBegan)
@@ -1904,27 +1880,20 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
_usingLocaleBasedCountryLabels = [[self bestLanguageForUser] isEqualToString:@"en"];
}
-- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera reason:(MGLCameraChangeReason)reason
-{
- return YES;
-}
-
-- (void)mapView:(MGLMapView *)mapView regionWillChangeAnimated:(BOOL)animated reason:(MGLCameraChangeReason)reason
-{
-}
-
- (void)mapViewRegionIsChanging:(MGLMapView *)mapView reason:(MGLCameraChangeReason)reason
{
[self updateHUD];
}
-- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated reason:(MGLCameraChangeReason)reason
+- (void)mapView:(MGLMapView *)mapView regionDidChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated
{
[self updateHUD];
}
- (void)mapView:(MGLMapView *)mapView didSingleTapAtCoordinate:(CLLocationCoordinate2D)coordinate
{
+ [self.navigationController setNavigationBarHidden:!self.navigationController.navigationBarHidden animated:YES];
+
#if 0
MGLPointAnnotation *annot = [[MGLPointAnnotation alloc] init];
annot.coordinate = coordinate;
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 1f193f0623..202872d01a 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -251,8 +251,6 @@
AC518E00201BB55A00EBC820 /* MGLTelemetryConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = AC518DFD201BB55A00EBC820 /* MGLTelemetryConfig.h */; };
AC518E03201BB56000EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; };
AC518E04201BB56100EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; };
- CA55CD3F202C16AA00CE7095 /* MGLCameraChange.m in Sources */ = {isa = PBXBuildFile; fileRef = CA55CD3D202C16A900CE7095 /* MGLCameraChange.m */; };
- CA55CD40202C16AA00CE7095 /* MGLCameraChange.m in Sources */ = {isa = PBXBuildFile; fileRef = CA55CD3D202C16A900CE7095 /* MGLCameraChange.m */; };
CA55CD41202C16AA00CE7095 /* MGLCameraChange.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChange.h */; settings = {ATTRIBUTES = (Public, ); }; };
CA55CD42202C16AA00CE7095 /* MGLCameraChange.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChange.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -760,7 +758,6 @@
96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationHeadingIndicator.h; sourceTree = "<group>"; };
AC518DFD201BB55A00EBC820 /* MGLTelemetryConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTelemetryConfig.h; sourceTree = "<group>"; };
AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLTelemetryConfig.m; sourceTree = "<group>"; };
- CA55CD3D202C16A900CE7095 /* MGLCameraChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLCameraChange.m; sourceTree = "<group>"; };
CA55CD3E202C16AA00CE7095 /* MGLCameraChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChange.h; sourceTree = "<group>"; };
DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = "<group>"; };
DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = "<group>"; };
@@ -1462,7 +1459,6 @@
DAD165851CF4D08B001FF4B9 /* Telemetry */,
355ADFF91E9281C300F3939D /* Views */,
CA55CD3E202C16AA00CE7095 /* MGLCameraChange.h */,
- CA55CD3D202C16A900CE7095 /* MGLCameraChange.m */,
DA704CC01F65A475004B3F28 /* MGLMapAccessibilityElement.h */,
DA704CC11F65A475004B3F28 /* MGLMapAccessibilityElement.mm */,
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.h */,
@@ -2417,7 +2413,6 @@
35136D3F1D42273000C20EFD /* MGLLineStyleLayer.mm in Sources */,
DA704CC41F65A475004B3F28 /* MGLMapAccessibilityElement.mm in Sources */,
DA72620D1DEEE3480043BB89 /* MGLOpenGLStyleLayer.mm in Sources */,
- CA55CD3F202C16AA00CE7095 /* MGLCameraChange.m in Sources */,
DA88481A1CBAFA6200AB86E3 /* MGLAccountManager.m in Sources */,
3510FFFB1D6DCC4700F413B2 /* NSCompoundPredicate+MGLAdditions.mm in Sources */,
AC518E03201BB56000EBC820 /* MGLTelemetryConfig.m in Sources */,
@@ -2508,7 +2503,6 @@
35136D401D42273000C20EFD /* MGLLineStyleLayer.mm in Sources */,
DA704CC51F65A475004B3F28 /* MGLMapAccessibilityElement.mm in Sources */,
DA72620E1DEEE3480043BB89 /* MGLOpenGLStyleLayer.mm in Sources */,
- CA55CD40202C16AA00CE7095 /* MGLCameraChange.m in Sources */,
DAA4E42F1CBB730400178DFB /* MGLCompactCalloutView.m in Sources */,
3510FFFC1D6DCC4700F413B2 /* NSCompoundPredicate+MGLAdditions.mm in Sources */,
AC518E04201BB56100EBC820 /* MGLTelemetryConfig.m in Sources */,
diff --git a/platform/ios/src/MGLCameraChange.h b/platform/ios/src/MGLCameraChange.h
index bfd956d66d..c2f7728f2c 100644
--- a/platform/ios/src/MGLCameraChange.h
+++ b/platform/ios/src/MGLCameraChange.h
@@ -1,14 +1,35 @@
#import "MGLFoundation.h"
-typedef NSString *MGLCameraChangeReason NS_TYPED_ENUM;
-
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonUnknown;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonProgramatic;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGestureResetNorth;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGesturePan;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGesturePinch;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGestureRotate;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGestureDoubleTap;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGestureTwoFingerSingleTap;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGestureQuickZoom;
-extern MGL_EXPORT const MGLCameraChangeReason MGLCameraChangeReasonGesturePitchStart;
+typedef NS_OPTIONS(NSUInteger, MGLCameraChangeReason)
+{
+ /// No reason for the camera move is specified.
+ MGLCameraChangeReasonNone = 0,
+
+ /// Set when a public API that moves the camera is called. This may be set for some gestures
+ MGLCameraChangeReasonProgrammatic = 1 << 0,
+
+ /// User tapped the compass to reset to North
+ MGLCameraChangeReasonResetNorth = 1 << 1,// Tap on compass
+
+ /// User panned the map.
+ MGLCameraChangeReasonGesturePan = 1 << 2,
+
+ /// User pinched to zoom in/out
+ MGLCameraChangeReasonGesturePinch = 1 << 3,
+
+ // User rotated the map
+ MGLCameraChangeReasonGestureRotate = 1 << 4,
+
+ /// User zoomed the map in
+ MGLCameraChangeReasonGestureZoomIn = 1 << 5,// One finger double tap
+
+ /// User zoomed the map out
+ MGLCameraChangeReasonGestureZoomOut = 1 << 6,// Two finger single tap
+
+ /// User long pressed on the map for a quick zoom
+ MGLCameraChangeReasonGestureQuickZoom = 1 << 7,// Long press
+
+ // User panned with two fingers to tilt the map
+ MGLCameraChangeReasonGesturePitch = 1 << 8// Two finger drag
+};
+
diff --git a/platform/ios/src/MGLCameraChange.m b/platform/ios/src/MGLCameraChange.m
deleted file mode 100644
index 02f00fc990..0000000000
--- a/platform/ios/src/MGLCameraChange.m
+++ /dev/null
@@ -1,16 +0,0 @@
-#import "MGLCameraChange.h"
-
-#define MGL_CAMERA_CHANGE_REASON_DEF(name) const MGLCameraChangeReason name = @ #name
-
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonUnknown);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonProgramatic);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGestureResetNorth);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGesturePan);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGesturePinch);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGestureRotate);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGestureDoubleTap);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGestureTwoFingerSingleTap);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGestureQuickZoom);
-MGL_CAMERA_CHANGE_REASON_DEF(MGLCameraChangeReasonGesturePitchStart);
-
-#undef MGL_CAMERA_CHANGE_REASON_DEF
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index bf9c8626e7..ea437887c4 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -553,7 +553,7 @@ public:
options.padding = padding;
options.zoom = 0;
- _cameraChangeReason = MGLCameraChangeReasonUnknown;
+ _cameraChangeReason = MGLCameraChangeReasonNone;
_mbglMap->jumpTo(options);
_pendingLatitude = NAN;
@@ -1241,7 +1241,7 @@ public:
- (void)handleCompassTapGesture:(__unused id)sender
{
- self.cameraChangeReason = MGLCameraChangeReasonGestureResetNorth;
+ self.cameraChangeReason |= MGLCameraChangeReasonResetNorth;
[self resetNorthAnimated:YES];
@@ -1314,7 +1314,7 @@ public:
MGLMapCamera *oldCamera = self.camera;
- self.cameraChangeReason = MGLCameraChangeReasonGesturePan;
+ self.cameraChangeReason |= MGLCameraChangeReasonGesturePan;
if (pan.state == UIGestureRecognizerStateBegan)
{
@@ -1384,7 +1384,7 @@ public:
CGPoint centerPoint = [self anchorPointForGesture:pinch];
MGLMapCamera *oldCamera = self.camera;
- self.cameraChangeReason = MGLCameraChangeReasonGesturePinch;
+ self.cameraChangeReason |= MGLCameraChangeReasonGesturePinch;
if (pinch.state == UIGestureRecognizerStateBegan)
{
@@ -1483,7 +1483,7 @@ public:
CGPoint centerPoint = [self anchorPointForGesture:rotate];
MGLMapCamera *oldCamera = self.camera;
- self.cameraChangeReason = MGLCameraChangeReasonGestureRotate;
+ self.cameraChangeReason |= MGLCameraChangeReasonGestureRotate;
if (rotate.state == UIGestureRecognizerStateBegan)
{
@@ -1681,7 +1681,7 @@ public:
if (doubleTap.state == UIGestureRecognizerStateEnded)
{
- self.cameraChangeReason = MGLCameraChangeReasonGestureDoubleTap;
+ self.cameraChangeReason |= MGLCameraChangeReasonGestureZoomIn;
MGLMapCamera *oldCamera = self.camera;
@@ -1718,7 +1718,7 @@ public:
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonGestureTwoFingerSingleTap;
+ self.cameraChangeReason |= MGLCameraChangeReasonGestureZoomOut;
if (twoFingerTap.state == UIGestureRecognizerStateBegan)
{
@@ -1757,7 +1757,7 @@ public:
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonGestureQuickZoom;
+ self.cameraChangeReason |= MGLCameraChangeReasonGestureQuickZoom;
if (quickZoom.state == UIGestureRecognizerStateBegan)
{
@@ -1802,7 +1802,7 @@ public:
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonGesturePitchStart;
+ self.cameraChangeReason |= MGLCameraChangeReasonGesturePitch;
if (twoFingerDrag.state == UIGestureRecognizerStateBegan)
{
@@ -2900,7 +2900,7 @@ public:
{
self.userTrackingMode = MGLUserTrackingModeNone;
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
[self _setCenterCoordinate:centerCoordinate edgePadding:self.contentInset zoomLevel:zoomLevel direction:direction duration:animated ? MGLAnimationDuration : 0 animationTimingFunction:nil completionHandler:completion];
}
@@ -2952,7 +2952,7 @@ public:
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
_mbglMap->easeTo(cameraOptions, animationOptions);
}
@@ -2977,7 +2977,7 @@ public:
if (zoomLevel == self.zoomLevel) return;
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
CGFloat duration = animated ? MGLAnimationDuration : 0;
@@ -3068,7 +3068,7 @@ public:
{
self.userTrackingMode = MGLUserTrackingModeNone;
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
[self _setVisibleCoordinates:coordinates count:count edgePadding:insets direction:direction duration:duration animationTimingFunction:function completionHandler:completion];
}
@@ -3120,7 +3120,7 @@ public:
[self willChangeValueForKey:@"visibleCoordinateBounds"];
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
_mbglMap->easeTo(cameraOptions, animationOptions);
[self didChangeValueForKey:@"visibleCoordinateBounds"];
@@ -3155,7 +3155,7 @@ public:
CGFloat duration = animated ? MGLAnimationDuration : 0;
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
if (self.userTrackingMode == MGLUserTrackingModeNone)
{
@@ -3242,7 +3242,7 @@ public:
[self willChangeValueForKey:@"camera"];
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera edgePadding:edgePadding];
_mbglMap->easeTo(cameraOptions, animationOptions);
@@ -3301,7 +3301,7 @@ public:
[self willChangeValueForKey:@"camera"];
_mbglMap->cancelTransitions();
- self.cameraChangeReason = MGLCameraChangeReasonProgramatic;
+ self.cameraChangeReason |= MGLCameraChangeReasonProgrammatic;
mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera edgePadding:insets];
_mbglMap->flyTo(cameraOptions, animationOptions);
@@ -3467,20 +3467,7 @@ public:
- (void)resetCameraChangeReason
{
- self.cameraChangeReason = MGLCameraChangeReasonUnknown;
-}
-
-- (void)setCameraChangeReason:(MGLCameraChangeReason)reason
-{
- // If not already set, update. This is required since the reason can be set in succession (for
- // example "resetting north" sets the reason to MGLCameraChangeReasonGestureResetNorth before
- // calling a public method which calls self.cameraChangeReason with MGLCameraChangeReasonProgramatic.
- // We want the first reason to win out. This may be better handled with a stack or some other
- // mechanism.
- if (MGLCameraChangeReasonUnknown == _cameraChangeReason)
- {
- _cameraChangeReason = reason;
- }
+ self.cameraChangeReason = MGLCameraChangeReasonNone;
}
#pragma mark - Styling -
@@ -5431,9 +5418,9 @@ public:
if ( ! [self isSuppressingChangeDelimiters] )
{
- if ([self.delegate respondsToSelector:@selector(mapView:regionWillChangeAnimated:reason:)])
+ if ([self.delegate respondsToSelector:@selector(mapView:regionWillChangeForReason:animated:)])
{
- [self.delegate mapView:self regionWillChangeAnimated:animated reason:self.cameraChangeReason];
+ [self.delegate mapView:self regionWillChangeForReason:self.cameraChangeReason animated:animated];
}
else if ([self.delegate respondsToSelector:@selector(mapView:regionWillChangeAnimated:)])
{
@@ -5453,9 +5440,9 @@ public:
[(MGLScaleBar *)self.scaleBar setMetersPerPoint:[self metersPerPointAtLatitude:self.centerCoordinate.latitude]];
}
- if ([self.delegate respondsToSelector:@selector(mapView:regionIsChangingWithReason:)])
+ if ([self.delegate respondsToSelector:@selector(mapView:regionIsChangingForReason:)])
{
- [self.delegate mapView:self regionIsChangingWithReason:self.cameraChangeReason];
+ [self.delegate mapView:self regionIsChangingForReason:self.cameraChangeReason];
}
else if ([self.delegate respondsToSelector:@selector(mapViewRegionIsChanging:)])
{
@@ -5473,7 +5460,7 @@ public:
if ( ! [self isSuppressingChangeDelimiters])
{
BOOL respondsToSelector = [self.delegate respondsToSelector:@selector(mapView:regionDidChangeAnimated:)];
- BOOL respondsToSelectorWithReason = [self.delegate respondsToSelector:@selector(mapView:regionDidChangeAnimated:reason:)];
+ BOOL respondsToSelectorWithReason = [self.delegate respondsToSelector:@selector(mapView:regionDidChangeForReason:animated:)];
if ((respondsToSelector || respondsToSelectorWithReason) &&
([UIApplication sharedApplication].applicationState == UIApplicationStateActive))
@@ -5491,7 +5478,7 @@ public:
if (respondsToSelectorWithReason)
{
- [self.delegate mapView:self regionDidChangeAnimated:animated reason:self.cameraChangeReason];
+ [self.delegate mapView:self regionDidChangeForReason:self.cameraChangeReason animated:animated];
}
else if (respondsToSelector)
{
diff --git a/platform/ios/src/MGLMapViewDelegate.h b/platform/ios/src/MGLMapViewDelegate.h
index 1ed6c4e01a..55c79afb77 100644
--- a/platform/ios/src/MGLMapViewDelegate.h
+++ b/platform/ios/src/MGLMapViewDelegate.h
@@ -27,11 +27,14 @@ NS_ASSUME_NONNULL_BEGIN
This method is called whenever the currently displayed map camera will start
changing for any reason.
-
+
+ This method will be deprecated in a future release, please transition to
+ `-mapView:regionWillChangeForReason:animated:`
+
@param mapView The map view whose viewpoint will change.
@param animated Whether the change will cause an animated effect on the map.
- @note If `mapView:regionWillChangeAnimated:reason` is implemented this method will not be called.
+ @note If `-mapView:regionWillChangeForReason:animated:` is implemented this method will not be called.
*/
- (void)mapView:(MGLMapView *)mapView regionWillChangeAnimated:(BOOL)animated;
@@ -45,9 +48,9 @@ NS_ASSUME_NONNULL_BEGIN
@param animated Whether the change will cause an animated effect on the map.
@param reason The reason for the camera change.
- @note If this method is implemented `mapView:regionWillChangeAnimated:` will not be called.
+ @note If this method is implemented `-mapView:regionWillChangeAnimated:` will not be called.
*/
-- (void)mapView:(MGLMapView *)mapView regionWillChangeAnimated:(BOOL)animated reason:(MGLCameraChangeReason)reason;
+- (void)mapView:(MGLMapView *)mapView regionWillChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated;
/**
Tells the delegate that the viewpoint depicted by the map view is changing.
@@ -61,9 +64,12 @@ NS_ASSUME_NONNULL_BEGIN
the viewpoint. Therefore, your implementation of this method should be as lightweight
as possible to avoid affecting performance.
+ This method will be deprecated in a future release, please transition to
+ `-mapView:regionIsChangingForReason:`
+
@param mapView The map view whose viewpoint is changing.
- @note If `mapView:regionIsChangingWithReason:` is implemented this method will not be called.
+ @note If `-mapView:regionIsChangingForReason:` is implemented this method will not be called.
*/
- (void)mapViewRegionIsChanging:(MGLMapView *)mapView;
@@ -82,9 +88,9 @@ NS_ASSUME_NONNULL_BEGIN
@param mapView The map view whose viewpoint is changing.
@param reason The reason for the camera change.
- @note If this method is implemented `mapViewRegionIsChanging:` will not be called.
+ @note If this method is implemented `-mapViewRegionIsChanging:` will not be called.
*/
-- (void)mapView:(MGLMapView *)mapView regionIsChangingWithReason:(MGLCameraChangeReason)reason;
+- (void)mapView:(MGLMapView *)mapView regionIsChangingForReason:(MGLCameraChangeReason)reason;
/**
Tells the delegate that the viewpoint depicted by the map view has finished
@@ -94,10 +100,13 @@ NS_ASSUME_NONNULL_BEGIN
changing, after any calls to `-mapViewRegionIsChanging:` due to animation. Therefore,
this method can be called before `-mapViewDidFinishLoadingMap:` is called.
+ This method will be deprecated in a future release, please transition to
+ `mapView:regionDidChangeForReason:animated:`
+
@param mapView The map view whose viewpoint has changed.
@param animated Whether the change caused an animated effect on the map.
- @note If `mapView:regionDidChangeAnimated:reason:` is implemented this method will not be called.
+ @note If `mapView:regionDidChangeForReason:animated:` is implemented this method will not be called.
*/
- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated;
@@ -113,9 +122,9 @@ NS_ASSUME_NONNULL_BEGIN
@param animated Whether the change caused an animated effect on the map.
@param reason The reason for the camera change.
- @note If this method is implemented `mapView:regionDidChangeAnimated:` will not be called.
+ @note If this method is implemented `-mapView:regionDidChangeAnimated:` will not be called.
*/
-- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated reason:(MGLCameraChangeReason)reason;
+- (void)mapView:(MGLMapView *)mapView regionDidChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated;
/**
Asks the delegate whether the map view should be allowed to change from the
@@ -127,7 +136,10 @@ NS_ASSUME_NONNULL_BEGIN
This method is called many times during gesturing, so you should avoid performing
complex or performance-intensive tasks in your implementation.
-
+
+ This method will be deprecated in a future release, please transition to
+ `-mapView:shouldChangeFromCamera:toCamera:reason:`
+
@param mapView The map view that the user is manipulating.
@param oldCamera The camera representing the viewpoint at the moment the
gesture is recognized. If this method returns `NO`, the map view’s camera
@@ -137,7 +149,7 @@ NS_ASSUME_NONNULL_BEGIN
@return A Boolean value indicating whether the map view should stay at
`oldCamera` or change to `newCamera`.
- @note If `mapView:shouldChangeFromCamera:toCamera:reason:` is implemented this method will not be called.
+ @note If `-mapView:shouldChangeFromCamera:toCamera:reason:` is implemented this method will not be called.
*/
- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera;
@@ -162,7 +174,7 @@ NS_ASSUME_NONNULL_BEGIN
@return A Boolean value indicating whether the map view should stay at
`oldCamera` or change to `newCamera`.
- @note If this method is implemented `mapView:shouldChangeFromCamera:toCamera:` will not be called.
+ @note If this method is implemented `-mapView:shouldChangeFromCamera:toCamera:` will not be called.
*/
- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera reason:(MGLCameraChangeReason)reason;
@@ -177,22 +189,8 @@ NS_ASSUME_NONNULL_BEGIN
@param mapView The map view that was tapped.
@param coordinate Location of tap in world coordinates.
- @note If you implement this method, custom tap gesture recognizers that are installed in the following
- way
-
-```
-UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
-for (UIGestureRecognizer *gesture in self.mapView.gestureRecognizers)
-{
- if ([gesture isKindOfClass:[UITapGestureRecognizer class]])
- {
- [singleTap requireGestureRecognizerToFail:gesture];
- }
-}
-[self.mapView addGestureRecognizer:singleTap];
-```
-
- will fail to trigger, since the built-in single tap recognizer will no longer fail.
+ @note If you implement this method, custom tap gesture recognizers that are installed will fail to
+ trigger, since the built-in single tap recognizer will no longer fail.
*/
- (void)mapView:(MGLMapView *)mapView didSingleTapAtCoordinate:(CLLocationCoordinate2D)coordinate;
diff --git a/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift b/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift
index b66c6b6d1f..d559d09180 100644
--- a/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift
+++ b/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift
@@ -15,7 +15,7 @@ extension MGLMapViewDelegateIntegrationTests: MGLMapViewDelegate {
func mapViewRegionIsChanging(_ mapView: MGLMapView, reason: MGLCameraChangeReason) {}
- func mapView(_ mapView: MGLMapView, regionIsChangingWithReason reason: MGLCameraChangeReason) {}
+ func mapView(_ mapView: MGLMapView, regionIsChangingFor reason: MGLCameraChangeReason) {}
func mapView(_ mapView: MGLMapView, didChange mode: MGLUserTrackingMode, animated: Bool) {}
@@ -41,11 +41,11 @@ extension MGLMapViewDelegateIntegrationTests: MGLMapViewDelegate {
func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {}
- func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool, reason: MGLCameraChangeReason) {}
+ func mapView(_ mapView: MGLMapView, regionDidChangeFor reason: MGLCameraChangeReason, animated: Bool) {}
func mapView(_ mapView: MGLMapView, regionWillChangeAnimated animated: Bool) {}
- func mapView(_ mapView: MGLMapView, regionWillChangeAnimated animated: Bool, reason: MGLCameraChangeReason) {}
+ func mapView(_ mapView: MGLMapView, regionWillChangeFor reason: MGLCameraChangeReason, animated: Bool) {}
func mapViewDidFailLoadingMap(_ mapView: MGLMapView, withError error: Error) {}
diff --git a/platform/ios/uitest/MapViewTests.m b/platform/ios/uitest/MapViewTests.m
index 0ac4d32af2..52b88be80c 100644
--- a/platform/ios/uitest/MapViewTests.m
+++ b/platform/ios/uitest/MapViewTests.m
@@ -538,7 +538,7 @@
userInfo:@{ @"animated" : @(animated) }];
}
-- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated reason:(MGLCameraChangeReason)reason {
+- (void)mapView:(MGLMapView *)mapView regionDidChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated {
[[NSNotificationCenter defaultCenter] postNotificationName:@"regionDidChangeAnimated"
object:mapView