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

Commit

Permalink
[ios] Add MGLCompassButton and MGLOrnamentVisibility
Browse files Browse the repository at this point in the history
  • Loading branch information
friedbunny authored Jul 11, 2019
1 parent de71ff5 commit 5b48822
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 100 deletions.
12 changes: 12 additions & 0 deletions platform/darwin/src/MGLTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,16 @@ NS_INLINE MGLTransition MGLTransitionMake(NSTimeInterval duration, NSTimeInterva
return transition;
}

/**
Constants indicating the visibility of different map ornaments.
*/
typedef NS_ENUM(NSInteger, MGLOrnamentVisibility) {
/** A constant indicating that the ornament adapts to the current map state. */
MGLOrnamentVisibilityAdaptive,
/** A constant indicating that the ornament is always hidden. */
MGLOrnamentVisibilityHidden,
/** A constant indicating that the ornament is always visible. */
MGLOrnamentVisibilityVisible
};

NS_ASSUME_NONNULL_END
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* `-[MGLMapView selectAnnotation:animated:completionHandler:]`
* Deprecated variants of the above methods without completion handlers. ([#14959](https://github.com/mapbox/mapbox-gl-native/pull/14959))
* Fixed an issue where the two-finger tilt gesture would continue after lifting one finger. ([#14969](https://github.com/mapbox/mapbox-gl-native/pull/14969))
* Added `MGLMapView.compassView.visibility` and `MGLOrnamentVisibility` to allow configuration of compass visibility behavior. ([#15055](https://github.com/mapbox/mapbox-gl-native/pull/15055))

## 5.1.0 - June 19, 2019

Expand Down
22 changes: 22 additions & 0 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@
9620BB3B1E69FE1700705A1D /* MGLSDKUpdateChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9620BB371E69FE1700705A1D /* MGLSDKUpdateChecker.mm */; };
9621F2502091020E005B3800 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3510FFEE1D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
96381C0222C6F3950053497D /* MGLMapViewPitchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 96381C0122C6F3950053497D /* MGLMapViewPitchTests.m */; };
9641771F22D546DA00332422 /* MGLCompassButton_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9641771E22D546DA00332422 /* MGLCompassButton_Private.h */; };
9641772022D546DA00332422 /* MGLCompassButton_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9641771E22D546DA00332422 /* MGLCompassButton_Private.h */; };
9654C1261FFC1AB900DB6A19 /* MGLPolyline_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C1251FFC1AB900DB6A19 /* MGLPolyline_Private.h */; };
9654C1291FFC1CCD00DB6A19 /* MGLPolygon_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C1271FFC1CC000DB6A19 /* MGLPolygon_Private.h */; };
9658C155204761FC00D8A674 /* MGLMapViewScaleBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9658C154204761FC00D8A674 /* MGLMapViewScaleBarTests.m */; };
Expand Down Expand Up @@ -424,6 +426,11 @@
96E516FB20005A4000A02306 /* MGLUserLocationHeadingBeamLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 966FCF4A1F3A5C9200F2B6DE /* MGLUserLocationHeadingBeamLayer.h */; };
96E516FC20005A4400A02306 /* MGLUserLocationHeadingIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */; };
96E5170420005A6B00A02306 /* SMCalloutView.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8848891CBB037E00AB86E3 /* SMCalloutView.h */; };
96E6145622CC135200109F14 /* MGLCompassButtonTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E6145522CC135200109F14 /* MGLCompassButtonTests.m */; };
96E6145922CC169000109F14 /* MGLCompassButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E6145722CC169000109F14 /* MGLCompassButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
96E6145A22CC169000109F14 /* MGLCompassButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E6145722CC169000109F14 /* MGLCompassButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
96E6145B22CC169000109F14 /* MGLCompassButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96E6145822CC169000109F14 /* MGLCompassButton.mm */; };
96E6145C22CC169000109F14 /* MGLCompassButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96E6145822CC169000109F14 /* MGLCompassButton.mm */; };
96ED34DE22374C0900E9FCA9 /* MGLMapViewDirectionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96ED34DD22374C0900E9FCA9 /* MGLMapViewDirectionTests.mm */; };
96F3F73C1F57124B003E2D2C /* MGLUserLocationHeadingIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */; };
9C188C4F2242C95A0022FA55 /* MMEDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 40834BBC1FE05D6E00C1BD0D /* MMEDate.m */; };
Expand Down Expand Up @@ -1104,6 +1111,7 @@
9620BB361E69FE1700705A1D /* MGLSDKUpdateChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLSDKUpdateChecker.h; sourceTree = "<group>"; };
9620BB371E69FE1700705A1D /* MGLSDKUpdateChecker.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = MGLSDKUpdateChecker.mm; sourceTree = "<group>"; };
96381C0122C6F3950053497D /* MGLMapViewPitchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewPitchTests.m; sourceTree = "<group>"; };
9641771E22D546DA00332422 /* MGLCompassButton_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLCompassButton_Private.h; sourceTree = "<group>"; };
9654C1251FFC1AB900DB6A19 /* MGLPolyline_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPolyline_Private.h; sourceTree = "<group>"; };
9654C1271FFC1CC000DB6A19 /* MGLPolygon_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPolygon_Private.h; sourceTree = "<group>"; };
9658C154204761FC00D8A674 /* MGLMapViewScaleBarTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewScaleBarTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1132,6 +1140,9 @@
96E0272C1E57C7E5004B8E66 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
96E0272D1E57C7E6004B8E66 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
96E0272E1E57C7E7004B8E66 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
96E6145522CC135200109F14 /* MGLCompassButtonTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLCompassButtonTests.m; sourceTree = "<group>"; };
96E6145722CC169000109F14 /* MGLCompassButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLCompassButton.h; sourceTree = "<group>"; };
96E6145822CC169000109F14 /* MGLCompassButton.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCompassButton.mm; sourceTree = "<group>"; };
96ED34DD22374C0900E9FCA9 /* MGLMapViewDirectionTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLMapViewDirectionTests.mm; sourceTree = "<group>"; };
96F017292118FBAE00892778 /* MGLMapView_Experimental.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMapView_Experimental.h; sourceTree = "<group>"; };
96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationHeadingIndicator.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1658,6 +1669,9 @@
355ADFF91E9281C300F3939D /* Views */ = {
isa = PBXGroup;
children = (
96E6145722CC169000109F14 /* MGLCompassButton.h */,
9641771E22D546DA00332422 /* MGLCompassButton_Private.h */,
96E6145822CC169000109F14 /* MGLCompassButton.mm */,
355ADFFB1E9281DA00F3939D /* MGLScaleBar.h */,
355ADFFC1E9281DA00F3939D /* MGLScaleBar.mm */,
);
Expand Down Expand Up @@ -2026,6 +2040,7 @@
DA35A2C31CCA9F8300E826B2 /* MGLClockDirectionFormatterTests.m */,
35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.mm */,
DA35A2C41CCA9F8300E826B2 /* MGLCompassDirectionFormatterTests.m */,
96E6145522CC135200109F14 /* MGLCompassButtonTests.m */,
DA35A2A91CCA058D00E826B2 /* MGLCoordinateFormatterTests.m */,
3598544C1E1D38AA00B29F84 /* MGLDistanceFormatterTests.m */,
6407D66F1E0085FD00F6A9C3 /* MGLDocumentationExampleTests.swift */,
Expand Down Expand Up @@ -2411,6 +2426,7 @@
DA35A2BB1CCA9A6900E826B2 /* MGLClockDirectionFormatter.h in Headers */,
353933FE1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */,
DA8848201CBAFA6200AB86E3 /* MGLOfflinePack_Private.h in Headers */,
9641771F22D546DA00332422 /* MGLCompassButton_Private.h in Headers */,
DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */,
DA8847FA1CBAFA5100AB86E3 /* MGLPolyline.h in Headers */,
3566C7711D4A9198008152BC /* MGLSource_Private.h in Headers */,
Expand Down Expand Up @@ -2454,6 +2470,7 @@
74CB5EC3219B282500102936 /* MGLCircleStyleLayer_Private.h in Headers */,
DA8847F01CBAFA5100AB86E3 /* MGLAnnotation.h in Headers */,
400533011DB0862B0069F638 /* NSArray+MGLAdditions.h in Headers */,
96E6145922CC169000109F14 /* MGLCompassButton.h in Headers */,
1F06668A1EC64F8E001C16D7 /* MGLLight.h in Headers */,
4049C29D1DB6CD6C00B3F799 /* MGLPointCollection.h in Headers */,
40CF6DBB1DAC3C6600A4D18B /* MGLShape_Private.h in Headers */,
Expand Down Expand Up @@ -2602,6 +2619,7 @@
96E516DE200054F700A02306 /* MGLGeometry_Private.h in Headers */,
353933FC1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h in Headers */,
3566C76D1D4A8DFA008152BC /* MGLRasterTileSource.h in Headers */,
9641772022D546DA00332422 /* MGLCompassButton_Private.h in Headers */,
DAED38641D62D0FC00D7640F /* NSURL+MGLAdditions.h in Headers */,
DABFB85E1CBE99E500D62B32 /* MGLAnnotation.h in Headers */,
DABFB8641CBE99E500D62B32 /* MGLOfflineStorage.h in Headers */,
Expand Down Expand Up @@ -2645,6 +2663,7 @@
9C6E283922A982670056B7BE /* MMEEventLogReportViewController.h in Headers */,
1F6A82A92138871900BA5B41 /* MGLLoggingConfiguration_Private.h in Headers */,
DABFB8661CBE99E500D62B32 /* MGLPointAnnotation.h in Headers */,
96E6145A22CC169000109F14 /* MGLCompassButton.h in Headers */,
96E516E42000560B00A02306 /* MGLComputedShapeSource_Private.h in Headers */,
96E516E92000560B00A02306 /* MGLAnnotationImage_Private.h in Headers */,
96E516E52000560B00A02306 /* MGLOfflinePack_Private.h in Headers */,
Expand Down Expand Up @@ -3240,6 +3259,7 @@
40CFA6511D7875BB008103BD /* MGLShapeSourceTests.mm in Sources */,
DA35A2C51CCA9F8300E826B2 /* MGLClockDirectionFormatterTests.m in Sources */,
35B8E08C1D6C8B5100E768D2 /* MGLPredicateTests.mm in Sources */,
96E6145622CC135200109F14 /* MGLCompassButtonTests.m in Sources */,
96036A0620059BBA00510F3D /* MGLNSOrthographyAdditionsTests.m in Sources */,
1F95931D1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm in Sources */,
DA695426215B1E76002041A4 /* MGLMapCameraTests.m in Sources */,
Expand Down Expand Up @@ -3336,6 +3356,7 @@
3557F7B21E1D27D300CCA5E6 /* MGLDistanceFormatter.m in Sources */,
9C6E282B22A981570056B7BE /* MGLMapboxEvents.m in Sources */,
1FCCEC36222605C400302E3B /* MGLSDKMetricsManager.m in Sources */,
96E6145B22CC169000109F14 /* MGLCompassButton.mm in Sources */,
40834BE71FE05E1800C1BD0D /* MMEAPIClient.m in Sources */,
DA8848591CBAFB9800AB86E3 /* MGLMapView.mm in Sources */,
DA8848501CBAFB9800AB86E3 /* MGLAnnotationImage.m in Sources */,
Expand Down Expand Up @@ -3462,6 +3483,7 @@
1FCCEC37222605C400302E3B /* MGLSDKMetricsManager.m in Sources */,
9C6E282C22A981580056B7BE /* MGLMapboxEvents.m in Sources */,
DAA4E41F1CBB730400178DFB /* MGLMultiPoint.mm in Sources */,
96E6145C22CC169000109F14 /* MGLCompassButton.mm in Sources */,
DD0902AA1DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */,
40834C041FE05E1800C1BD0D /* MMELocationManager.m in Sources */,
9C6E281F22A980AC0056B7BE /* CLLocation+MMEMobileEvents.m in Sources */,
Expand Down
1 change: 1 addition & 0 deletions platform/ios/jazzy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ custom_categories:
children:
- MGLCalloutView
- MGLCalloutViewDelegate
- MGLCompassButton
- name: Location Updates
children:
- MGLLocationManager
Expand Down
3 changes: 3 additions & 0 deletions platform/ios/sdk-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"platform/darwin/src/MGLDistanceFormatter.m",
"platform/ios/src/MGLMapboxEvents.m",
"platform/darwin/src/MGLSDKMetricsManager.m",
"platform/ios/src/MGLCompassButton.mm",
"platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEAPIClient.m",
"platform/ios/src/MGLMapView.mm",
"platform/ios/src/MGLAnnotationImage.m",
Expand Down Expand Up @@ -141,6 +142,7 @@
"MGLStyle.h": "platform/darwin/src/MGLStyle.h",
"MGLUserLocationAnnotationView.h": "platform/ios/src/MGLUserLocationAnnotationView.h",
"MGLAnnotation.h": "platform/darwin/src/MGLAnnotation.h",
"MGLCompassButton.h": "platform/ios/src/MGLCompassButton.h",
"MGLLight.h": "platform/darwin/src/MGLLight.h",
"MGLPointCollection.h": "platform/darwin/src/MGLPointCollection.h",
"MGLAnnotationView.h": "platform/ios/src/MGLAnnotationView.h",
Expand Down Expand Up @@ -195,6 +197,7 @@
"private_headers": {
"MGLFillStyleLayer_Private.h": "platform/darwin/src/MGLFillStyleLayer_Private.h",
"MGLOfflinePack_Private.h": "platform/darwin/src/MGLOfflinePack_Private.h",
"MGLCompassButton_Private.h": "platform/ios/src/MGLCompassButton_Private.h",
"MGLSource_Private.h": "platform/darwin/src/MGLSource_Private.h",
"MGLAnnotationView_Private.h": "platform/ios/src/MGLAnnotationView_Private.h",
"MGLValueEvaluator.h": "platform/darwin/src/MGLValueEvaluator.h",
Expand Down
22 changes: 22 additions & 0 deletions platform/ios/src/MGLCompassButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import <UIKit/UIKit.h>

#import "MGLTypes.h"

NS_ASSUME_NONNULL_BEGIN

/**
A specialized view that displays the current compass heading for its associated map.
*/
MGL_EXPORT
@interface MGLCompassButton : UIImageView

/**
The visibility of the compass button.
You can configure a compass button to be visible all the time or only when the compass heading changes.
*/
@property (nonatomic, assign) MGLOrnamentVisibility compassVisibility;

@end

NS_ASSUME_NONNULL_END
128 changes: 128 additions & 0 deletions platform/ios/src/MGLCompassButton.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#import "MGLCompassButton_Private.h"
#import "MGLCompassDirectionFormatter.h"

#import <Mapbox/MGLGeometry.h>

#import "MGLMapView_Private.h"
#import "UIImage+MGLAdditions.h"
#import "NSBundle+MGLAdditions.h"

#include <mbgl/math/wrap.hpp>

@interface MGLCompassButton ()

@property (nonatomic, weak) MGLMapView *mapView;
@property (nonatomic) MGLCompassDirectionFormatter *accessibilityCompassFormatter;

@end

@implementation MGLCompassButton

+ (instancetype)compassButtonWithMapView:(MGLMapView *)mapView {
return [[MGLCompassButton alloc] initWithMapView:mapView];
}

- (instancetype)initWithMapView:(MGLMapView *)mapView {
if (self = [super init]) {
self.mapView = mapView;
[self commonInit];
}
return self;
}

- (void)commonInit {
self.image = self.compassImage;

self.compassVisibility = MGLOrnamentVisibilityAdaptive;

self.alpha = 0;
self.userInteractionEnabled = YES;
self.translatesAutoresizingMaskIntoConstraints = NO;

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[self addGestureRecognizer:tapGesture];

self.accessibilityTraits = UIAccessibilityTraitButton;
self.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_LABEL", nil, nil, @"Compass", @"Accessibility label");
self.accessibilityHint = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_HINT", nil, nil, @"Rotates the map to face due north", @"Accessibility hint");

self.accessibilityCompassFormatter = [[MGLCompassDirectionFormatter alloc] init];
self.accessibilityCompassFormatter.unitStyle = NSFormattingUnitStyleLong;

[self sizeToFit];
}

- (void)setCompassVisibility:(MGLOrnamentVisibility)compassVisibility {
if (_compassVisibility == compassVisibility) { return; }
_compassVisibility = compassVisibility;

[self updateCompassAnimated:NO];
}

- (UIImage *)compassImage {
UIImage *scaleImage = [UIImage mgl_resourceImageNamed:@"Compass"];
UIGraphicsBeginImageContextWithOptions(scaleImage.size, NO, UIScreen.mainScreen.scale);
[scaleImage drawInRect:{CGPointZero, scaleImage.size}];

NSAttributedString *north = [[NSAttributedString alloc] initWithString:NSLocalizedStringWithDefaultValue(@"COMPASS_NORTH", nil, nil, @"N", @"Compass abbreviation for north") attributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:11 weight:UIFontWeightUltraLight],
NSForegroundColorAttributeName: [UIColor whiteColor],
}];
CGRect stringRect = CGRectMake((scaleImage.size.width - north.size.width) / 2,
scaleImage.size.height * 0.435,
north.size.width, north.size.height);
[north drawInRect:stringRect];

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

- (void)handleTapGesture:(__unused UITapGestureRecognizer *)sender {
[self.mapView resetNorth];
}

- (void)updateCompass {
[self updateCompassAnimated:YES];
}

- (void)updateCompassAnimated:(BOOL)animated {
CLLocationDirection direction = self.mapView.direction;
CLLocationDirection plateDirection = mbgl::util::wrap(-direction, 0., 360.);
self.transform = CGAffineTransformMakeRotation(MGLRadiansFromDegrees(plateDirection));

self.isAccessibilityElement = direction > 0;
self.accessibilityValue = [self.accessibilityCompassFormatter stringFromDirection:direction];

switch (self.compassVisibility) {
case MGLOrnamentVisibilityAdaptive:
if (direction > 0 && self.alpha < 1) {
[self showCompass:animated];
} else if (direction == 0 && self.alpha > 0) {
[self hideCompass:animated];
}
break;
case MGLOrnamentVisibilityVisible:
[self showCompass:animated];
break;
case MGLOrnamentVisibilityHidden:
[self hideCompass:animated];
break;
}
}

- (void)showCompass:(BOOL)animated {
animated ? [self animateToAlpha:1] : [self setAlpha:1];
}

- (void)hideCompass:(BOOL)animated {
animated ? [self animateToAlpha:0] : [self setAlpha:0];
}

- (void)animateToAlpha:(CGFloat)alpha {
[UIView animateWithDuration:MGLAnimationDuration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.alpha = alpha;
} completion:nil];
}

