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

Commit

Permalink
[ios] Adds camera change delegate methods with reason parameter. (#11151
Browse files Browse the repository at this point in the history
)

Added missing notification handler for UIApplicationWillResignActiveNotification.
  • Loading branch information
julianrex authored Feb 12, 2018
1 parent 560afaf commit 9ee99c9
Show file tree
Hide file tree
Showing 7 changed files with 325 additions and 73 deletions.
4 changes: 3 additions & 1 deletion platform/ios/app/MBXViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ - (void)updateShapeSourceFeatures
- (void)styleDynamicPointCollection
{
[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(36.9979, -109.0441) zoomLevel:14 animated:NO];

CLLocationCoordinate2D coordinates[] = {
{37.00145594210082, -109.04960632324219},
{37.00173012609867, -109.0404224395752},
Expand Down Expand Up @@ -1884,7 +1885,8 @@ - (void)mapViewRegionIsChanging:(MGLMapView *)mapView
[self updateHUD];
}

- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
- (void)mapView:(MGLMapView *)mapView regionDidChangeWithReason:(MGLCameraChangeReason)reason animated:(BOOL)animated
{
[self updateHUD];
}

Expand Down
18 changes: 12 additions & 6 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@
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 */; };
CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; };
CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA00FC901D5EEB0D009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */; };
Expand Down Expand Up @@ -756,6 +758,7 @@
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>"; };
CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.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>"; };
DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1449,19 +1452,20 @@
DA8848331CBAFB2A00AB86E3 /* Kit */ = {
isa = PBXGroup;
children = (
355ADFF91E9281C300F3939D /* Views */,
35CE617F1D4165C2004F2359 /* Categories */,
DAD165841CF4D06B001FF4B9 /* Annotations */,
35CE617F1D4165C2004F2359 /* Categories */,
DA88487F1CBB033F00AB86E3 /* Fabric */,
DA8848881CBB036000AB86E3 /* SMCalloutView */,
DAD165851CF4D08B001FF4B9 /* Telemetry */,
355ADFF91E9281C300F3939D /* Views */,
CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */,
DA704CC01F65A475004B3F28 /* MGLMapAccessibilityElement.h */,
DA704CC11F65A475004B3F28 /* MGLMapAccessibilityElement.mm */,
DA8848361CBAFB8500AB86E3 /* MGLMapView.h */,
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.h */,
DA8848361CBAFB8500AB86E3 /* MGLMapView.h */,
DA88484A1CBAFB9800AB86E3 /* MGLMapView.mm */,
DA8848371CBAFB8500AB86E3 /* MGLMapView+IBAdditions.h */,
DA737EE01D056A4E005BDA16 /* MGLMapViewDelegate.h */,
DA88484A1CBAFB9800AB86E3 /* MGLMapView.mm */,
DA88487F1CBB033F00AB86E3 /* Fabric */,
DA8848881CBB036000AB86E3 /* SMCalloutView */,
);
name = Kit;
path = src;
Expand Down Expand Up @@ -1764,6 +1768,7 @@
350098DC1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.h in Headers */,
DA8848231CBAFA6200AB86E3 /* MGLOfflineStorage_Private.h in Headers */,
404326891D5B9B27007111BD /* MGLAnnotationContainerView_Private.h in Headers */,
CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */,
1FB7DAAF1F2A4DBD00410606 /* MGLVectorSource+MGLAdditions.h in Headers */,
DA88483B1CBAFB8500AB86E3 /* MGLCalloutView.h in Headers */,
35E0CFE61D3E501500188327 /* MGLStyle_Private.h in Headers */,
Expand Down Expand Up @@ -1896,6 +1901,7 @@
3510FFF11D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */,
35D3A1E71E9BE7EC002B38EE /* MGLScaleBar.h in Headers */,
35E0CFE71D3E501500188327 /* MGLStyle_Private.h in Headers */,
CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */,
DABFB86D1CBE9A0F00D62B32 /* MGLAnnotationImage.h in Headers */,
DABFB8721CBE9A0F00D62B32 /* MGLUserLocation.h in Headers */,
927FBD001F4DB05500F8BF1F /* MGLMapSnapshotter.h in Headers */,
Expand Down
61 changes: 61 additions & 0 deletions platform/ios/src/MGLCameraChangeReason.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#import "MGLFoundation.h"

/**
:nodoc:
Bitmask values that describe why a camera move occurred.
Values of this type are passed to the `MGLMapView`'s delegate in the following methods:
- `-mapView:shouldChangeFromCamera:toCamera:reason:`
- `-mapView:regionWillChangeWithReason:animated:`
- `-mapView:regionIsChangingWithReason:`
- `-mapView:regionDidChangeWithReason:animated:`
It's important to note that it's almost impossible to perform a rotate without zooming (in or out),
so if you'll often find `MGLCameraChangeReasonGesturePinch` set alongside `MGLCameraChangeReasonGestureRotate`.
Since there are several reasons why a zoom or rotation has occurred, it is worth considering
creating a combined constant, for example:
```
static const MGLCameraChangeReason anyZoom = MGLCameraChangeReasonGesturePinch |
MGLCameraChangeReasonGestureZoomIn |
MGLCameraChangeReasonGestureZoomOut |
MGLCameraChangeReasonGestureOneFingerZoom;
static const MGLCameraChangeReason anyRotation = MGLCameraChangeReasonResetNorth | MGLCameraChangeReasonGestureRotate;
```
*/
typedef NS_OPTIONS(NSUInteger, MGLCameraChangeReason)
{
/// :nodoc: The reason for the camera change has not be specified.
MGLCameraChangeReasonNone = 0,

/// :nodoc: Set when a public API that moves the camera is called. This may be set for some gestures,
/// for example MGLCameraChangeReasonResetNorth.
MGLCameraChangeReasonProgrammatic = 1 << 0,

/// :nodoc: The user tapped the compass to reset the map orientation so North is up.
MGLCameraChangeReasonResetNorth = 1 << 1,

/// :nodoc: The user panned the map.
MGLCameraChangeReasonGesturePan = 1 << 2,

/// :nodoc: The user pinched to zoom in/out.
MGLCameraChangeReasonGesturePinch = 1 << 3,

// :nodoc: The user rotated the map.
MGLCameraChangeReasonGestureRotate = 1 << 4,

/// :nodoc: The user zoomed the map in (one finger double tap).
MGLCameraChangeReasonGestureZoomIn = 1 << 5,

/// :nodoc: The user zoomed the map out (two finger single tap).
MGLCameraChangeReasonGestureZoomOut = 1 << 6,

/// :nodoc: The user long pressed on the map for a quick zoom (single tap, then long press and drag up/down).
MGLCameraChangeReasonGestureOneFingerZoom = 1 << 7,

// :nodoc: The user panned with two fingers to tilt the map (two finger drag).
MGLCameraChangeReasonGestureTilt = 1 << 8
};
Loading

1 comment on commit 9ee99c9

@Etienne-io
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @julianrex

Could you explain the reason why every delegate method using reason parameter are annotated with 'no-doc'?

Do you have specific reasons to not expose them?

Thanks,

Etienne

Please sign in to comment.