summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2018-02-09 16:15:52 -0500
committerJulian Rex <julian.rex@mapbox.com>2018-02-09 16:34:49 -0500
commit7b14455f749db73ef70c58cc2307d2c619633ddf (patch)
tree9169f161ee510c5c9691862f60acb5a3ed9ff03b
parent6259ef642a914071816ee07ae65c0a1c033836b1 (diff)
downloadqtlocation-mapboxgl-7b14455f749db73ef70c58cc2307d2c619633ddf.tar.gz
[ios] Renamed delegate methods' "for" to "with"
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/app/MBXViewController.m2
-rw-r--r--platform/ios/src/MGLMapView.mm12
-rw-r--r--platform/ios/src/MGLMapViewDelegate.h121
-rw-r--r--platform/ios/test/MGLMapViewDelegateIntegrationTests.swift6
-rw-r--r--platform/ios/uitest/MapViewTests.m2
6 files changed, 67 insertions, 77 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 7eb3fd8bf9..49476f5917 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
## 3.7.4
* Added the `MGLTileSourceOptionTileCoordinateBounds` option to create an `MGLTileSource` that only supplies tiles within a specific geographic bounding box. ([#11141](https://github.com/mapbox/mapbox-gl-native/pull/11141))
+* Provide optional delegate methods that provide a reason for a camera change. These are called in preference over the existing methods that do not have the parameter. ([#11151](https://github.com/mapbox/mapbox-gl-native/pull/11151))
## 3.7.3 - January 10, 2018
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index dedf148123..904046ac15 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -1885,7 +1885,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
[self updateHUD];
}
-- (void)mapView:(MGLMapView *)mapView regionDidChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated
+- (void)mapView:(MGLMapView *)mapView regionDidChangeWithReason:(MGLCameraChangeReason)reason animated:(BOOL)animated
{
[self updateHUD];
}
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 233ffa164c..126acb8f0f 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -5420,9 +5420,9 @@ public:
if ( ! [self isSuppressingChangeDelimiters] )
{
- if ([self.delegate respondsToSelector:@selector(mapView:regionWillChangeForReason:animated:)])
+ if ([self.delegate respondsToSelector:@selector(mapView:regionWillChangeWithReason:animated:)])
{
- [self.delegate mapView:self regionWillChangeForReason:self.cameraChangeReason animated:animated];
+ [self.delegate mapView:self regionWillChangeWithReason:self.cameraChangeReason animated:animated];
}
else if ([self.delegate respondsToSelector:@selector(mapView:regionWillChangeAnimated:)])
{
@@ -5442,9 +5442,9 @@ public:
[(MGLScaleBar *)self.scaleBar setMetersPerPoint:[self metersPerPointAtLatitude:self.centerCoordinate.latitude]];
}
- if ([self.delegate respondsToSelector:@selector(mapView:regionIsChangingForReason:)])
+ if ([self.delegate respondsToSelector:@selector(mapView:regionIsChangingWithReason:)])
{
- [self.delegate mapView:self regionIsChangingForReason:self.cameraChangeReason];
+ [self.delegate mapView:self regionIsChangingWithReason:self.cameraChangeReason];
}
else if ([self.delegate respondsToSelector:@selector(mapViewRegionIsChanging:)])
{
@@ -5462,7 +5462,7 @@ public:
if ( ! [self isSuppressingChangeDelimiters])
{
BOOL respondsToSelector = [self.delegate respondsToSelector:@selector(mapView:regionDidChangeAnimated:)];
- BOOL respondsToSelectorWithReason = [self.delegate respondsToSelector:@selector(mapView:regionDidChangeForReason:animated:)];
+ BOOL respondsToSelectorWithReason = [self.delegate respondsToSelector:@selector(mapView:regionDidChangeWithReason:animated:)];
if ((respondsToSelector || respondsToSelectorWithReason) &&
([UIApplication sharedApplication].applicationState == UIApplicationStateActive))
@@ -5480,7 +5480,7 @@ public:
if (respondsToSelectorWithReason)
{
- [self.delegate mapView:self regionDidChangeForReason:self.cameraChangeReason animated:animated];
+ [self.delegate mapView:self regionDidChangeWithReason:self.cameraChangeReason animated:animated];
}
else if (respondsToSelector)
{
diff --git a/platform/ios/src/MGLMapViewDelegate.h b/platform/ios/src/MGLMapViewDelegate.h
index 55c79afb77..c0abe1fe1a 100644
--- a/platform/ios/src/MGLMapViewDelegate.h
+++ b/platform/ios/src/MGLMapViewDelegate.h
@@ -23,18 +23,64 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark Responding to Map Position Changes
/**
+ Asks the delegate whether the map view should be allowed to change from the
+ existing camera to the new camera in response to a user gesture.
+
+ This method is called as soon as the user gesture is recognized. It is not
+ called in response to a programmatic camera change, such as by setting the
+ `centerCoordinate` property or calling `-flyToCamera:completionHandler:`.
+
+ This method is called many times during gesturing, so you should avoid performing
+ complex or performance-intensive tasks in your implementation.
+
+ @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
+ continues to be this camera.
+ @param newCamera The expected camera after the gesture completes. If this
+ method returns `YES`, this camera becomes the map view’s camera.
+ @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.
+ */
+- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera;
+
+/**
+ Asks the delegate whether the map view should be allowed to change from the
+ existing camera to the new camera in response to a user gesture.
+
+ This method is called as soon as the user gesture is recognized. It is not
+ called in response to a programmatic camera change, such as by setting the
+ `centerCoordinate` property or calling `-flyToCamera:completionHandler:`.
+
+ This method is called many times during gesturing, so you should avoid performing
+ complex or performance-intensive tasks in your implementation.
+
+ @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
+ continues to be this camera.
+ @param newCamera The expected camera after the gesture completes. If this
+ method returns `YES`, this camera becomes the map view’s camera.
+ @param reason The reason for the camera change.
+ @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.
+ */
+- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera reason:(MGLCameraChangeReason)reason;
+
+/**
Tells the delegate that the viewpoint depicted by the map view is about to change.
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:regionWillChangeForReason:animated:` is implemented this method will not be called.
+ @note If `-mapView:regionWillChangeWithReason:animated:` is implemented this method will not be called.
*/
- (void)mapView:(MGLMapView *)mapView regionWillChangeAnimated:(BOOL)animated;
@@ -50,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
@note If this method is implemented `-mapView:regionWillChangeAnimated:` will not be called.
*/
-- (void)mapView:(MGLMapView *)mapView regionWillChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated;
+- (void)mapView:(MGLMapView *)mapView regionWillChangeWithReason:(MGLCameraChangeReason)reason animated:(BOOL)animated;
/**
Tells the delegate that the viewpoint depicted by the map view is changing.
@@ -64,12 +110,9 @@ 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:regionIsChangingForReason:` is implemented this method will not be called.
+ @note If `-mapView:regionIsChangingWithReason:` is implemented this method will not be called.
*/
- (void)mapViewRegionIsChanging:(MGLMapView *)mapView;
@@ -90,7 +133,7 @@ NS_ASSUME_NONNULL_BEGIN
@note If this method is implemented `-mapViewRegionIsChanging:` will not be called.
*/
-- (void)mapView:(MGLMapView *)mapView regionIsChangingForReason:(MGLCameraChangeReason)reason;
+- (void)mapView:(MGLMapView *)mapView regionIsChangingWithReason:(MGLCameraChangeReason)reason;
/**
Tells the delegate that the viewpoint depicted by the map view has finished
@@ -100,13 +143,10 @@ 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:regionDidChangeForReason:animated:` is implemented this method will not be called.
+ @note If `-mapView:regionDidChangeWithReason:animated:` is implemented this method will not be called.
*/
- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated;
@@ -124,59 +164,8 @@ NS_ASSUME_NONNULL_BEGIN
@note If this method is implemented `-mapView:regionDidChangeAnimated:` will not be called.
*/
-- (void)mapView:(MGLMapView *)mapView regionDidChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated;
-
-/**
- Asks the delegate whether the map view should be allowed to change from the
- existing camera to the new camera in response to a user gesture.
-
- This method is called as soon as the user gesture is recognized. It is not
- called in response to a programmatic camera change, such as by setting the
- `centerCoordinate` property or calling `-flyToCamera:completionHandler:`.
-
- 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
- continues to be this camera.
- @param newCamera The expected camera after the gesture completes. If this
- method returns `YES`, this camera becomes the map view’s camera.
- @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.
- */
-- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera;
+- (void)mapView:(MGLMapView *)mapView regionDidChangeWithReason:(MGLCameraChangeReason)reason animated:(BOOL)animated;
-/**
- Asks the delegate whether the map view should be allowed to change from the
- existing camera to the new camera in response to a user gesture.
-
- This method is called as soon as the user gesture is recognized. It is not
- called in response to a programmatic camera change, such as by setting the
- `centerCoordinate` property or calling `-flyToCamera:completionHandler:`.
-
- This method is called many times during gesturing, so you should avoid performing
- complex or performance-intensive tasks in your implementation.
-
- @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
- continues to be this camera.
- @param newCamera The expected camera after the gesture completes. If this
- method returns `YES`, this camera becomes the map view’s camera.
- @param reason The reason for the camera change.
- @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.
- */
-- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera reason:(MGLCameraChangeReason)reason;
#pragma mark Responding to user gestures
diff --git a/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift b/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift
index d559d09180..4d11b000b9 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, regionIsChangingFor reason: MGLCameraChangeReason) {}
+ func mapView(_ mapView: MGLMapView, regionIsChangingWith 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, regionDidChangeFor reason: MGLCameraChangeReason, animated: Bool) {}
+ func mapView(_ mapView: MGLMapView, regionDidChangeWith reason: MGLCameraChangeReason, animated: Bool) {}
func mapView(_ mapView: MGLMapView, regionWillChangeAnimated animated: Bool) {}
- func mapView(_ mapView: MGLMapView, regionWillChangeFor reason: MGLCameraChangeReason, animated: Bool) {}
+ func mapView(_ mapView: MGLMapView, regionWillChangeWith 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 a64bc44f30..ba15af918a 100644
--- a/platform/ios/uitest/MapViewTests.m
+++ b/platform/ios/uitest/MapViewTests.m
@@ -538,7 +538,7 @@
userInfo:@{ @"animated" : @(animated) }];
}
-- (void)mapView:(MGLMapView *)mapView regionDidChangeForReason:(MGLCameraChangeReason)reason animated:(BOOL)animated {
+- (void)mapView:(MGLMapView *)mapView regionDidChangeWithReason:(MGLCameraChangeReason)reason animated:(BOOL)animated {
[[NSNotificationCenter defaultCenter] postNotificationName:@"regionDidChangeAnimated"
object:mapView