@end
19 changes: 19 additions & 0 deletions platform/ios/src/MGLCompassButton_Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#import <UIKit/UIKit.h>

#import <Mapbox/MGLCompassButton.h>

@class MGLMapView;

NS_ASSUME_NONNULL_BEGIN

@interface MGLCompassButton (Private)

+ (instancetype)compassButtonWithMapView:(MGLMapView *)mapView;

@property (nonatomic, weak) MGLMapView *mapView;

- (void)updateCompass;

@end

NS_ASSUME_NONNULL_END
9 changes: 4 additions & 5 deletions platform/ios/src/MGLMapView.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#import "MGLGeometry.h"
#import "MGLMapCamera.h"

#import <UIKit/UIKit.h>

#import "MGLCompassButton.h"
#import "MGLFoundation.h"
#import "MGLGeometry.h"
#import "MGLMapCamera.h"
#import "MGLTypes.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -122,7 +122,6 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLMapViewPreferredFramesPerSecond MGLMapView

FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLMissingLocationServicesUsageDescriptionException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLUserLocationAnnotationTypeException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLResourceNotFoundException;

/**
An interactive, customizable map view with an interface similar to the one
Expand Down Expand Up @@ -316,7 +315,7 @@ MGL_EXPORT
A control indicating the map’s direction and allowing the user to manipulate
the direction, positioned in the upper-right corner.
*/
@property (nonatomic, readonly) UIImageView *compassView;
@property (nonatomic, readonly) MGLCompassButton *compassView;

/**
The position of the compass view. The default value is `MGLOrnamentPositionTopRight`.
Expand Down
Loading

0 comments on commit 5b48822

Please sign in to comment.