From 80e98fd9532d2155c8bb1935359cc5451492a9db Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Mon, 22 Feb 2021 13:01:41 +0100 Subject: [PATCH 01/10] Cherry pick changes from mapbox-gl-native-ios. resolves #29 --- platform/ios/platform/darwin/src/MGLEvent.h | 41 ++++ platform/ios/platform/darwin/src/MGLEvent.mm | 80 +++++++ .../platform/darwin/src/MGLEvent_Private.h | 11 + .../platform/darwin/src/MGLLocationManager.h | 31 +++ .../platform/darwin/src/MGLLocationManager.m | 31 +++ .../ios/platform/darwin/src/MGLObserver.h | 65 ++++++ .../ios/platform/darwin/src/MGLObserver.mm | 101 +++++++++ .../platform/darwin/src/MGLObserver_Private.h | 40 ++++ .../ios/platform/darwin/src/MGLStyleValue.mm | 2 + .../darwin/src/MGLStyleValue_Private.h | 2 + platform/ios/platform/ios/CHANGELOG.md | 13 ++ platform/ios/platform/ios/app/Info.plist | 5 + .../ios/app/MBXOrnamentsViewController.m | 3 +- .../ios/platform/ios/app/MBXViewController.m | 56 ++++- .../ios/docs/guides/Info.plist Keys.md | 17 +- .../ios/ios.xcodeproj/project.pbxproj | 48 +++++ .../src/MGLFaux3DUserLocationAnnotationView.m | 198 ++++++++++++++++-- platform/ios/platform/ios/src/MGLMapView.h | 11 +- platform/ios/platform/ios/src/MGLMapView.mm | 87 ++++++++ .../ios/platform/ios/src/MGLMapViewDelegate.h | 23 ++ .../src/MGLUserLocationAnnotationViewStyle.h | 57 +++++ .../src/MGLUserLocationAnnotationViewStyle.m | 62 ++++++ platform/ios/platform/ios/src/Mapbox.h | 65 +++--- .../MGLMapViewDelegateIntegrationTests.swift | 4 + 24 files changed, 999 insertions(+), 54 deletions(-) create mode 100644 platform/ios/platform/darwin/src/MGLEvent.h create mode 100644 platform/ios/platform/darwin/src/MGLEvent.mm create mode 100644 platform/ios/platform/darwin/src/MGLEvent_Private.h create mode 100644 platform/ios/platform/darwin/src/MGLObserver.h create mode 100644 platform/ios/platform/darwin/src/MGLObserver.mm create mode 100644 platform/ios/platform/darwin/src/MGLObserver_Private.h create mode 100644 platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.h create mode 100644 platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.m diff --git a/platform/ios/platform/darwin/src/MGLEvent.h b/platform/ios/platform/darwin/src/MGLEvent.h new file mode 100644 index 00000000000..be647c65df1 --- /dev/null +++ b/platform/ios/platform/darwin/src/MGLEvent.h @@ -0,0 +1,41 @@ +#import "MGLFoundation.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + Type of event used when subscribing to and unsubscribing from an `MGLObservable`. + */ +typedef NSString *MGLEventType NS_TYPED_EXTENSIBLE_ENUM; + +// TODO: Doc +FOUNDATION_EXPORT MGL_EXPORT MGLEventType const MGLEventTypeResourceRequest; + + +/** + Generic Event used when notifying an `MGLObserver`. This is not intended nor + expected to be created by the application developer. It will be provided as + part of an `MGLObservable` notification. + */ +MGL_EXPORT +@interface MGLEvent: NSObject + +/// Type of an event. Matches an original event type used for a subscription. +@property (nonatomic, readonly, copy) MGLEventType type; + +/// Timestamp taken at the time of an event creation, relative to the Unix epoch. +@property (nonatomic, readonly) NSTimeInterval begin; + +/// Timestamp taken at the time of an event completion. For a non-interval +/// (single-shot) events, migth be equal to an event's `begin` timestamp. +/// Relative to the Unix epoch. +@property (nonatomic, readonly) NSTimeInterval end; + +/// Generic property for the event's data. Supported types are: `NSNumber` (int64, +/// uint64, bool, double), `NSString`, `NSArray`, `NSDictionary`. +@property (nonatomic, readonly, copy) id data; + +/// Test for equality. Note this compares all properties except `data`. +- (BOOL)isEqualToEvent:(MGLEvent *)otherEvent; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLEvent.mm b/platform/ios/platform/darwin/src/MGLEvent.mm new file mode 100644 index 00000000000..21330a87a3a --- /dev/null +++ b/platform/ios/platform/darwin/src/MGLEvent.mm @@ -0,0 +1,80 @@ +#import "MGLEvent_Private.h" +#import "MGLStyleValue_Private.h" + +const MGLEventType MGLEventTypeResourceRequest = @"resource-request"; + +#pragma mark - Event + +@implementation MGLEvent + +- (instancetype)init { + [self doesNotRecognizeSelector:_cmd]; + return nil; +} + +- (instancetype)initWithEvent:(const mbgl::ObservableEvent&)event { + self = [super init]; + + if (!self) + return nil; + + // mbgl::ObservableEvent timestamps do not use the system_clock, i.e. they + // are not relative to the Unix epoch, so we'll need to offset appropriately + auto systemClockNow = std::chrono::system_clock::now(); + auto steadyClockNow = std::chrono::steady_clock::now(); + auto begin = std::chrono::time_point_cast(systemClockNow + + (event.begin - steadyClockNow)); + auto end = std::chrono::time_point_cast(systemClockNow + + (event.end - steadyClockNow)); + + auto beginTime = std::chrono::duration>(begin.time_since_epoch()).count(); + auto endTime = std::chrono::duration>(end.time_since_epoch()).count(); + + _type = (MGLEventType)[NSString stringWithUTF8String:event.type.c_str()]; + _begin = beginTime; + _end = endTime; + + // From value.md + // Supported types are `int`, `uint`, `bool`, `double`, `array`, `object` and `string`. + _data = MGLJSONObjectFromMBGLValue(event.data); + + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p; type = %@, begin = %f, end = %f, data = %@>", + NSStringFromClass([self class]), (void *)self, + self.type, + self.begin, + self.end, + self.data]; +} + +#pragma mark - Equality + +- (NSUInteger)hash { + return self.type.hash ^ @(self.begin).hash ^ @(self.end).hash; +} + +- (BOOL)isEqualToEvent:(MGLEvent *)other { + if (self == other) + return YES; + + // Ignore the value at this moment. + return ((self.type == other.type) && + (self.begin == other.begin) && + (self.end == other.end)); +} + +- (BOOL)isEqual:(id)other { + if (self == other) + return YES; + + if (![other isKindOfClass:[MGLEvent class]]) { + return NO; + } + + return [self isEqualToEvent:(MGLEvent*)other]; +} + +@end \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLEvent_Private.h b/platform/ios/platform/darwin/src/MGLEvent_Private.h new file mode 100644 index 00000000000..ca2f88fdf28 --- /dev/null +++ b/platform/ios/platform/darwin/src/MGLEvent_Private.h @@ -0,0 +1,11 @@ +#import +#import "MGLEvent.h" +#include + +NS_ASSUME_NONNULL_BEGIN + +@interface MGLEvent () +- (instancetype)initWithEvent:(const mbgl::ObservableEvent&)event; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLLocationManager.h b/platform/ios/platform/darwin/src/MGLLocationManager.h index ecb9192981e..d9dfe391197 100644 --- a/platform/ios/platform/darwin/src/MGLLocationManager.h +++ b/platform/ios/platform/darwin/src/MGLLocationManager.h @@ -58,6 +58,18 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)setDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 +/** + Specifies the level of location accuracy the Maps SDK has permission to use. + + @note If the value of this property is `CLAccuracyAuthorizationFullAccuracy`, you can set the + `MGLLocationManager.desiredAccuracy` property to any value. If the value is `CLAccuracyAuthorizationReducedAccuracy`, + setting `MGLLocationManager.desiredAccuracy` to a value other than` kCLLocationAccuracyReduced` has no effect on + the location information. + */ +- (CLAccuracyAuthorization)accuracyAuthorization API_AVAILABLE(ios(14)); +#endif + /** Specifies the type of user activity associated with the location updates. @@ -78,6 +90,17 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)setActivityType:(CLActivityType)activityType; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 +/** + Requests the user's permission to temporarily use location update services + with full accuracy. + + @note If the user turned off location accuracy you may use this method to + request full accuracy for a session. + */ +- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString *)purposeKey API_AVAILABLE(ios(14)); +#endif + @required /** @@ -195,6 +218,14 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)locationManager:(id)manager didFailWithError:(nonnull NSError *)error; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 +/** + Notifies the delegate that the location authorization status has changed. + + @param manager The location manager reporting the change. + */ +- (void)locationManagerDidChangeAuthorization:(id)manager; +#endif @optional diff --git a/platform/ios/platform/darwin/src/MGLLocationManager.m b/platform/ios/platform/darwin/src/MGLLocationManager.m index 29e3ccaa30f..cdee3777356 100644 --- a/platform/ios/platform/darwin/src/MGLLocationManager.m +++ b/platform/ios/platform/darwin/src/MGLLocationManager.m @@ -38,7 +38,16 @@ - (CLLocationAccuracy)desiredAccuracy { } - (CLAuthorizationStatus)authorizationStatus { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 + if (@available(iOS 14.0, *)) { + return self.locationManager.authorizationStatus; + } else { + return kCLAuthorizationStatusNotDetermined; + } +#else + return [CLLocationManager authorizationStatus]; return [CLLocationManager authorizationStatus]; +#endif } - (void)setActivityType:(CLActivityType)activityType { @@ -49,6 +58,23 @@ - (CLActivityType)activityType { return self.locationManager.activityType; } +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 +- (CLAccuracyAuthorization)accuracyAuthorization { + if (@available(iOS 14.0, *)) { + return self.locationManager.accuracyAuthorization; + } else { + return CLAccuracyAuthorizationFullAccuracy; + } +} + +- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString *)purposeKey { + if (@available(iOS 14.0, *)) { + [self.locationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:purposeKey]; + } +} +#endif + + - (void)dismissHeadingCalibrationDisplay { [self.locationManager dismissHeadingCalibrationDisplay]; } @@ -113,4 +139,9 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError * } } +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 +- (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager { + [self.delegate locationManagerDidChangeAuthorization:self]; +} +#endif @end diff --git a/platform/ios/platform/darwin/src/MGLObserver.h b/platform/ios/platform/darwin/src/MGLObserver.h new file mode 100644 index 00000000000..b46829747b8 --- /dev/null +++ b/platform/ios/platform/darwin/src/MGLObserver.h @@ -0,0 +1,65 @@ +#import "MGLFoundation.h" +#import "MGLEvent.h" + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - + +/** + Base class for observers used to receive notifications from an `MGLObservable`. + Subclasses should only override `-[MGLObserver notifyWithEvent:]`. + */ +MGL_EXPORT +@interface MGLObserver: NSObject + +/// A unique identifier that can be used to identify an observer. +@property (nonatomic, readonly) NSUInteger identifier; + +/// Primary notification method. +- (void)notifyWithEvent:(MGLEvent*)event; + +// TODO: document +- (BOOL)isEqualToObserver:(MGLObserver *)other; +@end + + +#pragma mark - + +/** + Protocol that yypes that wish to support subscriptions for events should conform + to. + */ +MGL_EXPORT +@protocol MGLObservable + +/** + Subscribes an `MGLObserver` to a provided set of event types. + `MGLObservable` will hold a strong reference to an `MGLObserver` instance, + therefore, in order to stop receiving notifications (and to avoid memory leaks), + the caller must call unsubscribe with the `MGLObserver` instance used for + the initial subscription. + + @param observer an MGLObserver + @param events a set of event types to subscribe to. + */ +- (void)subscribeForObserver:(nonnull MGLObserver *)observer + events:(nonnull NSSet *)events; + +/** + Unsubscribes an `MGLObserver` from a provided set of event types. + + @param observer an MGLObserver + @param events a set of event types to unsubscribe from. + */ +- (void)unsubscribeForObserver:(nonnull MGLObserver *)observer + events:(nonnull NSSet *)events; +/** + Unsubscribes an `MGLObserver` from all events (and release the strong reference). + + @param observer an MGLObserver + */ +- (void)unsubscribeForObserver:(nonnull MGLObserver *)observer; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLObserver.mm b/platform/ios/platform/darwin/src/MGLObserver.mm new file mode 100644 index 00000000000..54ae76ab558 --- /dev/null +++ b/platform/ios/platform/darwin/src/MGLObserver.mm @@ -0,0 +1,101 @@ +#import "MGLObserver_Private.h" +#import "MGLLoggingConfiguration_Private.h" +#import "MGLEvent_Private.h" + +#pragma mark - Native C++ peer object + +namespace mbgl { +namespace darwin { + +void Observer::notify(const ObservableEvent& event) { + + if (!observer) { + MGLLogWarning(@"Platform observer has been deallocated"); + return; + } + + [observer notifyWithEvent:[[MGLEvent alloc] initWithEvent:event]]; +} + +std::size_t Observer::id() const { + if (!observer) { + MGLLogWarning(@"Platform observer has been deallocated"); + return 0; + } + + return static_cast(observer.identifier); +} + +} +} + +#pragma mark - Cocoa observer + +@implementation MGLObserver ++ (NSUInteger)nextIdentifier { + static NSUInteger identifier; + return ++identifier; +} + +- (void)dealloc { + MGLAssert(!_observing, @"Ensure the observer is unsubscribed before deallocating"); +} + +- (instancetype)init { + self = [super init]; + + if (!self) return nil; + + _identifier = [MGLObserver nextIdentifier]; + _peer = std::make_shared(self); + + return self; +} + +- (void)notifyWithEvent:(MGLEvent*)event { + if (self.notificationHandler) { + self.notificationHandler(event); + } +} + +- (BOOL)isEqualToObserver:(MGLObserver *)other { + if (self == other) + return YES; + + if (self.identifier != other.identifier) + return NO; + + return (self.peer == other.peer); +} + +- (BOOL)isEqual:(id)other { + if (self == other) + return YES; + + if (![other isKindOfClass:[MGLObserver class]]) { + return NO; + } + + return [self isEqualToObserver:(MGLObserver*)other]; +} + +- (NSUInteger)hash { + // Rotate the address + NSUInteger peerHash = reinterpret_cast(self.peer.get()); + + NSUInteger width = (sizeof(NSUInteger) * __CHAR_BIT__); + NSUInteger shift = self.identifier % width; + + NSUInteger newHash = (peerHash << shift) | (peerHash >> (width - shift)); + return newHash; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p; identifier = %lu, peer = %p, hash = %lu>", + NSStringFromClass([self class]), (void *)self, + (unsigned long)self.identifier, + self.peer.get(), + (unsigned long)[self hash]]; +} + +@end \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLObserver_Private.h b/platform/ios/platform/darwin/src/MGLObserver_Private.h new file mode 100644 index 00000000000..2fe8fcb6c3b --- /dev/null +++ b/platform/ios/platform/darwin/src/MGLObserver_Private.h @@ -0,0 +1,40 @@ +#import + +#import "MGLObserver.h" + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - Native C++ peer object + +namespace mbgl { +namespace darwin { + +class Observer : public mbgl::Observer { +public: + Observer(MGLObserver *observer_): observer(observer_) {} + virtual ~Observer() = default; + virtual void notify(const ObservableEvent& event); + virtual std::size_t id() const; + +protected: + + /// Cocoa observer that this adapter bridges to. + __weak MGLObserver *observer = nullptr; +}; + +} +} + +#pragma mark - +@interface MGLObserver () +@property (nonatomic, assign) std::shared_ptr peer; + +// TODO: Consider making public +@property (nonatomic, copy) void (^notificationHandler)(MGLEvent *); + +// Debug property used for development. +@property (nonatomic, assign) BOOL observing; +@end + +NS_ASSUME_NONNULL_END + diff --git a/platform/ios/platform/darwin/src/MGLStyleValue.mm b/platform/ios/platform/darwin/src/MGLStyleValue.mm index 01ad108d7fd..f379e71b8a1 100644 --- a/platform/ios/platform/darwin/src/MGLStyleValue.mm +++ b/platform/ios/platform/darwin/src/MGLStyleValue.mm @@ -14,6 +14,8 @@ id MGLJSONObjectFromMBGLValue(const mbgl::Value &value) { return @(value); }, [](const int64_t value) { return @(value); + }, [](const uint64_t value) { + return @(value); }, [](const double value) { return @(value); }, [](const std::string &value) { diff --git a/platform/ios/platform/darwin/src/MGLStyleValue_Private.h b/platform/ios/platform/darwin/src/MGLStyleValue_Private.h index 43f0b9d2825..cec6e1aaef0 100644 --- a/platform/ios/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/ios/platform/darwin/src/MGLStyleValue_Private.h @@ -35,6 +35,8 @@ namespace mbgl { } } +id MGLJSONObjectFromMBGLValue(const mbgl::Value &value); + NS_INLINE MGLTransition MGLTransitionFromOptions(const mbgl::style::TransitionOptions& options) { MGLTransition transition; transition.duration = MGLTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); diff --git a/platform/ios/platform/ios/CHANGELOG.md b/platform/ios/platform/ios/CHANGELOG.md index e0f53587773..114aa806790 100644 --- a/platform/ios/platform/ios/CHANGELOG.md +++ b/platform/ios/platform/ios/CHANGELOG.md @@ -6,6 +6,19 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### Features +* Added `MGLLocationManager.accuracyAuthorization` and `[MGLLocationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKeyproperty:]` to support iOS 14 location accuracy privacy changes. (cherry pick from [#361](https://github.com/mapbox/mapbox-gl-native-ios/pull/361)) +* Added `[MGLLocationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKeyproperty:]` to allow developers request just-in-time full-accuracy permissions. (cherry pick from [#361](https://github.com/mapbox/mapbox-gl-native-ios/pull/361)) +* Added `[MGLLocationManagerDelegate locationManagerDidChangeAuthorization:]` to let `MGLMapView` know about privacy changes. (cherry pick from [#376](https://github.com/mapbox/mapbox-gl-native-ios/pull/376)) +* Added `[MGLMapViewDelegate mapView:didChangeLocationManagerAuthorization:]` to allow developers adjust their apps to privacy settings changes. (cherry pick from [#376](https://github.com/mapbox/mapbox-gl-native-ios/pull/376)) +* Added `MGLObserver`, `MGLObservable` and `MGLEvent` to monitor events from the map view. (cherry pick from [#358](https://github.com/mapbox/mapbox-gl-native-ios/pull/358)) +* Added an approximate user location halo when `MGLLocationManager.accuracyAuthorization` is set to `CLAccuracyAuthorizationReducedAccuracy`. (cherry pick from [#381](https://github.com/mapbox/mapbox-gl-native-ios/pull/381)) +* The `MGLAccuracyAuthorizationDescription` as element of `NSLocationTemporaryUsageDescriptionDictionary` Info.plist key can now be set to describe why you request accuracy authorization. (cherry pick from [#392](https://github.com/mapbox/mapbox-gl-native-ios/pull/392)) +* Added `[MGLMapViewDelegate mapViewStyleForDefaultUserLocationAnnotationView:]` and `MGLUserLocationAnnotationViewStyle` class to allow developers customize the default user location annotation view UI style. (cherry pick from [#403](https://github.com/mapbox/mapbox-gl-native-ios/pull/403)) + +### Bug Fixes + +* Fixed an issue that caused a crash when custom location managers did not implement `MGLLocationManager.accuracyAuthorization`. (cherry pick from [#474](https://github.com/mapbox/mapbox-gl-native-ios/pull/474)) + ### Other * mapbox-gl-js submodule has been replaced with maplibre-gl-js diff --git a/platform/ios/platform/ios/app/Info.plist b/platform/ios/platform/ios/app/Info.plist index e7c23e481e4..b349ea331d7 100644 --- a/platform/ios/platform/ios/app/Info.plist +++ b/platform/ios/platform/ios/app/Info.plist @@ -24,6 +24,11 @@ 15256 LSRequiresIPhoneOS + NSLocationTemporaryUsageDescriptionDictionary + + MGLAccuracyAuthorizationDescription + MapLibre requires your precise location to help you navigate the map. + NSHumanReadableCopyright © 2014–2019 Mapbox NSLocationAlwaysUsageDescription diff --git a/platform/ios/platform/ios/app/MBXOrnamentsViewController.m b/platform/ios/platform/ios/app/MBXOrnamentsViewController.m index f451f647e52..28dc79641e7 100644 --- a/platform/ios/platform/ios/app/MBXOrnamentsViewController.m +++ b/platform/ios/platform/ios/app/MBXOrnamentsViewController.m @@ -2,7 +2,7 @@ #import "MBXOrnamentsViewController.h" -@interface MBXOrnamentsViewController () +@interface MBXOrnamentsViewController () @property (nonatomic) MGLMapView *mapView; @property (nonatomic) NSTimer *timer; @@ -64,7 +64,6 @@ - (void)viewDidLoad { zoomLevel:16 direction:30 animated:NO]; - mapView.delegate = self; mapView.showsScale = YES; [self.view addSubview:mapView]; diff --git a/platform/ios/platform/ios/app/MBXViewController.m b/platform/ios/platform/ios/app/MBXViewController.m index af668317c01..1c8a7519d33 100644 --- a/platform/ios/platform/ios/app/MBXViewController.m +++ b/platform/ios/platform/ios/app/MBXViewController.m @@ -15,7 +15,6 @@ #import "MBXFrameTimeGraphView.h" #import "../src/MGLMapView_Experimental.h" - #import static const CLLocationCoordinate2D WorldTourDestinations[] = { @@ -193,6 +192,15 @@ @interface MBXSpriteBackedAnnotation : MGLPointAnnotation @implementation MBXSpriteBackedAnnotation @end +@interface MBXTestObserver: MGLObserver +@end + +@implementation MBXTestObserver +- (void)notifyWithEvent:(MGLEvent *)event { + NSLog(@"Received event: %@", event); +} +@end + @interface MBXViewController () *helperWindows; @property (nonatomic) NSMutableArray *contentInsetsOverlays; - +@property (nonatomic) MBXTestObserver *testObserver; +@property (nonatomic, copy) void (^locationBlock)(void); @end @interface MGLMapView (MBXViewController) @@ -300,6 +309,15 @@ - (void)viewDidLoad } } }]; + + // TODO: Replace with menu implementation + self.testObserver = [[MBXTestObserver alloc] init]; + [self.mapView subscribeForObserver:self.testObserver event:MGLEventTypeResourceRequest]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.mapView unsubscribeForObserver:self.testObserver]; + self.testObserver = nil; + }); } - (UIInterfaceOrientationMask)supportedInterfaceOrientations @@ -1952,6 +1970,12 @@ - (IBAction)cycleStyles:(__unused id)sender } - (IBAction)locateUser:(id)sender +{ + [self nextTrackingMode:sender]; +} + + +- (void)nextTrackingMode:(id)sender { MGLUserTrackingMode nextMode; NSString *nextAccessibilityValue; @@ -2333,6 +2357,34 @@ - (void)mapViewDidFinishRenderingFrame:(MGLMapView *)mapView fullyRendered:(BOOL } } +- (void)mapView:(nonnull MGLMapView *)mapView didChangeLocationManagerAuthorization:(nonnull id)manager { + if (@available(iOS 14, *)) { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 + if (manager.authorizationStatus == kCLAuthorizationStatusDenied || manager.accuracyAuthorization == CLAccuracyAuthorizationReducedAccuracy) { + [self alertAccuracyChanges]; + } +#endif + } +} + +- (void)alertAccuracyChanges { + UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Mapbox GL works best with your precise location." + message:@"You'll get turn-by-turn directions." + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *settingsAction = [UIAlertAction actionWithTitle:@"Turn On in Settings" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; + }]; + + UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Keep Precise Location Off" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + handler:nil]; + + [alert addAction:settingsAction]; + [alert addAction:defaultAction]; + [self presentViewController:alert animated:YES completion:nil]; +} + - (void)saveCurrentMapState:(__unused NSNotification *)notification { // The following properties can change after the view loads so we need to save their diff --git a/platform/ios/platform/ios/docs/guides/Info.plist Keys.md b/platform/ios/platform/ios/docs/guides/Info.plist Keys.md index 44604576467..39dfceb0836 100644 --- a/platform/ios/platform/ios/docs/guides/Info.plist Keys.md +++ b/platform/ios/platform/ios/docs/guides/Info.plist Keys.md @@ -10,6 +10,22 @@ Mapbox-hosted vector tiles and styles require an API access token, which you can As an alternative, you can use `MGLAccountManager.accessToken` to set a token in code. See [our guide](https://www.mapbox.com/help/ios-private-access-token/) for some tips on keeping access tokens in open source code private. +## MGLAccuracyAuthorizationDescription + +Set the Mapbox accuracy authorization description string as an element of `NSLocationTemporaryUsageDescriptionDictionary` to be used by the map to request authorization when the `MGLLocationManager.accuracyAuthorization` is set to `CLAccuracyAuthorizationReducedAccuracy`. Requesting accuracy authorization is available for devices running iOS 14.0 and above. + +Example: + +```xml +NSLocationTemporaryUsageDescriptionDictionary + + MGLAccuracyAuthorizationDescription + Mapbox requires your precise location to help you navigate the map. + +``` + +Remove `MGLAccuracyAuthorizationDescription` if you want to control when to request for accuracy authorization. + ## MGLMapboxAPIBaseURL Use this key if you need to customize the API base URL used throughout the SDK. If unset, the default Mapbox API is used. @@ -47,4 +63,3 @@ At runtime, you can obtain the value of this key using the `MGLOfflineStorage.da Beginning in version 4.0, the SDK also performs collision detection between style layers based on different sources by default. For the default behavior, omit the `MGLCollisionBehaviorPre4_0` key or set it to NO (`false`). This property may also be set using `[[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"MGLCollisionBehaviorPre4_0"]`; it will override any value specified in the `Info.plist`. - diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 62d5c2dbd7b..3cb975a8b5b 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -224,6 +224,22 @@ 40F887701D7A1E58008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40F887711D7A1E59008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; }; + 4BC5767B25E3C8AB006E06EB /* MGLObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767525E3C8AA006E06EB /* MGLObserver.h */; }; + 4BC5767C25E3C8AB006E06EB /* MGLObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767525E3C8AA006E06EB /* MGLObserver.h */; }; + 4BC5767D25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */; }; + 4BC5767E25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */; }; + 4BC5767F25E3C8AB006E06EB /* MGLEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */; }; + 4BC5768025E3C8AB006E06EB /* MGLEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */; }; + 4BC5768125E3C8AB006E06EB /* MGLObserver.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */; }; + 4BC5768225E3C8AB006E06EB /* MGLObserver.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */; }; + 4BC5768325E3C8AB006E06EB /* MGLEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767925E3C8AB006E06EB /* MGLEvent.h */; }; + 4BC5768425E3C8AB006E06EB /* MGLEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767925E3C8AB006E06EB /* MGLEvent.h */; }; + 4BC5768525E3C8AB006E06EB /* MGLObserver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */; }; + 4BC5768625E3C8AB006E06EB /* MGLObserver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */; }; + 4BC5769325E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; }; + 4BC5769425E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; }; + 4BC5769525E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */; }; + 4BC5769625E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */; }; 550570C622958FB400228ECF /* MGLMapView+Impl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 550570C422958FB300228ECF /* MGLMapView+Impl.mm */; }; 550570C722958FB400228ECF /* MGLMapView+Impl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 550570C422958FB300228ECF /* MGLMapView+Impl.mm */; }; 550570C822958FB400228ECF /* MGLMapView+Impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 550570C522958FB400228ECF /* MGLMapView+Impl.h */; }; @@ -907,6 +923,14 @@ 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLShapeSource_Private.h; sourceTree = ""; }; 40FDA7691CCAAA6800442548 /* MBXAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBXAnnotationView.h; sourceTree = ""; }; 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXAnnotationView.m; sourceTree = ""; }; + 4BC5767525E3C8AA006E06EB /* MGLObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLObserver.h; sourceTree = ""; }; + 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLEvent_Private.h; sourceTree = ""; }; + 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLEvent.mm; sourceTree = ""; }; + 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLObserver.mm; sourceTree = ""; }; + 4BC5767925E3C8AB006E06EB /* MGLEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLEvent.h; sourceTree = ""; }; + 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLObserver_Private.h; sourceTree = ""; }; + 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationAnnotationViewStyle.h; sourceTree = ""; }; + 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLUserLocationAnnotationViewStyle.m; sourceTree = ""; }; 550570C422958FB300228ECF /* MGLMapView+Impl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MGLMapView+Impl.mm"; sourceTree = ""; }; 550570C522958FB400228ECF /* MGLMapView+Impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MGLMapView+Impl.h"; sourceTree = ""; }; 554180411D2E97DE00012372 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; @@ -1894,6 +1918,12 @@ 1F6A82A021360F9C00BA5B41 /* MGLLoggingConfiguration.h */, CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */, 1F6A82A62138871900BA5B41 /* MGLLoggingConfiguration_Private.h */, + 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */, + 4BC5767925E3C8AB006E06EB /* MGLEvent.h */, + 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */, + 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */, + 4BC5767525E3C8AA006E06EB /* MGLObserver.h */, + 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */, ); name = Foundation; path = ../darwin/src; @@ -1919,6 +1949,8 @@ 5580B45A229570A10091291B /* MGLMapView+OpenGL.mm */, DA8848371CBAFB8500AB86E3 /* MGLMapView+IBAdditions.h */, DA737EE01D056A4E005BDA16 /* MGLMapViewDelegate.h */, + 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */, + 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */, ); name = Kit; path = src; @@ -2182,6 +2214,7 @@ 357FE2DD1E02D2B20068B753 /* NSCoder+MGLAdditions.h in Headers */, 35D13AB71D3D15E300AFB4E0 /* MGLStyleLayer.h in Headers */, 07D947531F67488E00E37934 /* MGLComputedShapeSource_Private.h in Headers */, + 4BC5768325E3C8AB006E06EB /* MGLEvent.h in Headers */, 9654C1261FFC1AB900DB6A19 /* MGLPolyline_Private.h in Headers */, 40F887701D7A1E58008ECB67 /* MGLShapeSource_Private.h in Headers */, 350098DC1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.h in Headers */, @@ -2195,6 +2228,7 @@ 3510FFF01D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */, 74CB5EBF219B280400102936 /* MGLHeatmapStyleLayer_Private.h in Headers */, 1FC4817D2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */, + 4BC5767B25E3C8AB006E06EB /* MGLObserver.h in Headers */, 1F2B94C0221636D900210640 /* MGLNetworkConfiguration_Private.h in Headers */, 353AFA141D65AB17005A69F4 /* NSDate+MGLAdditions.h in Headers */, DA8848531CBAFB9800AB86E3 /* MGLCompactCalloutView.h in Headers */, @@ -2239,6 +2273,7 @@ CAFB3C14234505D500399265 /* MGLMapSnapshotter_Private.h in Headers */, 1FCAE2A220B872A400C577DD /* MGLLocationManager.h in Headers */, DACA86262019218600E9693A /* MGLRasterDEMSource.h in Headers */, + 4BC5769325E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */, 353933F81D3FB79F003F57D7 /* MGLLineStyleLayer.h in Headers */, 92F2C3ED1F0E3C3A00268EC0 /* MGLRendererFrontend.h in Headers */, DAAF722D1DA903C700312FA4 /* MGLStyleValue_Private.h in Headers */, @@ -2300,6 +2335,7 @@ DA72620B1DEEE3480043BB89 /* MGLOpenGLStyleLayer.h in Headers */, 404C26E71D89C55D000AA13D /* MGLTileSource_Private.h in Headers */, DA88485C1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.h in Headers */, + 4BC5767D25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */, 359F57461D2FDDA6005217F1 /* MGLUserLocationAnnotationView_Private.h in Headers */, 404C26E21D89B877000AA13D /* MGLTileSource.h in Headers */, DA8847FD1CBAFA5100AB86E3 /* MGLTilePyramidOfflineRegion.h in Headers */, @@ -2308,6 +2344,7 @@ 350098BB1D480108004B2AF0 /* MGLVectorTileSource.h in Headers */, DA8847F61CBAFA5100AB86E3 /* MGLOfflineStorage.h in Headers */, DAD1656E1CF41981001FF4B9 /* MGLFeature_Private.h in Headers */, + 4BC5768525E3C8AB006E06EB /* MGLObserver_Private.h in Headers */, DA88483C1CBAFB8500AB86E3 /* MGLMapView.h in Headers */, 3EA9363147E77DD29FA06063 /* MGLRendererConfiguration.h in Headers */, 550570C822958FB400228ECF /* MGLMapView+Impl.h in Headers */, @@ -2340,6 +2377,7 @@ 3566C7671D4A77BA008152BC /* MGLShapeSource.h in Headers */, DA35A29F1CC9E94C00E826B2 /* MGLCoordinateFormatter.h in Headers */, 967C864C210A9D3C004DF794 /* UIDevice+MGLAdditions.h in Headers */, + 4BC5768425E3C8AB006E06EB /* MGLEvent.h in Headers */, 404C26E31D89B877000AA13D /* MGLTileSource.h in Headers */, 96E516F6200059EC00A02306 /* MGLRendererFrontend.h in Headers */, 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */, @@ -2353,6 +2391,7 @@ 96E516EF2000594F00A02306 /* NSArray+MGLAdditions.h in Headers */, 96E516F12000596800A02306 /* NSString+MGLAdditions.h in Headers */, 35E0CFE71D3E501500188327 /* MGLStyle_Private.h in Headers */, + 4BC5767C25E3C8AB006E06EB /* MGLObserver.h in Headers */, CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */, DABFB86D1CBE9A0F00D62B32 /* MGLAnnotationImage.h in Headers */, DABFB8721CBE9A0F00D62B32 /* MGLUserLocation.h in Headers */, @@ -2397,6 +2436,7 @@ 1F2B94C1221636D900210640 /* MGLNetworkConfiguration_Private.h in Headers */, 35CE61831D4165D9004F2359 /* UIColor+MGLAdditions.h in Headers */, 96E516F32000597100A02306 /* NSDictionary+MGLAdditions.h in Headers */, + 4BC5769425E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */, 1FCAE2A920B88B3800C577DD /* MGLLocationManager_Private.h in Headers */, 96E516F02000595800A02306 /* NSBundle+MGLAdditions.h in Headers */, 96E516F920005A3500A02306 /* MGLFaux3DUserLocationAnnotationView.h in Headers */, @@ -2458,6 +2498,7 @@ 96E516E82000560B00A02306 /* MGLAnnotationContainerView_Private.h in Headers */, 35D13AC41D3D19DD00AFB4E0 /* MGLFillStyleLayer.h in Headers */, DABFB86E1CBE9A0F00D62B32 /* MGLCalloutView.h in Headers */, + 4BC5767E25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */, 96E516FC20005A4400A02306 /* MGLUserLocationHeadingIndicator.h in Headers */, 1F7454971ECD450D00021D39 /* MGLLight_Private.h in Headers */, DABFB8601CBE99E500D62B32 /* MGLMapCamera.h in Headers */, @@ -2466,6 +2507,7 @@ DABFB86A1CBE99E500D62B32 /* MGLStyle.h in Headers */, DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */, 96E516E12000551100A02306 /* MGLMultiPoint_Private.h in Headers */, + 4BC5768625E3C8AB006E06EB /* MGLObserver_Private.h in Headers */, 3EA934623AD0000B7D99C3FB /* MGLRendererConfiguration.h in Headers */, DACA86272019218600E9693A /* MGLRasterDEMSource.h in Headers */, 9621F2502091020E005B3800 /* NSExpression+MGLAdditions.h in Headers */, @@ -3055,6 +3097,7 @@ DA8848261CBAFA6200AB86E3 /* MGLPolygon.mm in Sources */, 35B82BFA1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */, 966FCF4E1F3A5C9200F2B6DE /* MGLUserLocationHeadingBeamLayer.m in Sources */, + 4BC5768125E3C8AB006E06EB /* MGLObserver.mm in Sources */, 8989B17E201A48EB0081CF59 /* MGLHeatmapStyleLayer.mm in Sources */, 353AFA161D65AB17005A69F4 /* NSDate+MGLAdditions.mm in Sources */, 1FCAE2A420B872A400C577DD /* MGLLocationManager.m in Sources */, @@ -3062,6 +3105,7 @@ DA8848241CBAFA6200AB86E3 /* MGLOfflineStorage.mm in Sources */, DA88482A1CBAFA6200AB86E3 /* MGLTilePyramidOfflineRegion.mm in Sources */, 4049C29F1DB6CD6C00B3F799 /* MGLPointCollection.mm in Sources */, + 4BC5769525E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */, 35136D3F1D42273000C20EFD /* MGLLineStyleLayer.mm in Sources */, DA704CC41F65A475004B3F28 /* MGLMapAccessibilityElement.mm in Sources */, DA72620D1DEEE3480043BB89 /* MGLOpenGLStyleLayer.mm in Sources */, @@ -3070,6 +3114,7 @@ DA8848271CBAFA6200AB86E3 /* MGLPolyline.mm in Sources */, 35CE61841D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */, 3EA93369F61CF70AFA50465D /* MGLRendererConfiguration.m in Sources */, + 4BC5767F25E3C8AB006E06EB /* MGLEvent.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3151,6 +3196,7 @@ 966FCF4F1F3A5C9200F2B6DE /* MGLUserLocationHeadingBeamLayer.m in Sources */, DAA4E4231CBB730400178DFB /* MGLPolygon.mm in Sources */, 8989B17F201A48EB0081CF59 /* MGLHeatmapStyleLayer.mm in Sources */, + 4BC5768225E3C8AB006E06EB /* MGLObserver.mm in Sources */, 353AFA171D65AB17005A69F4 /* NSDate+MGLAdditions.mm in Sources */, 35D13AC61D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm in Sources */, 1FCAE2A520B872A400C577DD /* MGLLocationManager.m in Sources */, @@ -3158,6 +3204,7 @@ 4049C2A01DB6CD6C00B3F799 /* MGLPointCollection.mm in Sources */, 35136D401D42273000C20EFD /* MGLLineStyleLayer.mm in Sources */, DA704CC51F65A475004B3F28 /* MGLMapAccessibilityElement.mm in Sources */, + 4BC5769625E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */, DA72620E1DEEE3480043BB89 /* MGLOpenGLStyleLayer.mm in Sources */, DAA4E42F1CBB730400178DFB /* MGLCompactCalloutView.m in Sources */, 3510FFFC1D6DCC4700F413B2 /* NSCompoundPredicate+MGLAdditions.mm in Sources */, @@ -3166,6 +3213,7 @@ 35CE61851D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */, DAA4E4241CBB730400178DFB /* MGLPolyline.mm in Sources */, 3EA9366247780E4F252652A8 /* MGLRendererConfiguration.m in Sources */, + 4BC5768025E3C8AB006E06EB /* MGLEvent.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m b/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m index 30ab7de269c..fc77c659dcd 100644 --- a/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m +++ b/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m @@ -1,10 +1,13 @@ #import "MGLFaux3DUserLocationAnnotationView.h" #import "MGLMapView.h" +#import "MGLMapViewDelegate.h" #import "MGLUserLocation.h" #import "MGLUserLocationHeadingIndicator.h" #import "MGLUserLocationHeadingArrowLayer.h" #import "MGLUserLocationHeadingBeamLayer.h" +#import "MGLLocationManager_Private.h" +#import "MGLUserLocationAnnotationViewStyle.h" const CGFloat MGLUserLocationAnnotationDotSize = 22.0; const CGFloat MGLUserLocationAnnotationHaloSize = 115.0; @@ -14,9 +17,12 @@ const CGFloat MGLUserLocationHeadingUpdateThreshold = 0.01; +const CGFloat MGLUserLocationApproximateZoomThreshold = 7.0; + @implementation MGLFaux3DUserLocationAnnotationView { BOOL _puckModeActivated; + BOOL _approximateModeActivated; CALayer *_puckDot; CAShapeLayer *_puckArrow; @@ -27,6 +33,8 @@ @implementation MGLFaux3DUserLocationAnnotationView CALayer *_dotLayer; CALayer *_haloLayer; + CALayer *_approximateLayer; + CLLocationDirection _oldHeadingAccuracy; CLLocationAccuracy _oldHorizontalAccuracy; double _oldZoom; @@ -49,28 +57,77 @@ - (void)update if (CLLocationCoordinate2DIsValid(self.userLocation.coordinate)) { - (self.mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? [self drawPuck] : [self drawDot]; - [self updatePitch]; + if (@available(iOS 14, *)) { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 + if (![self.mapView.locationManager respondsToSelector:@selector(accuracyAuthorization)] || + self.mapView.locationManager.accuracyAuthorization == CLAccuracyAuthorizationFullAccuracy) { + [self drawPreciseLocationPuck]; + } else { + [self drawApproximate]; + [self updatePitch]; + } +#endif + } else { + [self drawPreciseLocationPuck]; + } + } +} +- (void)drawPreciseLocationPuck { + if (_approximateModeActivated) { + [_approximateLayer removeFromSuperlayer]; + _approximateLayer = nil; + + _approximateModeActivated = NO; + } + (self.mapView.userTrackingMode == MGLUserTrackingModeFollowWithCourse) ? [self drawPuck] : [self drawDot]; + [self updatePitch]; _haloLayer.hidden = ! CLLocationCoordinate2DIsValid(self.mapView.userLocation.coordinate) || self.mapView.userLocation.location.horizontalAccuracy > 10; } + - (void)setTintColor:(UIColor *)tintColor { - CGColorRef newTintColor = [tintColor CGColor]; - + UIColor *puckArrowFillColor = tintColor; + UIColor *puckArrowStrokeColor = tintColor; + + UIColor *approximateFillColor = tintColor; + + UIColor *accuracyFillColor = tintColor; + UIColor *haloFillColor = tintColor; + UIColor *dotFillColor = tintColor; + UIColor *headingFillColor = tintColor; + + if ([self.mapView.delegate respondsToSelector:@selector(mapViewStyleForDefaultUserLocationAnnotationView:)]) { + MGLUserLocationAnnotationViewStyle *style = [self.mapView.delegate mapViewStyleForDefaultUserLocationAnnotationView:self.mapView]; + + puckArrowFillColor = style.puckArrowFillColor ? style.puckArrowFillColor : puckArrowFillColor; + + if (@available(iOS 14, *)) { + approximateFillColor = style.approximateHaloFillColor ? style.approximateHaloFillColor : approximateFillColor; + } + + haloFillColor = style.haloFillColor ? style.haloFillColor : haloFillColor; + dotFillColor = style.puckFillColor ? style.puckFillColor : dotFillColor; + headingFillColor = style.puckFillColor ? style.puckFillColor : headingFillColor; + } + if (_puckModeActivated) { - _puckArrow.fillColor = newTintColor; - _puckArrow.strokeColor = newTintColor; + _puckArrow.fillColor = [puckArrowFillColor CGColor]; + _puckArrow.strokeColor = [puckArrowStrokeColor CGColor]; + } + else if (_approximateModeActivated) + { + _approximateLayer.backgroundColor = [approximateFillColor CGColor]; } else { - _accuracyRingLayer.backgroundColor = newTintColor; - _haloLayer.backgroundColor = newTintColor; - _dotLayer.backgroundColor = newTintColor; - [_headingIndicatorLayer updateTintColor:newTintColor]; + _accuracyRingLayer.backgroundColor = [accuracyFillColor CGColor]; + _haloLayer.backgroundColor = [haloFillColor CGColor]; + _dotLayer.backgroundColor = [dotFillColor CGColor]; + [_headingIndicatorLayer updateTintColor:[headingFillColor CGColor]]; } } @@ -146,14 +203,26 @@ - (void)drawPuck [self updateFrameWithSize:MGLUserLocationAnnotationPuckSize]; } + UIColor *arrowColor = self.mapView.tintColor; + UIColor *puckShadowColor = UIColor.blackColor; + CGFloat shadowOpacity = 0.25; + + + if ([self.mapView.delegate respondsToSelector:@selector(mapViewStyleForDefaultUserLocationAnnotationView:)]) { + MGLUserLocationAnnotationViewStyle *style = [self.mapView.delegate mapViewStyleForDefaultUserLocationAnnotationView:self.mapView]; + arrowColor = style.puckArrowFillColor ? style.puckArrowFillColor : arrowColor; + puckShadowColor = style.puckShadowColor ? style.puckShadowColor : puckShadowColor; + shadowOpacity = style.puckShadowOpacity; + } + // background dot (white with black shadow) // if ( ! _puckDot) { _puckDot = [self circleLayerWithSize:MGLUserLocationAnnotationPuckSize]; _puckDot.backgroundColor = [[UIColor whiteColor] CGColor]; - _puckDot.shadowColor = [[UIColor blackColor] CGColor]; - _puckDot.shadowOpacity = 0.25; + _puckDot.shadowColor = [puckShadowColor CGColor]; + _puckDot.shadowOpacity = shadowOpacity; _puckDot.shadowPath = [[UIBezierPath bezierPathWithOvalInRect:_puckDot.bounds] CGPath]; if (self.mapView.camera.pitch) @@ -175,7 +244,7 @@ - (void)drawPuck { _puckArrow = [CAShapeLayer layer]; _puckArrow.path = [[self puckArrow] CGPath]; - _puckArrow.fillColor = [self.mapView.tintColor CGColor]; + _puckArrow.fillColor = [arrowColor CGColor]; _puckArrow.bounds = CGRectMake(0, 0, round(MGLUserLocationAnnotationArrowSize), round(MGLUserLocationAnnotationArrowSize)); _puckArrow.position = CGPointMake(CGRectGetMidX(super.bounds), CGRectGetMidY(super.bounds)); _puckArrow.shouldRasterize = YES; @@ -228,6 +297,20 @@ - (void)drawDot [self updateFrameWithSize:MGLUserLocationAnnotationDotSize]; } + + UIColor *haloColor = self.mapView.tintColor; + UIColor *puckBackgroundColor = self.mapView.tintColor; + UIColor *puckShadowColor = UIColor.blackColor; + CGFloat shadowOpacity = 0.25; + + if ([self.mapView.delegate respondsToSelector:@selector(mapViewStyleForDefaultUserLocationAnnotationView:)]) { + MGLUserLocationAnnotationViewStyle *style = [self.mapView.delegate mapViewStyleForDefaultUserLocationAnnotationView:self.mapView]; + haloColor = style.haloFillColor ? style.haloFillColor : haloColor; + puckBackgroundColor = style.puckFillColor ? style.puckFillColor : puckBackgroundColor; + puckShadowColor = style.puckShadowColor ? style.puckShadowColor : puckShadowColor; + shadowOpacity = style.puckShadowOpacity; + } + // heading indicator (tinted, beam or arrow) // BOOL headingTrackingModeEnabled = self.mapView.userTrackingMode == MGLUserTrackingModeFollowWithHeading; @@ -251,11 +334,13 @@ - (void)drawDot if (headingTrackingModeEnabled) { _headingIndicatorLayer = [[MGLUserLocationHeadingBeamLayer alloc] initWithUserLocationAnnotationView:self]; + [_headingIndicatorLayer updateTintColor:[haloColor CGColor]]; [self.layer insertSublayer:_headingIndicatorLayer below:_dotBorderLayer]; } else { _headingIndicatorLayer = [[MGLUserLocationHeadingArrowLayer alloc] initWithUserLocationAnnotationView:self]; + [_headingIndicatorLayer updateTintColor:[puckBackgroundColor CGColor]]; [self.layer addSublayer:_headingIndicatorLayer]; _headingIndicatorLayer.zPosition = 1; } @@ -351,7 +436,7 @@ - (void)drawDot if ( ! _haloLayer) { _haloLayer = [self circleLayerWithSize:MGLUserLocationAnnotationHaloSize]; - _haloLayer.backgroundColor = [self.mapView.tintColor CGColor]; + _haloLayer.backgroundColor = [haloColor CGColor]; _haloLayer.allowsGroupOpacity = NO; _haloLayer.zPosition = -0.1f; @@ -381,8 +466,8 @@ - (void)drawDot { _dotBorderLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize]; _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; - _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; - _dotBorderLayer.shadowOpacity = 0.25; + _dotBorderLayer.shadowColor = [puckShadowColor CGColor]; + _dotBorderLayer.shadowOpacity = shadowOpacity; _dotBorderLayer.shadowPath = [[UIBezierPath bezierPathWithOvalInRect:_dotBorderLayer.bounds] CGPath]; if (self.mapView.camera.pitch) @@ -403,7 +488,7 @@ - (void)drawDot if ( ! _dotLayer) { _dotLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75]; - _dotLayer.backgroundColor = [self.mapView.tintColor CGColor]; + _dotLayer.backgroundColor = [puckBackgroundColor CGColor]; // set defaults for the animations CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:1.5]; @@ -435,6 +520,85 @@ - (void)drawDot } } +- (void)drawApproximate +{ + if ( ! _approximateModeActivated) + { + self.layer.sublayers = nil; + + _headingIndicatorLayer = nil; + _dotBorderLayer = nil; + _dotLayer = nil; + _accuracyRingLayer = nil; + _haloLayer = nil; + _puckDot = nil; + _puckArrow = nil; + + _approximateModeActivated = YES; + } + + UIColor *backgroundColor = self.mapView.tintColor; + UIColor *strokeColor = UIColor.blackColor; + CGFloat borderSize = 2.0; + CGFloat opacity = 0.25; + + if ([self.mapView.delegate respondsToSelector:@selector(mapViewStyleForDefaultUserLocationAnnotationView:)]) { + MGLUserLocationAnnotationViewStyle *style = [self.mapView.delegate mapViewStyleForDefaultUserLocationAnnotationView:self.mapView]; + if (@available(iOS 14, *)) { + backgroundColor = style.approximateHaloFillColor ? style.approximateHaloFillColor : backgroundColor; + strokeColor = style.approximateHaloBorderColor ? style.approximateHaloBorderColor : strokeColor; + opacity = style.approximateHaloOpacity; + borderSize = style.approximateHaloBorderWidth; + } + } + + // update approximate ring (if zoom or horizontal accuracy have changed) + if (_approximateLayer && (_oldZoom != self.mapView.zoomLevel || _oldHorizontalAccuracy != self.userLocation.location.horizontalAccuracy)) + { + CGFloat borderWidth = 2; + if (self.mapView.zoomLevel < MGLUserLocationApproximateZoomThreshold) { + borderSize = 3; + } + _approximateLayer.borderWidth = borderSize; + + if (self.mapView.zoomLevel >= MGLUserLocationApproximateZoomThreshold) { + CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; + + _approximateLayer.hidden = NO; + + // disable implicit animation of the accuracy ring, unless triggered by a change in accuracy + BOOL shouldDisableActions = _oldHorizontalAccuracy == self.userLocation.location.horizontalAccuracy; + + [CATransaction begin]; + [CATransaction setDisableActions:shouldDisableActions]; + + _approximateLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize); + _approximateLayer.cornerRadius = accuracyRingSize / 2.0; + + [CATransaction commit]; + } + + // store accuracy and zoom so we're not redrawing unchanged location updates + _oldHorizontalAccuracy = self.userLocation.location.horizontalAccuracy; + _oldZoom = self.mapView.zoomLevel; + } + + // approximate ring + if ( ! _approximateLayer && self.userLocation.location.horizontalAccuracy) + { + CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; + _approximateLayer = [self circleLayerWithSize:accuracyRingSize]; + approximateLayer.backgroundColor = [backgroundColor CGColor]; + _approximateLayer.opacity = opacity; + _approximateLayer.shouldRasterize = NO; + _approximateLayer.allowsGroupOpacity = NO; + _approximateLayer.borderWidth = borderSize; + _approximateLayer.borderColor = [strokeColor CGColor]; + + [self.layer addSublayer:_approximateLayer]; + } +} + - (CALayer *)circleLayerWithSize:(CGFloat)layerSize { layerSize = round(layerSize); diff --git a/platform/ios/platform/ios/src/MGLMapView.h b/platform/ios/platform/ios/src/MGLMapView.h index f2eb51dd13d..a6c6ea3da17 100644 --- a/platform/ios/platform/ios/src/MGLMapView.h +++ b/platform/ios/platform/ios/src/MGLMapView.h @@ -6,6 +6,7 @@ #import "MGLMapCamera.h" #import "MGLTypes.h" #import "MGLStyle.h" +#import "MGLObserver.h" NS_ASSUME_NONNULL_BEGIN @@ -188,7 +189,7 @@ FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLUserLocationAnnotationTyp Simple map view example to learn how to initialize a basic `MGLMapView`. */ MGL_EXPORT -@interface MGLMapView : UIView +@interface MGLMapView : UIView #pragma mark Creating Instances @@ -2002,6 +2003,14 @@ MGL_EXPORT */ @property (nonatomic) MGLMapDebugMaskOptions debugMask; +/** + :nodoc: + Convenience method for subscribing to a single event. See `-[MGLObservable + subscribeForObserver:events:]`. + */ +- (void)subscribeForObserver:(nonnull MGLObserver *)observer + event:(nonnull MGLEventType)event; + @end NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/ios/src/MGLMapView.mm b/platform/ios/platform/ios/src/MGLMapView.mm index f16883b22cd..8890b11fb97 100644 --- a/platform/ios/platform/ios/src/MGLMapView.mm +++ b/platform/ios/platform/ios/src/MGLMapView.mm @@ -67,6 +67,8 @@ #import "MGLLoggingConfiguration_Private.h" #import "MGLNetworkConfiguration_Private.h" #import "MGLReachability.h" +#import "MGLObserver_Private.h" +#import "MGLEvent_Private.h" #include #include @@ -277,6 +279,8 @@ @interface MGLMapView () *observerCache; + @end @implementation MGLMapView @@ -517,6 +521,8 @@ - (void)commonInit _annotationViewReuseQueueByIdentifier = [NSMutableDictionary dictionary]; _selectedAnnotationTag = MGLAnnotationTagNotFound; _annotationsNearbyLastTap = {}; + + _observerCache = [NSMutableSet set]; // TODO: This warning should be removed when automaticallyAdjustsScrollViewInsets is removed from // the UIViewController api. @@ -5417,6 +5423,11 @@ - (void)validateLocationServices } } +- (NSString *)accuracyDescriptionString { + NSDictionary *dictionary = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationTemporaryUsageDescriptionDictionary"]; + return dictionary[@"MGLAccuracyAuthorizationDescription"]; +} + - (void)setShowsUserLocation:(BOOL)showsUserLocation { MGLLogDebug(@"Setting showsUserLocation: %@", MGLStringFromBOOL(showsUserLocation)); @@ -5975,6 +5986,47 @@ - (void)locationManager:(__unused id)manager didFailWithErro } } +- (void)locationManagerDidChangeAuthorization:(id)manager +{ + if (![self shouldShowLocationDotBasedOnCurrentLocationPermissions]) + { + [self.userLocationAnnotationView removeFromSuperview]; + [self.locationManager stopUpdatingLocation]; + [self.locationManager stopUpdatingHeading]; + } else { + if (@available(iOS 14, *)) { +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 + if (self.userTrackingMode != MGLUserTrackingModeNone && + [manager respondsToSelector:@selector(authorizationStatus)] && + (manager.authorizationStatus != kCLAuthorizationStatusRestricted || + manager.authorizationStatus != kCLAuthorizationStatusAuthorizedAlways || + manager.authorizationStatus != kCLAuthorizationStatusAuthorizedWhenInUse) && + [manager respondsToSelector:@selector(accuracyAuthorization)] && + manager.accuracyAuthorization == CLAccuracyAuthorizationReducedAccuracy && + [self accuracyDescriptionString] != nil ) { + [self.locationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:@"MGLAccuracyAuthorizationDescription"]; + } else { + [self validateLocationServices]; + } +#endif + } else { + [self validateLocationServices]; + } + } + + if (@available(iOS 14, *)) { + if ([self.delegate respondsToSelector:@selector(mapView:didChangeLocationManagerAuthorization:)]) { + [self.delegate mapView:self didChangeLocationManagerAuthorization:manager]; + } + } +} + +- (BOOL)shouldShowLocationDotBasedOnCurrentLocationPermissions +{ + return self.locationManager && (self.locationManager.authorizationStatus == kCLAuthorizationStatusAuthorizedAlways + || self.locationManager.authorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse); +} + - (void)updateHeadingForDeviceOrientation { if (self.locationManager) @@ -6840,6 +6892,41 @@ - (void)prepareForInterfaceBuilder return _annotationViewReuseQueueByIdentifier[identifier]; } +#pragma mark - MGLObservable methods - + +static std::vector vectorOfStringsFromSet(NSSet *setOfStrings) { + __block std::vector strings; + strings.reserve(setOfStrings.count); + [setOfStrings enumerateObjectsUsingBlock:^(NSString * _Nonnull text, BOOL * _Nonnull stop) { + strings.push_back(text.UTF8String); + }]; + return strings; +} + +// Convenience method +- (void)subscribeForObserver:(nonnull MGLObserver *)observer event:(nonnull MGLEventType)event { + [self subscribeForObserver:observer events:[NSSet setWithObject:event]]; +} + +- (void)subscribeForObserver:(MGLObserver *)observer events:(nonnull NSSet *)events { + observer.observing = YES; + [self.observerCache addObject:observer]; + + auto eventTypes = vectorOfStringsFromSet(events); + self.mbglMap.subscribe(observer.peer, eventTypes); +} + +- (void)unsubscribeForObserver:(MGLObserver *)observer events:(nonnull NSSet *)events { + auto eventTypes = vectorOfStringsFromSet(events); + self.mbglMap.unsubscribe(observer.peer, eventTypes); +} + +- (void)unsubscribeForObserver:(MGLObserver *)observer { + self.mbglMap.unsubscribe(observer.peer); + [self.observerCache removeObject:observer]; + observer.observing = NO; +} + @end #pragma mark - IBAdditions methods diff --git a/platform/ios/platform/ios/src/MGLMapViewDelegate.h b/platform/ios/platform/ios/src/MGLMapViewDelegate.h index 3ddb7b007f0..e3ba90e0547 100644 --- a/platform/ios/platform/ios/src/MGLMapViewDelegate.h +++ b/platform/ios/platform/ios/src/MGLMapViewDelegate.h @@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN @class MGLMapView; +@class MGLUserLocationAnnotationViewStyle; /** The `MGLMapViewDelegate` protocol defines a set of optional methods that you @@ -313,6 +314,16 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)mapViewDidStopLocatingUser:(MGLMapView *)mapView; +/** + Asks the delegate styling options for each default user location annotation view. + + 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 is tracking the user’s location. + */ +- (MGLUserLocationAnnotationViewStyle *)mapViewStyleForDefaultUserLocationAnnotationView:(MGLMapView *)mapView NS_SWIFT_NAME(mapView(styleForDefaultUserLocationAnnotationView:)); + /** Tells the delegate that the location of the user was updated. @@ -368,6 +379,18 @@ NS_ASSUME_NONNULL_BEGIN */ - (CGPoint)mapViewUserLocationAnchorPoint:(MGLMapView *)mapView; +/** + Tells the delegate that the map's location updates accuracy authorization has changed. + + This method is called after the user changes location accuracy authorization when + requesting location permissions or in privacy settings. + + @param mapView The map view that changed its location accuracy authorization. + @param manager The location manager reporting the update. + + */ +- (void)mapView:(MGLMapView *)mapView didChangeLocationManagerAuthorization:(id)manager API_AVAILABLE(ios(14)); + #pragma mark Managing the Appearance of Annotations /** diff --git a/platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.h b/platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.h new file mode 100644 index 00000000000..26c580a4c73 --- /dev/null +++ b/platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.h @@ -0,0 +1,57 @@ +#import + +#import "MGLFoundation.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + A class containing information about the default User Location annotation view style. + */ +MGL_EXPORT +@interface MGLUserLocationAnnotationViewStyle : NSObject + +/** + The fill color for the puck view. + */ +@property (nonatomic) UIColor *puckFillColor; +/** + The shadow color for the puck view. + */ +@property (nonatomic) UIColor *puckShadowColor; +/** + The shadow opacity for the puck view. + Set any value between 0.0 and 1.0. + The default value of this property is equal to `0.25` + */ +@property (nonatomic, assign) CGFloat puckShadowOpacity; +/** + The fill color for the arrow puck. + */ +@property (nonatomic) UIColor *puckArrowFillColor; +/** + The fill color for the puck view. + */ +@property (nonatomic) UIColor *haloFillColor; +/** + The halo fill color for the approximate view. + */ +@property (nonatomic) UIColor *approximateHaloFillColor API_AVAILABLE(ios(14)); +/** + The halo border color for the approximate view. + */ +@property (nonatomic) UIColor *approximateHaloBorderColor API_AVAILABLE(ios(14)); +/** + The halo border width for the approximate view. + The default value of this property is equal to `2.0` + */ +@property (nonatomic, assign) CGFloat approximateHaloBorderWidth API_AVAILABLE(ios(14)); +/** + The halo opacity for the approximate view. + Set any value between 0.0 and 1.0 + The default value of this property is equal to `0.15` + */ +@property (nonatomic, assign) CGFloat approximateHaloOpacity API_AVAILABLE(ios(14)); + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.m b/platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.m new file mode 100644 index 00000000000..3857a9c9e62 --- /dev/null +++ b/platform/ios/platform/ios/src/MGLUserLocationAnnotationViewStyle.m @@ -0,0 +1,62 @@ +#import "MGLUserLocationAnnotationViewStyle.h" +#import "MGLLoggingConfiguration_Private.h" + +@implementation MGLUserLocationAnnotationViewStyle + +- (instancetype)init { + if ((self = [super init])) { + self.puckShadowOpacity = 0.25; + if (@available(iOS 14, *)) { + self.approximateHaloBorderWidth = 2.0; + self.approximateHaloOpacity = 0.15; + } + } + return self; +} + +- (void)setPuckFillColor:(UIColor *)puckFillColor { + MGLLogDebug(@"Setting puckFillColor: %@", puckFillColor); + _puckFillColor = puckFillColor; +} + +- (void)setPuckShadowColor:(UIColor *)puckShadowColor { + MGLLogDebug(@"Setting puckShadowColor: %@", puckShadowColor); + _puckShadowColor = puckShadowColor; +} + +- (void)setPuckShadowOpacity:(CGFloat)puckShadowOpacity { + MGLLogDebug(@"Setting puckShadowOpacity: %.2f", puckShadowOpacity); + _puckShadowOpacity = puckShadowOpacity; +} + +- (void)setPuckArrowFillColor:(UIColor *)puckArrowFillColor { + MGLLogDebug(@"Setting puckArrowFillColor: %@", puckArrowFillColor); + _puckArrowFillColor = puckArrowFillColor; +} + +- (void)setHaloFillColor:(UIColor *)haloFillColor { + MGLLogDebug(@"Setting haloFillColor: %@", haloFillColor); + _haloFillColor = haloFillColor; +} + +- (void)setApproximateHaloFillColor:(UIColor *)approximateHaloFillColor { + MGLLogDebug(@"Setting approximateHaloFillColor: %@", approximateHaloFillColor); + _approximateHaloFillColor = approximateHaloFillColor; +} + +- (void)setApproximateHaloBorderColor:(UIColor *)approximateHaloBorderColor { + MGLLogDebug(@"Setting approximateHaloBorderColor: %@", approximateHaloBorderColor); + _approximateHaloBorderColor = approximateHaloBorderColor; +} + +- (void)setApproximateHaloBorderWidth:(CGFloat)approximateHaloBorderWidth { + MGLLogDebug(@"Setting approximateHaloBorderWidth: %.2f", approximateHaloBorderWidth); + _approximateHaloBorderWidth = approximateHaloBorderWidth; +} + +- (void)setApproximateHaloOpacity:(CGFloat)approximateHaloOpacity { + MGLLogDebug(@"Setting approximateHaloOpacity: %.2f", approximateHaloOpacity); + _approximateHaloOpacity = approximateHaloOpacity; +} + +@end \ No newline at end of file diff --git a/platform/ios/platform/ios/src/Mapbox.h b/platform/ios/platform/ios/src/Mapbox.h index b5fd86e851a..88e0486a8ac 100644 --- a/platform/ios/platform/ios/src/Mapbox.h +++ b/platform/ios/platform/ios/src/Mapbox.h @@ -1,5 +1,4 @@ #import - #import "MGLFoundation.h" /// Project version number for Mapbox. @@ -8,69 +7,73 @@ FOUNDATION_EXPORT MGL_EXPORT double MapboxVersionNumber; /// Project version string for Mapbox. FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; -#import "MGLAnnotationView.h" #import "MGLAccountManager.h" #import "MGLAnnotation.h" #import "MGLAnnotationImage.h" +#import "MGLAnnotationView.h" +#import "MGLAttributedExpression.h" +#import "MGLAttributionInfo.h" +#import "MGLBackgroundStyleLayer.h" #import "MGLCalloutView.h" +#import "MGLCircleStyleLayer.h" #import "MGLClockDirectionFormatter.h" #import "MGLCluster.h" #import "MGLCompassButton.h" #import "MGLCompassDirectionFormatter.h" +#import "MGLComputedShapeSource.h" #import "MGLCoordinateFormatter.h" #import "MGLDistanceFormatter.h" +#import "MGLEvent.h" #import "MGLFeature.h" +#import "MGLFillExtrusionStyleLayer.h" +#import "MGLFillStyleLayer.h" +#import "MGLForegroundStyleLayer.h" #import "MGLGeometry.h" +#import "MGLHeatmapStyleLayer.h" +#import "MGLHillshadeStyleLayer.h" +#import "MGLImageSource.h" #import "MGLLight.h" +#import "MGLLineStyleLayer.h" +#import "MGLLocationManager.h" +#import "MGLLoggingConfiguration.h" #import "MGLMapCamera.h" +#import "MGLMapSnapshotter.h" #import "MGLMapView.h" -#import "MGLMapView+IBAdditions.h" #import "MGLMapViewDelegate.h" +#import "MGLMapView+IBAdditions.h" #import "MGLMultiPoint.h" +#import "MGLNetworkConfiguration.h" +#import "MGLObserver.h" #import "MGLOfflinePack.h" #import "MGLOfflineRegion.h" #import "MGLOfflineStorage.h" +#import "MGLOpenGLStyleLayer.h" #import "MGLOverlay.h" #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" #import "MGLPolygon.h" #import "MGLPolyline.h" +#import "MGLRasterDEMSource.h" +#import "MGLRasterStyleLayer.h" +#import "MGLRasterTileSource.h" +#import "MGLSDKMetricsManager.h" #import "MGLShape.h" #import "MGLShapeCollection.h" +#import "MGLShapeOfflineRegion.h" +#import "MGLShapeSource.h" +#import "MGLSource.h" #import "MGLStyle.h" #import "MGLStyleLayer.h" -#import "MGLForegroundStyleLayer.h" -#import "MGLVectorStyleLayer.h" -#import "MGLFillExtrusionStyleLayer.h" -#import "MGLFillStyleLayer.h" -#import "MGLLineStyleLayer.h" +#import "MGLStyleValue.h" #import "MGLSymbolStyleLayer.h" -#import "MGLRasterStyleLayer.h" -#import "MGLCircleStyleLayer.h" -#import "MGLHeatmapStyleLayer.h" -#import "MGLHillshadeStyleLayer.h" -#import "MGLBackgroundStyleLayer.h" -#import "MGLOpenGLStyleLayer.h" -#import "MGLSource.h" -#import "MGLTileSource.h" -#import "MGLVectorTileSource.h" -#import "MGLShapeSource.h" -#import "MGLComputedShapeSource.h" -#import "MGLRasterTileSource.h" -#import "MGLRasterDEMSource.h" -#import "MGLImageSource.h" -#import "MGLShapeOfflineRegion.h" #import "MGLTilePyramidOfflineRegion.h" +#import "MGLTileSource.h" #import "MGLTypes.h" #import "MGLUserLocation.h" #import "MGLUserLocationAnnotationView.h" -#import "NSValue+MGLAdditions.h" -#import "MGLStyleValue.h" -#import "MGLAttributionInfo.h" -#import "MGLMapSnapshotter.h" +#import "MGLVectorStyleLayer.h" +#import "MGLVectorTileSource.h" #import "NSExpression+MGLAdditions.h" #import "NSPredicate+MGLAdditions.h" -#import "MGLLocationManager.h" -#import "MGLLoggingConfiguration.h" -#import "MGLNetworkConfiguration.h" -#import "MGLAttributedExpression.h" +#import "NSValue+MGLAdditions.h" +#import "MGLUserLocationAnnotationViewStyle.h" \ No newline at end of file diff --git a/platform/ios/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift b/platform/ios/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift index 172538c65b7..d581183c728 100644 --- a/platform/ios/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift +++ b/platform/ios/platform/ios/test/MGLMapViewDelegateIntegrationTests.swift @@ -100,4 +100,8 @@ extension MGLMapViewDelegateIntegrationTests: MGLMapViewDelegate { func mapView(_ mapView: MGLMapView, didFailToLoadImage imageName: String) -> UIImage? { return nil } func mapView(_ mapView: MGLMapView, shouldRemoveStyleImage imageName: String) -> Bool { return false } + + func mapView(_ mapView: MGLMapView, didChangeLocationManagerAuthorization manager: MGLLocationManager) {} + + func mapView(styleForDefaultUserLocationAnnotationView mapView: MGLMapView) -> MGLUserLocationAnnotationViewStyle { return MGLUserLocationAnnotationViewStyle() } } From 409ef553fa30d9aae8c906108711866edb58d7fa Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Mon, 22 Feb 2021 16:00:37 +0100 Subject: [PATCH 02/10] MGLSDKMetricsManager.h imported by accident. Added observable.hpp header. --- platform/ios/platform/ios/src/Mapbox.h | 1 - src/mbgl/util/observable.hpp | 67 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/mbgl/util/observable.hpp diff --git a/platform/ios/platform/ios/src/Mapbox.h b/platform/ios/platform/ios/src/Mapbox.h index 88e0486a8ac..333190cf6fc 100644 --- a/platform/ios/platform/ios/src/Mapbox.h +++ b/platform/ios/platform/ios/src/Mapbox.h @@ -56,7 +56,6 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLRasterDEMSource.h" #import "MGLRasterStyleLayer.h" #import "MGLRasterTileSource.h" -#import "MGLSDKMetricsManager.h" #import "MGLShape.h" #import "MGLShapeCollection.h" #import "MGLShapeOfflineRegion.h" diff --git a/src/mbgl/util/observable.hpp b/src/mbgl/util/observable.hpp new file mode 100644 index 00000000000..15af1000327 --- /dev/null +++ b/src/mbgl/util/observable.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace mbgl { + +class Observer; + +struct ObservableEvent { + explicit ObservableEvent(std::string type); + std::string type; + TimePoint begin; + TimePoint end; + mapbox::base::Value data; +}; + +class Observer { +public: + virtual ~Observer() = default; + + // Notifies Observer about an event + virtual void notify(const ObservableEvent&) = 0; + + // Id of an observer, must be unique. + // Default implementation uses `this` address of an instance. + virtual std::size_t id() const; +}; + +// Observable class implements basic Publish&Subscribe functionality +class Observable { +public: + Observable(); + virtual ~Observable(); + + // Subscribes `Observer` to recieve notifications of the event types provided in `eventTypes` + // `Observer::id()` would be used as an `id` for subscription. + virtual void subscribe(const std::shared_ptr&, const std::vector& eventTypes); + + // Unsubscribes perviosly subscribed `Observer` with an `id`, that is provided by `Observer::id()` + // Whenever an empty list of events is provided, observer would be unsubscribed from all events. + virtual void unsubscribeWithId(std::size_t id, const std::vector& eventTypes); + + // Must return true if `Observable` supports an `eventType`. + virtual bool supportsEventType(const std::string& eventType) const; + + // Shorthand for virtual method accepting `Observer` id. + void unsubscribe(const std::shared_ptr&, const std::vector& eventTypes); + void unsubscribe(const std::shared_ptr&); + +protected: + void dispatchEvent(const ObservableEvent&); + bool hasSubscribers() const; + +private: + struct Subscriber; + std::map> subscribers; + mutable std::mutex mutex; +}; + +} // namespace mbgl From bede290e9b1bd0d8b1fb15f950f8dfced08cac3d Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Mon, 22 Feb 2021 19:28:26 +0100 Subject: [PATCH 03/10] Removed Added `MGLObserver`, `MGLObservable` (pr 358). The implementation is partially in the core library which so it could not be cherry-picked. --- platform/ios/platform/darwin/src/MGLEvent.h | 41 ------- platform/ios/platform/darwin/src/MGLEvent.mm | 80 -------------- .../platform/darwin/src/MGLEvent_Private.h | 11 -- .../ios/platform/darwin/src/MGLObserver.h | 65 ----------- .../ios/platform/darwin/src/MGLObserver.mm | 101 ------------------ .../platform/darwin/src/MGLObserver_Private.h | 40 ------- platform/ios/platform/ios/CHANGELOG.md | 1 - .../ios/platform/ios/app/MBXViewController.m | 19 ---- .../ios/ios.xcodeproj/project.pbxproj | 36 ------- platform/ios/platform/ios/src/MGLMapView.h | 13 +-- platform/ios/platform/ios/src/MGLMapView.mm | 41 ------- platform/ios/platform/ios/src/Mapbox.h | 2 - src/mbgl/util/observable.hpp | 67 ------------ 13 files changed, 1 insertion(+), 516 deletions(-) delete mode 100644 platform/ios/platform/darwin/src/MGLEvent.h delete mode 100644 platform/ios/platform/darwin/src/MGLEvent.mm delete mode 100644 platform/ios/platform/darwin/src/MGLEvent_Private.h delete mode 100644 platform/ios/platform/darwin/src/MGLObserver.h delete mode 100644 platform/ios/platform/darwin/src/MGLObserver.mm delete mode 100644 platform/ios/platform/darwin/src/MGLObserver_Private.h delete mode 100644 src/mbgl/util/observable.hpp diff --git a/platform/ios/platform/darwin/src/MGLEvent.h b/platform/ios/platform/darwin/src/MGLEvent.h deleted file mode 100644 index be647c65df1..00000000000 --- a/platform/ios/platform/darwin/src/MGLEvent.h +++ /dev/null @@ -1,41 +0,0 @@ -#import "MGLFoundation.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - Type of event used when subscribing to and unsubscribing from an `MGLObservable`. - */ -typedef NSString *MGLEventType NS_TYPED_EXTENSIBLE_ENUM; - -// TODO: Doc -FOUNDATION_EXPORT MGL_EXPORT MGLEventType const MGLEventTypeResourceRequest; - - -/** - Generic Event used when notifying an `MGLObserver`. This is not intended nor - expected to be created by the application developer. It will be provided as - part of an `MGLObservable` notification. - */ -MGL_EXPORT -@interface MGLEvent: NSObject - -/// Type of an event. Matches an original event type used for a subscription. -@property (nonatomic, readonly, copy) MGLEventType type; - -/// Timestamp taken at the time of an event creation, relative to the Unix epoch. -@property (nonatomic, readonly) NSTimeInterval begin; - -/// Timestamp taken at the time of an event completion. For a non-interval -/// (single-shot) events, migth be equal to an event's `begin` timestamp. -/// Relative to the Unix epoch. -@property (nonatomic, readonly) NSTimeInterval end; - -/// Generic property for the event's data. Supported types are: `NSNumber` (int64, -/// uint64, bool, double), `NSString`, `NSArray`, `NSDictionary`. -@property (nonatomic, readonly, copy) id data; - -/// Test for equality. Note this compares all properties except `data`. -- (BOOL)isEqualToEvent:(MGLEvent *)otherEvent; -@end - -NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLEvent.mm b/platform/ios/platform/darwin/src/MGLEvent.mm deleted file mode 100644 index 21330a87a3a..00000000000 --- a/platform/ios/platform/darwin/src/MGLEvent.mm +++ /dev/null @@ -1,80 +0,0 @@ -#import "MGLEvent_Private.h" -#import "MGLStyleValue_Private.h" - -const MGLEventType MGLEventTypeResourceRequest = @"resource-request"; - -#pragma mark - Event - -@implementation MGLEvent - -- (instancetype)init { - [self doesNotRecognizeSelector:_cmd]; - return nil; -} - -- (instancetype)initWithEvent:(const mbgl::ObservableEvent&)event { - self = [super init]; - - if (!self) - return nil; - - // mbgl::ObservableEvent timestamps do not use the system_clock, i.e. they - // are not relative to the Unix epoch, so we'll need to offset appropriately - auto systemClockNow = std::chrono::system_clock::now(); - auto steadyClockNow = std::chrono::steady_clock::now(); - auto begin = std::chrono::time_point_cast(systemClockNow + - (event.begin - steadyClockNow)); - auto end = std::chrono::time_point_cast(systemClockNow + - (event.end - steadyClockNow)); - - auto beginTime = std::chrono::duration>(begin.time_since_epoch()).count(); - auto endTime = std::chrono::duration>(end.time_since_epoch()).count(); - - _type = (MGLEventType)[NSString stringWithUTF8String:event.type.c_str()]; - _begin = beginTime; - _end = endTime; - - // From value.md - // Supported types are `int`, `uint`, `bool`, `double`, `array`, `object` and `string`. - _data = MGLJSONObjectFromMBGLValue(event.data); - - return self; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p; type = %@, begin = %f, end = %f, data = %@>", - NSStringFromClass([self class]), (void *)self, - self.type, - self.begin, - self.end, - self.data]; -} - -#pragma mark - Equality - -- (NSUInteger)hash { - return self.type.hash ^ @(self.begin).hash ^ @(self.end).hash; -} - -- (BOOL)isEqualToEvent:(MGLEvent *)other { - if (self == other) - return YES; - - // Ignore the value at this moment. - return ((self.type == other.type) && - (self.begin == other.begin) && - (self.end == other.end)); -} - -- (BOOL)isEqual:(id)other { - if (self == other) - return YES; - - if (![other isKindOfClass:[MGLEvent class]]) { - return NO; - } - - return [self isEqualToEvent:(MGLEvent*)other]; -} - -@end \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLEvent_Private.h b/platform/ios/platform/darwin/src/MGLEvent_Private.h deleted file mode 100644 index ca2f88fdf28..00000000000 --- a/platform/ios/platform/darwin/src/MGLEvent_Private.h +++ /dev/null @@ -1,11 +0,0 @@ -#import -#import "MGLEvent.h" -#include - -NS_ASSUME_NONNULL_BEGIN - -@interface MGLEvent () -- (instancetype)initWithEvent:(const mbgl::ObservableEvent&)event; -@end - -NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLObserver.h b/platform/ios/platform/darwin/src/MGLObserver.h deleted file mode 100644 index b46829747b8..00000000000 --- a/platform/ios/platform/darwin/src/MGLObserver.h +++ /dev/null @@ -1,65 +0,0 @@ -#import "MGLFoundation.h" -#import "MGLEvent.h" - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - - -/** - Base class for observers used to receive notifications from an `MGLObservable`. - Subclasses should only override `-[MGLObserver notifyWithEvent:]`. - */ -MGL_EXPORT -@interface MGLObserver: NSObject - -/// A unique identifier that can be used to identify an observer. -@property (nonatomic, readonly) NSUInteger identifier; - -/// Primary notification method. -- (void)notifyWithEvent:(MGLEvent*)event; - -// TODO: document -- (BOOL)isEqualToObserver:(MGLObserver *)other; -@end - - -#pragma mark - - -/** - Protocol that yypes that wish to support subscriptions for events should conform - to. - */ -MGL_EXPORT -@protocol MGLObservable - -/** - Subscribes an `MGLObserver` to a provided set of event types. - `MGLObservable` will hold a strong reference to an `MGLObserver` instance, - therefore, in order to stop receiving notifications (and to avoid memory leaks), - the caller must call unsubscribe with the `MGLObserver` instance used for - the initial subscription. - - @param observer an MGLObserver - @param events a set of event types to subscribe to. - */ -- (void)subscribeForObserver:(nonnull MGLObserver *)observer - events:(nonnull NSSet *)events; - -/** - Unsubscribes an `MGLObserver` from a provided set of event types. - - @param observer an MGLObserver - @param events a set of event types to unsubscribe from. - */ -- (void)unsubscribeForObserver:(nonnull MGLObserver *)observer - events:(nonnull NSSet *)events; -/** - Unsubscribes an `MGLObserver` from all events (and release the strong reference). - - @param observer an MGLObserver - */ -- (void)unsubscribeForObserver:(nonnull MGLObserver *)observer; - -@end - -NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLObserver.mm b/platform/ios/platform/darwin/src/MGLObserver.mm deleted file mode 100644 index 54ae76ab558..00000000000 --- a/platform/ios/platform/darwin/src/MGLObserver.mm +++ /dev/null @@ -1,101 +0,0 @@ -#import "MGLObserver_Private.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLEvent_Private.h" - -#pragma mark - Native C++ peer object - -namespace mbgl { -namespace darwin { - -void Observer::notify(const ObservableEvent& event) { - - if (!observer) { - MGLLogWarning(@"Platform observer has been deallocated"); - return; - } - - [observer notifyWithEvent:[[MGLEvent alloc] initWithEvent:event]]; -} - -std::size_t Observer::id() const { - if (!observer) { - MGLLogWarning(@"Platform observer has been deallocated"); - return 0; - } - - return static_cast(observer.identifier); -} - -} -} - -#pragma mark - Cocoa observer - -@implementation MGLObserver -+ (NSUInteger)nextIdentifier { - static NSUInteger identifier; - return ++identifier; -} - -- (void)dealloc { - MGLAssert(!_observing, @"Ensure the observer is unsubscribed before deallocating"); -} - -- (instancetype)init { - self = [super init]; - - if (!self) return nil; - - _identifier = [MGLObserver nextIdentifier]; - _peer = std::make_shared(self); - - return self; -} - -- (void)notifyWithEvent:(MGLEvent*)event { - if (self.notificationHandler) { - self.notificationHandler(event); - } -} - -- (BOOL)isEqualToObserver:(MGLObserver *)other { - if (self == other) - return YES; - - if (self.identifier != other.identifier) - return NO; - - return (self.peer == other.peer); -} - -- (BOOL)isEqual:(id)other { - if (self == other) - return YES; - - if (![other isKindOfClass:[MGLObserver class]]) { - return NO; - } - - return [self isEqualToObserver:(MGLObserver*)other]; -} - -- (NSUInteger)hash { - // Rotate the address - NSUInteger peerHash = reinterpret_cast(self.peer.get()); - - NSUInteger width = (sizeof(NSUInteger) * __CHAR_BIT__); - NSUInteger shift = self.identifier % width; - - NSUInteger newHash = (peerHash << shift) | (peerHash >> (width - shift)); - return newHash; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p; identifier = %lu, peer = %p, hash = %lu>", - NSStringFromClass([self class]), (void *)self, - (unsigned long)self.identifier, - self.peer.get(), - (unsigned long)[self hash]]; -} - -@end \ No newline at end of file diff --git a/platform/ios/platform/darwin/src/MGLObserver_Private.h b/platform/ios/platform/darwin/src/MGLObserver_Private.h deleted file mode 100644 index 2fe8fcb6c3b..00000000000 --- a/platform/ios/platform/darwin/src/MGLObserver_Private.h +++ /dev/null @@ -1,40 +0,0 @@ -#import - -#import "MGLObserver.h" - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - Native C++ peer object - -namespace mbgl { -namespace darwin { - -class Observer : public mbgl::Observer { -public: - Observer(MGLObserver *observer_): observer(observer_) {} - virtual ~Observer() = default; - virtual void notify(const ObservableEvent& event); - virtual std::size_t id() const; - -protected: - - /// Cocoa observer that this adapter bridges to. - __weak MGLObserver *observer = nullptr; -}; - -} -} - -#pragma mark - -@interface MGLObserver () -@property (nonatomic, assign) std::shared_ptr peer; - -// TODO: Consider making public -@property (nonatomic, copy) void (^notificationHandler)(MGLEvent *); - -// Debug property used for development. -@property (nonatomic, assign) BOOL observing; -@end - -NS_ASSUME_NONNULL_END - diff --git a/platform/ios/platform/ios/CHANGELOG.md b/platform/ios/platform/ios/CHANGELOG.md index 114aa806790..358ece1f6f9 100644 --- a/platform/ios/platform/ios/CHANGELOG.md +++ b/platform/ios/platform/ios/CHANGELOG.md @@ -10,7 +10,6 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added `[MGLLocationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKeyproperty:]` to allow developers request just-in-time full-accuracy permissions. (cherry pick from [#361](https://github.com/mapbox/mapbox-gl-native-ios/pull/361)) * Added `[MGLLocationManagerDelegate locationManagerDidChangeAuthorization:]` to let `MGLMapView` know about privacy changes. (cherry pick from [#376](https://github.com/mapbox/mapbox-gl-native-ios/pull/376)) * Added `[MGLMapViewDelegate mapView:didChangeLocationManagerAuthorization:]` to allow developers adjust their apps to privacy settings changes. (cherry pick from [#376](https://github.com/mapbox/mapbox-gl-native-ios/pull/376)) -* Added `MGLObserver`, `MGLObservable` and `MGLEvent` to monitor events from the map view. (cherry pick from [#358](https://github.com/mapbox/mapbox-gl-native-ios/pull/358)) * Added an approximate user location halo when `MGLLocationManager.accuracyAuthorization` is set to `CLAccuracyAuthorizationReducedAccuracy`. (cherry pick from [#381](https://github.com/mapbox/mapbox-gl-native-ios/pull/381)) * The `MGLAccuracyAuthorizationDescription` as element of `NSLocationTemporaryUsageDescriptionDictionary` Info.plist key can now be set to describe why you request accuracy authorization. (cherry pick from [#392](https://github.com/mapbox/mapbox-gl-native-ios/pull/392)) * Added `[MGLMapViewDelegate mapViewStyleForDefaultUserLocationAnnotationView:]` and `MGLUserLocationAnnotationViewStyle` class to allow developers customize the default user location annotation view UI style. (cherry pick from [#403](https://github.com/mapbox/mapbox-gl-native-ios/pull/403)) diff --git a/platform/ios/platform/ios/app/MBXViewController.m b/platform/ios/platform/ios/app/MBXViewController.m index 1c8a7519d33..7fb8ee95572 100644 --- a/platform/ios/platform/ios/app/MBXViewController.m +++ b/platform/ios/platform/ios/app/MBXViewController.m @@ -192,15 +192,6 @@ @interface MBXSpriteBackedAnnotation : MGLPointAnnotation @implementation MBXSpriteBackedAnnotation @end -@interface MBXTestObserver: MGLObserver -@end - -@implementation MBXTestObserver -- (void)notifyWithEvent:(MGLEvent *)event { - NSLog(@"Received event: %@", event); -} -@end - @interface MBXViewController () *helperWindows; @property (nonatomic) NSMutableArray *contentInsetsOverlays; -@property (nonatomic) MBXTestObserver *testObserver; @property (nonatomic, copy) void (^locationBlock)(void); @end @@ -309,15 +299,6 @@ - (void)viewDidLoad } } }]; - - // TODO: Replace with menu implementation - self.testObserver = [[MBXTestObserver alloc] init]; - [self.mapView subscribeForObserver:self.testObserver event:MGLEventTypeResourceRequest]; - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self.mapView unsubscribeForObserver:self.testObserver]; - self.testObserver = nil; - }); } - (UIInterfaceOrientationMask)supportedInterfaceOrientations diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 3cb975a8b5b..57fbc837477 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -224,18 +224,6 @@ 40F887701D7A1E58008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40F887711D7A1E59008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; }; - 4BC5767B25E3C8AB006E06EB /* MGLObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767525E3C8AA006E06EB /* MGLObserver.h */; }; - 4BC5767C25E3C8AB006E06EB /* MGLObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767525E3C8AA006E06EB /* MGLObserver.h */; }; - 4BC5767D25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */; }; - 4BC5767E25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */; }; - 4BC5767F25E3C8AB006E06EB /* MGLEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */; }; - 4BC5768025E3C8AB006E06EB /* MGLEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */; }; - 4BC5768125E3C8AB006E06EB /* MGLObserver.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */; }; - 4BC5768225E3C8AB006E06EB /* MGLObserver.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */; }; - 4BC5768325E3C8AB006E06EB /* MGLEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767925E3C8AB006E06EB /* MGLEvent.h */; }; - 4BC5768425E3C8AB006E06EB /* MGLEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767925E3C8AB006E06EB /* MGLEvent.h */; }; - 4BC5768525E3C8AB006E06EB /* MGLObserver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */; }; - 4BC5768625E3C8AB006E06EB /* MGLObserver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */; }; 4BC5769325E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; }; 4BC5769425E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; }; 4BC5769525E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */; }; @@ -923,12 +911,6 @@ 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLShapeSource_Private.h; sourceTree = ""; }; 40FDA7691CCAAA6800442548 /* MBXAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBXAnnotationView.h; sourceTree = ""; }; 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXAnnotationView.m; sourceTree = ""; }; - 4BC5767525E3C8AA006E06EB /* MGLObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLObserver.h; sourceTree = ""; }; - 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLEvent_Private.h; sourceTree = ""; }; - 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLEvent.mm; sourceTree = ""; }; - 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLObserver.mm; sourceTree = ""; }; - 4BC5767925E3C8AB006E06EB /* MGLEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLEvent.h; sourceTree = ""; }; - 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLObserver_Private.h; sourceTree = ""; }; 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationAnnotationViewStyle.h; sourceTree = ""; }; 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLUserLocationAnnotationViewStyle.m; sourceTree = ""; }; 550570C422958FB300228ECF /* MGLMapView+Impl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MGLMapView+Impl.mm"; sourceTree = ""; }; @@ -1918,12 +1900,6 @@ 1F6A82A021360F9C00BA5B41 /* MGLLoggingConfiguration.h */, CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */, 1F6A82A62138871900BA5B41 /* MGLLoggingConfiguration_Private.h */, - 4BC5767625E3C8AB006E06EB /* MGLEvent_Private.h */, - 4BC5767925E3C8AB006E06EB /* MGLEvent.h */, - 4BC5767725E3C8AB006E06EB /* MGLEvent.mm */, - 4BC5767A25E3C8AB006E06EB /* MGLObserver_Private.h */, - 4BC5767525E3C8AA006E06EB /* MGLObserver.h */, - 4BC5767825E3C8AB006E06EB /* MGLObserver.mm */, ); name = Foundation; path = ../darwin/src; @@ -2214,7 +2190,6 @@ 357FE2DD1E02D2B20068B753 /* NSCoder+MGLAdditions.h in Headers */, 35D13AB71D3D15E300AFB4E0 /* MGLStyleLayer.h in Headers */, 07D947531F67488E00E37934 /* MGLComputedShapeSource_Private.h in Headers */, - 4BC5768325E3C8AB006E06EB /* MGLEvent.h in Headers */, 9654C1261FFC1AB900DB6A19 /* MGLPolyline_Private.h in Headers */, 40F887701D7A1E58008ECB67 /* MGLShapeSource_Private.h in Headers */, 350098DC1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.h in Headers */, @@ -2228,7 +2203,6 @@ 3510FFF01D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */, 74CB5EBF219B280400102936 /* MGLHeatmapStyleLayer_Private.h in Headers */, 1FC4817D2098CBC0000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */, - 4BC5767B25E3C8AB006E06EB /* MGLObserver.h in Headers */, 1F2B94C0221636D900210640 /* MGLNetworkConfiguration_Private.h in Headers */, 353AFA141D65AB17005A69F4 /* NSDate+MGLAdditions.h in Headers */, DA8848531CBAFB9800AB86E3 /* MGLCompactCalloutView.h in Headers */, @@ -2335,7 +2309,6 @@ DA72620B1DEEE3480043BB89 /* MGLOpenGLStyleLayer.h in Headers */, 404C26E71D89C55D000AA13D /* MGLTileSource_Private.h in Headers */, DA88485C1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.h in Headers */, - 4BC5767D25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */, 359F57461D2FDDA6005217F1 /* MGLUserLocationAnnotationView_Private.h in Headers */, 404C26E21D89B877000AA13D /* MGLTileSource.h in Headers */, DA8847FD1CBAFA5100AB86E3 /* MGLTilePyramidOfflineRegion.h in Headers */, @@ -2344,7 +2317,6 @@ 350098BB1D480108004B2AF0 /* MGLVectorTileSource.h in Headers */, DA8847F61CBAFA5100AB86E3 /* MGLOfflineStorage.h in Headers */, DAD1656E1CF41981001FF4B9 /* MGLFeature_Private.h in Headers */, - 4BC5768525E3C8AB006E06EB /* MGLObserver_Private.h in Headers */, DA88483C1CBAFB8500AB86E3 /* MGLMapView.h in Headers */, 3EA9363147E77DD29FA06063 /* MGLRendererConfiguration.h in Headers */, 550570C822958FB400228ECF /* MGLMapView+Impl.h in Headers */, @@ -2377,7 +2349,6 @@ 3566C7671D4A77BA008152BC /* MGLShapeSource.h in Headers */, DA35A29F1CC9E94C00E826B2 /* MGLCoordinateFormatter.h in Headers */, 967C864C210A9D3C004DF794 /* UIDevice+MGLAdditions.h in Headers */, - 4BC5768425E3C8AB006E06EB /* MGLEvent.h in Headers */, 404C26E31D89B877000AA13D /* MGLTileSource.h in Headers */, 96E516F6200059EC00A02306 /* MGLRendererFrontend.h in Headers */, 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */, @@ -2391,7 +2362,6 @@ 96E516EF2000594F00A02306 /* NSArray+MGLAdditions.h in Headers */, 96E516F12000596800A02306 /* NSString+MGLAdditions.h in Headers */, 35E0CFE71D3E501500188327 /* MGLStyle_Private.h in Headers */, - 4BC5767C25E3C8AB006E06EB /* MGLObserver.h in Headers */, CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */, DABFB86D1CBE9A0F00D62B32 /* MGLAnnotationImage.h in Headers */, DABFB8721CBE9A0F00D62B32 /* MGLUserLocation.h in Headers */, @@ -2498,7 +2468,6 @@ 96E516E82000560B00A02306 /* MGLAnnotationContainerView_Private.h in Headers */, 35D13AC41D3D19DD00AFB4E0 /* MGLFillStyleLayer.h in Headers */, DABFB86E1CBE9A0F00D62B32 /* MGLCalloutView.h in Headers */, - 4BC5767E25E3C8AB006E06EB /* MGLEvent_Private.h in Headers */, 96E516FC20005A4400A02306 /* MGLUserLocationHeadingIndicator.h in Headers */, 1F7454971ECD450D00021D39 /* MGLLight_Private.h in Headers */, DABFB8601CBE99E500D62B32 /* MGLMapCamera.h in Headers */, @@ -2507,7 +2476,6 @@ DABFB86A1CBE99E500D62B32 /* MGLStyle.h in Headers */, DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */, 96E516E12000551100A02306 /* MGLMultiPoint_Private.h in Headers */, - 4BC5768625E3C8AB006E06EB /* MGLObserver_Private.h in Headers */, 3EA934623AD0000B7D99C3FB /* MGLRendererConfiguration.h in Headers */, DACA86272019218600E9693A /* MGLRasterDEMSource.h in Headers */, 9621F2502091020E005B3800 /* NSExpression+MGLAdditions.h in Headers */, @@ -3097,7 +3065,6 @@ DA8848261CBAFA6200AB86E3 /* MGLPolygon.mm in Sources */, 35B82BFA1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */, 966FCF4E1F3A5C9200F2B6DE /* MGLUserLocationHeadingBeamLayer.m in Sources */, - 4BC5768125E3C8AB006E06EB /* MGLObserver.mm in Sources */, 8989B17E201A48EB0081CF59 /* MGLHeatmapStyleLayer.mm in Sources */, 353AFA161D65AB17005A69F4 /* NSDate+MGLAdditions.mm in Sources */, 1FCAE2A420B872A400C577DD /* MGLLocationManager.m in Sources */, @@ -3114,7 +3081,6 @@ DA8848271CBAFA6200AB86E3 /* MGLPolyline.mm in Sources */, 35CE61841D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */, 3EA93369F61CF70AFA50465D /* MGLRendererConfiguration.m in Sources */, - 4BC5767F25E3C8AB006E06EB /* MGLEvent.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3196,7 +3162,6 @@ 966FCF4F1F3A5C9200F2B6DE /* MGLUserLocationHeadingBeamLayer.m in Sources */, DAA4E4231CBB730400178DFB /* MGLPolygon.mm in Sources */, 8989B17F201A48EB0081CF59 /* MGLHeatmapStyleLayer.mm in Sources */, - 4BC5768225E3C8AB006E06EB /* MGLObserver.mm in Sources */, 353AFA171D65AB17005A69F4 /* NSDate+MGLAdditions.mm in Sources */, 35D13AC61D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm in Sources */, 1FCAE2A520B872A400C577DD /* MGLLocationManager.m in Sources */, @@ -3213,7 +3178,6 @@ 35CE61851D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */, DAA4E4241CBB730400178DFB /* MGLPolyline.mm in Sources */, 3EA9366247780E4F252652A8 /* MGLRendererConfiguration.m in Sources */, - 4BC5768025E3C8AB006E06EB /* MGLEvent.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/platform/ios/platform/ios/src/MGLMapView.h b/platform/ios/platform/ios/src/MGLMapView.h index a6c6ea3da17..d2a2fe6e733 100644 --- a/platform/ios/platform/ios/src/MGLMapView.h +++ b/platform/ios/platform/ios/src/MGLMapView.h @@ -6,7 +6,6 @@ #import "MGLMapCamera.h" #import "MGLTypes.h" #import "MGLStyle.h" -#import "MGLObserver.h" NS_ASSUME_NONNULL_BEGIN @@ -189,7 +188,7 @@ FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLUserLocationAnnotationTyp Simple map view example to learn how to initialize a basic `MGLMapView`. */ MGL_EXPORT -@interface MGLMapView : UIView +@interface MGLMapView : UIView #pragma mark Creating Instances @@ -2003,14 +2002,4 @@ MGL_EXPORT */ @property (nonatomic) MGLMapDebugMaskOptions debugMask; -/** - :nodoc: - Convenience method for subscribing to a single event. See `-[MGLObservable - subscribeForObserver:events:]`. - */ -- (void)subscribeForObserver:(nonnull MGLObserver *)observer - event:(nonnull MGLEventType)event; - -@end - NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/ios/src/MGLMapView.mm b/platform/ios/platform/ios/src/MGLMapView.mm index 8890b11fb97..60410b23998 100644 --- a/platform/ios/platform/ios/src/MGLMapView.mm +++ b/platform/ios/platform/ios/src/MGLMapView.mm @@ -67,8 +67,6 @@ #import "MGLLoggingConfiguration_Private.h" #import "MGLNetworkConfiguration_Private.h" #import "MGLReachability.h" -#import "MGLObserver_Private.h" -#import "MGLEvent_Private.h" #include #include @@ -279,8 +277,6 @@ @interface MGLMapView () *observerCache; - @end @implementation MGLMapView @@ -522,8 +518,6 @@ - (void)commonInit _selectedAnnotationTag = MGLAnnotationTagNotFound; _annotationsNearbyLastTap = {}; - _observerCache = [NSMutableSet set]; - // TODO: This warning should be removed when automaticallyAdjustsScrollViewInsets is removed from // the UIViewController api. static dispatch_once_t onceToken; @@ -6892,41 +6886,6 @@ - (void)prepareForInterfaceBuilder return _annotationViewReuseQueueByIdentifier[identifier]; } -#pragma mark - MGLObservable methods - - -static std::vector vectorOfStringsFromSet(NSSet *setOfStrings) { - __block std::vector strings; - strings.reserve(setOfStrings.count); - [setOfStrings enumerateObjectsUsingBlock:^(NSString * _Nonnull text, BOOL * _Nonnull stop) { - strings.push_back(text.UTF8String); - }]; - return strings; -} - -// Convenience method -- (void)subscribeForObserver:(nonnull MGLObserver *)observer event:(nonnull MGLEventType)event { - [self subscribeForObserver:observer events:[NSSet setWithObject:event]]; -} - -- (void)subscribeForObserver:(MGLObserver *)observer events:(nonnull NSSet *)events { - observer.observing = YES; - [self.observerCache addObject:observer]; - - auto eventTypes = vectorOfStringsFromSet(events); - self.mbglMap.subscribe(observer.peer, eventTypes); -} - -- (void)unsubscribeForObserver:(MGLObserver *)observer events:(nonnull NSSet *)events { - auto eventTypes = vectorOfStringsFromSet(events); - self.mbglMap.unsubscribe(observer.peer, eventTypes); -} - -- (void)unsubscribeForObserver:(MGLObserver *)observer { - self.mbglMap.unsubscribe(observer.peer); - [self.observerCache removeObject:observer]; - observer.observing = NO; -} - @end #pragma mark - IBAdditions methods diff --git a/platform/ios/platform/ios/src/Mapbox.h b/platform/ios/platform/ios/src/Mapbox.h index 333190cf6fc..c5d00ae2a17 100644 --- a/platform/ios/platform/ios/src/Mapbox.h +++ b/platform/ios/platform/ios/src/Mapbox.h @@ -23,7 +23,6 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLComputedShapeSource.h" #import "MGLCoordinateFormatter.h" #import "MGLDistanceFormatter.h" -#import "MGLEvent.h" #import "MGLFeature.h" #import "MGLFillExtrusionStyleLayer.h" #import "MGLFillStyleLayer.h" @@ -43,7 +42,6 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLMapView+IBAdditions.h" #import "MGLMultiPoint.h" #import "MGLNetworkConfiguration.h" -#import "MGLObserver.h" #import "MGLOfflinePack.h" #import "MGLOfflineRegion.h" #import "MGLOfflineStorage.h" diff --git a/src/mbgl/util/observable.hpp b/src/mbgl/util/observable.hpp deleted file mode 100644 index 15af1000327..00000000000 --- a/src/mbgl/util/observable.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace mbgl { - -class Observer; - -struct ObservableEvent { - explicit ObservableEvent(std::string type); - std::string type; - TimePoint begin; - TimePoint end; - mapbox::base::Value data; -}; - -class Observer { -public: - virtual ~Observer() = default; - - // Notifies Observer about an event - virtual void notify(const ObservableEvent&) = 0; - - // Id of an observer, must be unique. - // Default implementation uses `this` address of an instance. - virtual std::size_t id() const; -}; - -// Observable class implements basic Publish&Subscribe functionality -class Observable { -public: - Observable(); - virtual ~Observable(); - - // Subscribes `Observer` to recieve notifications of the event types provided in `eventTypes` - // `Observer::id()` would be used as an `id` for subscription. - virtual void subscribe(const std::shared_ptr&, const std::vector& eventTypes); - - // Unsubscribes perviosly subscribed `Observer` with an `id`, that is provided by `Observer::id()` - // Whenever an empty list of events is provided, observer would be unsubscribed from all events. - virtual void unsubscribeWithId(std::size_t id, const std::vector& eventTypes); - - // Must return true if `Observable` supports an `eventType`. - virtual bool supportsEventType(const std::string& eventType) const; - - // Shorthand for virtual method accepting `Observer` id. - void unsubscribe(const std::shared_ptr&, const std::vector& eventTypes); - void unsubscribe(const std::shared_ptr&); - -protected: - void dispatchEvent(const ObservableEvent&); - bool hasSubscribers() const; - -private: - struct Subscriber; - std::map> subscribers; - mutable std::mutex mutex; -}; - -} // namespace mbgl From c47b6176b3828e363c067bccc4824e8470122ec6 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Mon, 22 Feb 2021 23:08:50 +0100 Subject: [PATCH 04/10] Just a few bug fixes --- .../ios/ios.xcodeproj/project.pbxproj | 12 ++-- ...=> MGLFaux3DUserLocationAnnotationView.mm} | 71 ++++++++++--------- platform/ios/platform/ios/src/MGLMapView.h | 2 + platform/ios/platform/ios/src/MGLMapView.mm | 5 ++ .../ios/platform/ios/src/MGLMapView_Private.h | 2 + 5 files changed, 52 insertions(+), 40 deletions(-) rename platform/ios/platform/ios/src/{MGLFaux3DUserLocationAnnotationView.m => MGLFaux3DUserLocationAnnotationView.mm} (97%) diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 57fbc837477..590bc0fe95c 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -228,6 +228,8 @@ 4BC5769425E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; }; 4BC5769525E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */; }; 4BC5769625E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */; }; + 4BC576C925E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC576C825E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm */; }; + 4BC576CA25E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC576C825E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm */; }; 550570C622958FB400228ECF /* MGLMapView+Impl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 550570C422958FB300228ECF /* MGLMapView+Impl.mm */; }; 550570C722958FB400228ECF /* MGLMapView+Impl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 550570C422958FB300228ECF /* MGLMapView+Impl.mm */; }; 550570C822958FB400228ECF /* MGLMapView+Impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 550570C522958FB400228ECF /* MGLMapView+Impl.h */; }; @@ -534,7 +536,6 @@ DA88485A1CBAFB9800AB86E3 /* MGLUserLocation_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DA88484B1CBAFB9800AB86E3 /* MGLUserLocation_Private.h */; }; DA88485B1CBAFB9800AB86E3 /* MGLUserLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88484C1CBAFB9800AB86E3 /* MGLUserLocation.m */; }; DA88485C1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = DA88484D1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.h */; }; - DA88485D1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88484E1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.m */; }; DA8848601CBAFC2E00AB86E3 /* Mapbox.h in Headers */ = {isa = PBXBuildFile; fileRef = DA88485E1CBAFC2E00AB86E3 /* Mapbox.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA88488B1CBB037E00AB86E3 /* SMCalloutView.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8848891CBB037E00AB86E3 /* SMCalloutView.h */; }; DA88488C1CBB037E00AB86E3 /* SMCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88488A1CBB037E00AB86E3 /* SMCalloutView.m */; }; @@ -572,7 +573,6 @@ DAA4E42F1CBB730400178DFB /* MGLCompactCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8848451CBAFB9800AB86E3 /* MGLCompactCalloutView.m */; }; DAA4E4321CBB730400178DFB /* MGLMapView.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA88484A1CBAFB9800AB86E3 /* MGLMapView.mm */; }; DAA4E4331CBB730400178DFB /* MGLUserLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88484C1CBAFB9800AB86E3 /* MGLUserLocation.m */; }; - DAA4E4341CBB730400178DFB /* MGLFaux3DUserLocationAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88484E1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.m */; }; DAA4E4351CBB730400178DFB /* SMCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88488A1CBB037E00AB86E3 /* SMCalloutView.m */; }; DAAF722B1DA903C700312FA4 /* MGLStyleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = DAAF72291DA903C700312FA4 /* MGLStyleValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; DAAF722C1DA903C700312FA4 /* MGLStyleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = DAAF72291DA903C700312FA4 /* MGLStyleValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -913,6 +913,7 @@ 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXAnnotationView.m; sourceTree = ""; }; 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationAnnotationViewStyle.h; sourceTree = ""; }; 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLUserLocationAnnotationViewStyle.m; sourceTree = ""; }; + 4BC576C825E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFaux3DUserLocationAnnotationView.mm; sourceTree = ""; }; 550570C422958FB300228ECF /* MGLMapView+Impl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MGLMapView+Impl.mm"; sourceTree = ""; }; 550570C522958FB400228ECF /* MGLMapView+Impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MGLMapView+Impl.h"; sourceTree = ""; }; 554180411D2E97DE00012372 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; @@ -1190,7 +1191,6 @@ DA88484B1CBAFB9800AB86E3 /* MGLUserLocation_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUserLocation_Private.h; sourceTree = ""; }; DA88484C1CBAFB9800AB86E3 /* MGLUserLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLUserLocation.m; sourceTree = ""; }; DA88484D1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFaux3DUserLocationAnnotationView.h; sourceTree = ""; }; - DA88484E1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLFaux3DUserLocationAnnotationView.m; sourceTree = ""; }; DA88485E1CBAFC2E00AB86E3 /* Mapbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mapbox.h; path = src/Mapbox.h; sourceTree = SOURCE_ROOT; }; DA8848891CBB037E00AB86E3 /* SMCalloutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SMCalloutView.h; sourceTree = ""; }; DA88488A1CBB037E00AB86E3 /* SMCalloutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SMCalloutView.m; sourceTree = ""; }; @@ -2132,6 +2132,7 @@ DAD165841CF4D06B001FF4B9 /* Annotations */ = { isa = PBXGroup; children = ( + 4BC576C825E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm */, 404326881D5B9B1A007111BD /* MGLAnnotationContainerView_Private.h */, 40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */, 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */, @@ -2145,7 +2146,6 @@ DA8848441CBAFB9800AB86E3 /* MGLCompactCalloutView.h */, DA8848451CBAFB9800AB86E3 /* MGLCompactCalloutView.m */, DA88484D1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.h */, - DA88484E1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.m */, DA88484B1CBAFB9800AB86E3 /* MGLUserLocation_Private.h */, DA8848391CBAFB8500AB86E3 /* MGLUserLocation.h */, DA88484C1CBAFB9800AB86E3 /* MGLUserLocation.m */, @@ -2995,7 +2995,6 @@ 3510FFEC1D6D9C7A00F413B2 /* NSComparisonPredicate+MGLAdditions.mm in Sources */, DAED38651D62D0FC00D7640F /* NSURL+MGLAdditions.m in Sources */, 354B83981D2E873E005D9406 /* MGLUserLocationAnnotationView.m in Sources */, - DA88485D1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.m in Sources */, DAD165701CF41981001FF4B9 /* MGLFeature.mm in Sources */, 30E578191DAA855E0050F07E /* UIImage+MGLAdditions.mm in Sources */, 550570C622958FB400228ECF /* MGLMapView+Impl.mm in Sources */, @@ -3043,6 +3042,7 @@ 35D13AB91D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, 74CB5EB3219B252C00102936 /* MGLStyleLayerManager.mm in Sources */, DA35A2CB1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */, + 4BC576C925E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm in Sources */, 071BBB001EE7613F001FB02A /* MGLImageSource.mm in Sources */, DA8848321CBAFA6200AB86E3 /* NSString+MGLAdditions.m in Sources */, 408AA8581DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */, @@ -3139,6 +3139,7 @@ DA35A2CC1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */, 408AA8591DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */, 74CB5EB4219B252C00102936 /* MGLStyleLayerManager.mm in Sources */, + 4BC576CA25E443CE006E06EB /* MGLFaux3DUserLocationAnnotationView.mm in Sources */, DAA4E4281CBB730400178DFB /* MGLTypes.m in Sources */, DA35A2A21CC9E95F00E826B2 /* MGLCoordinateFormatter.m in Sources */, 357FE2E01E02D2B20068B753 /* NSCoder+MGLAdditions.mm in Sources */, @@ -3156,7 +3157,6 @@ 355AE0021E9281DA00F3939D /* MGLScaleBar.mm in Sources */, 4018B1C81CDC287F00F666AF /* MGLAnnotationView.mm in Sources */, 07D8C6FB1F67560100381808 /* MGLComputedShapeSource.mm in Sources */, - DAA4E4341CBB730400178DFB /* MGLFaux3DUserLocationAnnotationView.m in Sources */, DACA86292019218600E9693A /* MGLRasterDEMSource.mm in Sources */, 35B82BFB1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */, 966FCF4F1F3A5C9200F2B6DE /* MGLUserLocationHeadingBeamLayer.m in Sources */, diff --git a/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m b/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.mm similarity index 97% rename from platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m rename to platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.mm index fc77c659dcd..8a68fb5bc30 100644 --- a/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m +++ b/platform/ios/platform/ios/src/MGLFaux3DUserLocationAnnotationView.mm @@ -1,6 +1,6 @@ #import "MGLFaux3DUserLocationAnnotationView.h" -#import "MGLMapView.h" +#import "MGLMapView_Private.h" #import "MGLMapViewDelegate.h" #import "MGLUserLocation.h" #import "MGLUserLocationHeadingIndicator.h" @@ -32,7 +32,7 @@ @implementation MGLFaux3DUserLocationAnnotationView CALayer *_dotBorderLayer; CALayer *_dotLayer; CALayer *_haloLayer; - + CALayer *_approximateLayer; CLLocationDirection _oldHeadingAccuracy; @@ -72,6 +72,8 @@ - (void)update } } + + } - (void)drawPreciseLocationPuck { @@ -86,7 +88,6 @@ - (void)drawPreciseLocationPuck { _haloLayer.hidden = ! CLLocationCoordinate2DIsValid(self.mapView.userLocation.coordinate) || self.mapView.userLocation.location.horizontalAccuracy > 10; } - - (void)setTintColor:(UIColor *)tintColor { UIColor *puckArrowFillColor = tintColor; @@ -129,6 +130,7 @@ - (void)setTintColor:(UIColor *)tintColor _dotLayer.backgroundColor = [dotFillColor CGColor]; [_headingIndicatorLayer updateTintColor:[headingFillColor CGColor]]; } + } - (void)updatePitch @@ -202,12 +204,12 @@ - (void)drawPuck [self updateFrameWithSize:MGLUserLocationAnnotationPuckSize]; } - + UIColor *arrowColor = self.mapView.tintColor; UIColor *puckShadowColor = UIColor.blackColor; CGFloat shadowOpacity = 0.25; - + if ([self.mapView.delegate respondsToSelector:@selector(mapViewStyleForDefaultUserLocationAnnotationView:)]) { MGLUserLocationAnnotationViewStyle *style = [self.mapView.delegate mapViewStyleForDefaultUserLocationAnnotationView:self.mapView]; arrowColor = style.puckArrowFillColor ? style.puckArrowFillColor : arrowColor; @@ -296,13 +298,13 @@ - (void)drawDot [self updateFrameWithSize:MGLUserLocationAnnotationDotSize]; } - - + UIColor *haloColor = self.mapView.tintColor; UIColor *puckBackgroundColor = self.mapView.tintColor; UIColor *puckShadowColor = UIColor.blackColor; CGFloat shadowOpacity = 0.25; + if ([self.mapView.delegate respondsToSelector:@selector(mapViewStyleForDefaultUserLocationAnnotationView:)]) { MGLUserLocationAnnotationViewStyle *style = [self.mapView.delegate mapViewStyleForDefaultUserLocationAnnotationView:self.mapView]; haloColor = style.haloFillColor ? style.haloFillColor : haloColor; @@ -379,7 +381,7 @@ - (void)drawDot // if (_accuracyRingLayer && (_oldZoom != self.mapView.zoomLevel || _oldHorizontalAccuracy != self.userLocation.location.horizontalAccuracy)) { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; + CGFloat accuracyRingSize = [self calculateAccuracyRingSize: self.mapView.zoomLevel]; // only show the accuracy ring if it won't be obscured by the location dot if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15) @@ -421,7 +423,7 @@ - (void)drawDot // if ( ! _accuracyRingLayer && self.userLocation.location.horizontalAccuracy) { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; + CGFloat accuracyRingSize = [self calculateAccuracyRingSize: self.mapView.zoomLevel]; _accuracyRingLayer = [self circleLayerWithSize:accuracyRingSize]; _accuracyRingLayer.backgroundColor = [self.mapView.tintColor CGColor]; _accuracyRingLayer.opacity = 0.1; @@ -518,10 +520,12 @@ - (void)drawDot [self updateFaux3DEffect]; } + } - (void)drawApproximate { + if ( ! _approximateModeActivated) { self.layer.sublayers = nil; @@ -533,15 +537,15 @@ - (void)drawApproximate _haloLayer = nil; _puckDot = nil; _puckArrow = nil; - + _approximateModeActivated = YES; } - + UIColor *backgroundColor = self.mapView.tintColor; UIColor *strokeColor = UIColor.blackColor; CGFloat borderSize = 2.0; CGFloat opacity = 0.25; - + if ([self.mapView.delegate respondsToSelector:@selector(mapViewStyleForDefaultUserLocationAnnotationView:)]) { MGLUserLocationAnnotationViewStyle *style = [self.mapView.delegate mapViewStyleForDefaultUserLocationAnnotationView:self.mapView]; if (@available(iOS 14, *)) { @@ -552,17 +556,31 @@ - (void)drawApproximate } } + // approximate ring + if ( ! _approximateLayer && self.userLocation.location.horizontalAccuracy) + { + CGFloat accuracyRingSize = [self calculateAccuracyRingSize: MAX(self.mapView.zoomLevel, MGLUserLocationApproximateZoomThreshold)]; + _approximateLayer = [self circleLayerWithSize:accuracyRingSize]; + _approximateLayer.backgroundColor = [backgroundColor CGColor]; + _approximateLayer.opacity = opacity; + _approximateLayer.shouldRasterize = NO; + _approximateLayer.allowsGroupOpacity = NO; + _approximateLayer.borderWidth = borderSize; + _approximateLayer.borderColor = [strokeColor CGColor]; + + [self.layer addSublayer:_approximateLayer]; + } + // update approximate ring (if zoom or horizontal accuracy have changed) if (_approximateLayer && (_oldZoom != self.mapView.zoomLevel || _oldHorizontalAccuracy != self.userLocation.location.horizontalAccuracy)) { - CGFloat borderWidth = 2; if (self.mapView.zoomLevel < MGLUserLocationApproximateZoomThreshold) { - borderSize = 3; + borderSize = 1.0; } _approximateLayer.borderWidth = borderSize; - + if (self.mapView.zoomLevel >= MGLUserLocationApproximateZoomThreshold) { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; + CGFloat accuracyRingSize = [self calculateAccuracyRingSize: self.mapView.zoomLevel]; _approximateLayer.hidden = NO; @@ -577,26 +595,11 @@ - (void)drawApproximate [CATransaction commit]; } - + // store accuracy and zoom so we're not redrawing unchanged location updates _oldHorizontalAccuracy = self.userLocation.location.horizontalAccuracy; _oldZoom = self.mapView.zoomLevel; } - - // approximate ring - if ( ! _approximateLayer && self.userLocation.location.horizontalAccuracy) - { - CGFloat accuracyRingSize = [self calculateAccuracyRingSize]; - _approximateLayer = [self circleLayerWithSize:accuracyRingSize]; - approximateLayer.backgroundColor = [backgroundColor CGColor]; - _approximateLayer.opacity = opacity; - _approximateLayer.shouldRasterize = NO; - _approximateLayer.allowsGroupOpacity = NO; - _approximateLayer.borderWidth = borderSize; - _approximateLayer.borderColor = [strokeColor CGColor]; - - [self.layer addSublayer:_approximateLayer]; - } } - (CALayer *)circleLayerWithSize:(CGFloat)layerSize @@ -625,10 +628,10 @@ - (CAAnimationGroup *)loopingAnimationGroupWithDuration:(CGFloat)animationDurati return animationGroup; } -- (CGFloat)calculateAccuracyRingSize +- (CGFloat)calculateAccuracyRingSize:(double)zoomLevel { // diameter in screen points - return round(self.userLocation.location.horizontalAccuracy / [self.mapView metersPerPointAtLatitude:self.userLocation.coordinate.latitude] * 2.0); + return round(self.userLocation.location.horizontalAccuracy / [self.mapView metersPerPointAtLatitude:self.userLocation.coordinate.latitude zoomLevel:zoomLevel] * 2.0); } @end diff --git a/platform/ios/platform/ios/src/MGLMapView.h b/platform/ios/platform/ios/src/MGLMapView.h index d2a2fe6e733..f2eb51dd13d 100644 --- a/platform/ios/platform/ios/src/MGLMapView.h +++ b/platform/ios/platform/ios/src/MGLMapView.h @@ -2002,4 +2002,6 @@ MGL_EXPORT */ @property (nonatomic) MGLMapDebugMaskOptions debugMask; +@end + NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/ios/src/MGLMapView.mm b/platform/ios/platform/ios/src/MGLMapView.mm index 60410b23998..c17ba1bec91 100644 --- a/platform/ios/platform/ios/src/MGLMapView.mm +++ b/platform/ios/platform/ios/src/MGLMapView.mm @@ -4056,6 +4056,11 @@ - (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude return mbgl::Projection::getMetersPerPixelAtLatitude(latitude, self.zoomLevel); } +- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude zoomLevel:(double)zoomLevel +{ + return mbgl::Projection::getMetersPerPixelAtLatitude(latitude, zoomLevel); +} + #pragma mark - Camera Change Reason - - (void)resetCameraChangeReason diff --git a/platform/ios/platform/ios/src/MGLMapView_Private.h b/platform/ios/platform/ios/src/MGLMapView_Private.h index 155527000f2..bb34644f2ab 100644 --- a/platform/ios/platform/ios/src/MGLMapView_Private.h +++ b/platform/ios/platform/ios/src/MGLMapView_Private.h @@ -46,6 +46,8 @@ FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const _Nonnull MGLUnderlyingMapUna - (void)didFailToLoadImage:(nonnull NSString *)imageName; - (BOOL)shouldRemoveStyleImage:(nonnull NSString *)imageName; +- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude zoomLevel:(double)zoomLevel; + /** Triggers another render pass even when it is not necessary. */ - (void)setNeedsRerender; From 3fd414d3b60c2e43a348c150264154cac5670e62 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Mon, 22 Feb 2021 23:30:09 +0100 Subject: [PATCH 05/10] Missing public header and syntax error fix --- platform/ios/platform/ios/app/MBXViewController.m | 1 - platform/ios/platform/ios/ios.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/ios/platform/ios/app/MBXViewController.m b/platform/ios/platform/ios/app/MBXViewController.m index 7fb8ee95572..42cc1fa7bcd 100644 --- a/platform/ios/platform/ios/app/MBXViewController.m +++ b/platform/ios/platform/ios/app/MBXViewController.m @@ -2358,7 +2358,6 @@ - (void)alertAccuracyChanges { }]; UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Keep Precise Location Off" style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { handler:nil]; [alert addAction:settingsAction]; diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 590bc0fe95c..2755f960883 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -224,7 +224,7 @@ 40F887701D7A1E58008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40F887711D7A1E59008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; }; - 4BC5769325E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; }; + 4BC5769325E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC5769425E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC5769125E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h */; }; 4BC5769525E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */; }; 4BC5769625E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5769225E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.m */; }; @@ -2168,6 +2168,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 4BC5769325E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */, 556660DB1E1D8E8D00E2C41B /* MGLFoundation.h in Headers */, 92FC0AEA207CEE16007B6B54 /* MGLShapeOfflineRegion.h in Headers */, 35D13AC31D3D19DD00AFB4E0 /* MGLFillStyleLayer.h in Headers */, @@ -2247,7 +2248,6 @@ CAFB3C14234505D500399265 /* MGLMapSnapshotter_Private.h in Headers */, 1FCAE2A220B872A400C577DD /* MGLLocationManager.h in Headers */, DACA86262019218600E9693A /* MGLRasterDEMSource.h in Headers */, - 4BC5769325E3D3D6006E06EB /* MGLUserLocationAnnotationViewStyle.h in Headers */, 353933F81D3FB79F003F57D7 /* MGLLineStyleLayer.h in Headers */, 92F2C3ED1F0E3C3A00268EC0 /* MGLRendererFrontend.h in Headers */, DAAF722D1DA903C700312FA4 /* MGLStyleValue_Private.h in Headers */, From ca2b28686d499a957211a22c0ff6291c861715e6 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Mon, 22 Feb 2021 23:51:47 +0100 Subject: [PATCH 06/10] TestApp - bundle identifier update to MapLibre --- platform/ios/platform/ios/app/Info.plist | 38 +++++++++---------- .../ios/ios.xcodeproj/project.pbxproj | 21 ++++++---- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/platform/ios/platform/ios/app/Info.plist b/platform/ios/platform/ios/app/Info.plist index b349ea331d7..d96b11827e6 100644 --- a/platform/ios/platform/ios/app/Info.plist +++ b/platform/ios/platform/ios/app/Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.mapbox.MapboxGL + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,19 +24,30 @@ 15256 LSRequiresIPhoneOS - NSLocationTemporaryUsageDescriptionDictionary - - MGLAccuracyAuthorizationDescription - MapLibre requires your precise location to help you navigate the map. - NSHumanReadableCopyright © 2014–2019 Mapbox + NSLocationAlwaysAndWhenInUseUsageDescription + The map will display your location. If you choose Always, the map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products. NSLocationAlwaysUsageDescription The map will display your location. The map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products. + NSLocationTemporaryUsageDescriptionDictionary + + MGLAccuracyAuthorizationDescription + MapLibre requires your precise location to help you navigate the map. + NSLocationWhenInUseUsageDescription The map will display your location. - NSLocationAlwaysAndWhenInUseUsageDescription - The map will display your location. If you choose Always, the map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products. + UIApplicationShortcutItems + + + UIApplicationShortcutItemIconFile + settings + UIApplicationShortcutItemTitle + Settings + UIApplicationShortcutItemType + $(PRODUCT_BUNDLE_IDENTIFIER).settings + + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -58,16 +69,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - UIApplicationShortcutItems - - - UIApplicationShortcutItemTitle - Settings - UIApplicationShortcutItemType - $(PRODUCT_BUNDLE_IDENTIFIER).settings - UIApplicationShortcutItemIconFile - settings - - diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 2755f960883..ddb9cb5920d 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -2655,8 +2655,9 @@ }; DA1DC9491CB6C1C2006E619F = { CreatedOnToolsVersion = 7.3; - DevelopmentTeam = GJZR2MEM28; + DevelopmentTeam = KBDAWM7T4E; LastSwiftMigration = 0820; + ProvisioningStyle = Manual; }; DA2E88501CC036F400F24E7B = { CreatedOnToolsVersion = 7.3; @@ -3528,11 +3529,13 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; - DEVELOPMENT_TEAM = GJZR2MEM28; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = KBDAWM7T4E; INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.maplibregl; PRODUCT_NAME = "Mapbox GL"; + PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL TestApp Development"; }; name = RelWithDebInfo; }; @@ -3770,11 +3773,13 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; - DEVELOPMENT_TEAM = GJZR2MEM28; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = KBDAWM7T4E; INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.maplibregl; PRODUCT_NAME = "Mapbox GL"; + PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL TestApp Development"; }; name = Debug; }; @@ -3785,11 +3790,13 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; - DEVELOPMENT_TEAM = GJZR2MEM28; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = KBDAWM7T4E; INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.maplibregl; PRODUCT_NAME = "Mapbox GL"; + PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL TestApp Development"; }; name = Release; }; From 271da1429afcbb56db7ebe41fbca4f83d0578a5d Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Tue, 23 Feb 2021 00:09:12 +0100 Subject: [PATCH 07/10] Fixing test target in xcode project --- platform/ios/platform/ios/ios.xcodeproj/project.pbxproj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index ddb9cb5920d..596249b1a76 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -2661,6 +2661,7 @@ }; DA2E88501CC036F400F24E7B = { CreatedOnToolsVersion = 7.3; + DevelopmentTeam = V6F7X5J9Y7; LastSwiftMigration = 1010; }; DA8847D11CBAF91600AB86E3 = { @@ -3644,6 +3645,8 @@ baseConfigurationReference = CAE5AE2B2389FBF000E4A5A1 /* ios.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + DEVELOPMENT_TEAM = V6F7X5J9Y7; INFOPLIST_FILE = test/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_CFLAGS = "-fvisibility=hidden"; @@ -3805,6 +3808,8 @@ baseConfigurationReference = CAE5AE2B2389FBF000E4A5A1 /* ios.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + DEVELOPMENT_TEAM = V6F7X5J9Y7; INFOPLIST_FILE = test/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_CFLAGS = "-fvisibility=hidden"; @@ -3832,6 +3837,8 @@ baseConfigurationReference = CAE5AE2B2389FBF000E4A5A1 /* ios.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + DEVELOPMENT_TEAM = V6F7X5J9Y7; INFOPLIST_FILE = test/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_CFLAGS = "-fvisibility=hidden"; From 8aff171fbfb06b62b10606c97f077d0ee6b10865 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Tue, 23 Feb 2021 11:15:59 +0100 Subject: [PATCH 08/10] Removing redundant return statement. --- platform/ios/platform/darwin/src/MGLLocationManager.m | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/ios/platform/darwin/src/MGLLocationManager.m b/platform/ios/platform/darwin/src/MGLLocationManager.m index cdee3777356..5729f26b3ab 100644 --- a/platform/ios/platform/darwin/src/MGLLocationManager.m +++ b/platform/ios/platform/darwin/src/MGLLocationManager.m @@ -46,7 +46,6 @@ - (CLAuthorizationStatus)authorizationStatus { } #else return [CLLocationManager authorizationStatus]; - return [CLLocationManager authorizationStatus]; #endif } From cd3797bcd5bb4a317446862fa088a75f512dffa5 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Tue, 23 Feb 2021 11:21:43 +0100 Subject: [PATCH 09/10] Alert text updates. --- platform/ios/platform/ios/app/Info.plist | 4 ++-- platform/ios/platform/ios/app/MBXViewController.m | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/ios/platform/ios/app/Info.plist b/platform/ios/platform/ios/app/Info.plist index d96b11827e6..5bcd3b34bc0 100644 --- a/platform/ios/platform/ios/app/Info.plist +++ b/platform/ios/platform/ios/app/Info.plist @@ -27,9 +27,9 @@ NSHumanReadableCopyright © 2014–2019 Mapbox NSLocationAlwaysAndWhenInUseUsageDescription - The map will display your location. If you choose Always, the map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products. + The map will display your location. If you choose Always, the map may also use your location when it isn’t visible in order to improve OpenStreetMap. NSLocationAlwaysUsageDescription - The map will display your location. The map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products. + The map will display your location. The map may also use your location when it isn’t visible in order to improve OpenStreetMap. NSLocationTemporaryUsageDescriptionDictionary MGLAccuracyAuthorizationDescription diff --git a/platform/ios/platform/ios/app/MBXViewController.m b/platform/ios/platform/ios/app/MBXViewController.m index 42cc1fa7bcd..678736a4de1 100644 --- a/platform/ios/platform/ios/app/MBXViewController.m +++ b/platform/ios/platform/ios/app/MBXViewController.m @@ -2349,7 +2349,7 @@ - (void)mapView:(nonnull MGLMapView *)mapView didChangeLocationManagerAuthorizat } - (void)alertAccuracyChanges { - UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Mapbox GL works best with your precise location." + UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"MapLibre works best with your precise location." message:@"You'll get turn-by-turn directions." preferredStyle:UIAlertControllerStyleAlert]; From 514416c4c0e4133cb4db2c773b9f69b71d70e4c1 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Tue, 23 Feb 2021 13:47:12 +0100 Subject: [PATCH 10/10] Fixing benchmark app --- .../ios/platform/ios/benchmark/Info.plist | 6 +-- .../ios/benchmark/MBXBenchViewController.h | 1 + .../ios/benchmark/MBXBenchViewController.mm | 1 + .../ios/ios.xcodeproj/project.pbxproj | 48 ++++++++++++++----- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/platform/ios/platform/ios/benchmark/Info.plist b/platform/ios/platform/ios/benchmark/Info.plist index 1e877990422..0891d4a592a 100644 --- a/platform/ios/platform/ios/benchmark/Info.plist +++ b/platform/ios/platform/ios/benchmark/Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.mapbox.GL.benchmark + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,6 +24,8 @@ 15256 LSRequiresIPhoneOS + MGLMapboxMetricsEnabledSettingShownInApp + NSHumanReadableCopyright © 2015–2019 Mapbox UIApplicationExitsOnSuspend @@ -47,7 +49,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - MGLMapboxMetricsEnabledSettingShownInApp - diff --git a/platform/ios/platform/ios/benchmark/MBXBenchViewController.h b/platform/ios/platform/ios/benchmark/MBXBenchViewController.h index c4439be5ece..c93e28d6a07 100644 --- a/platform/ios/platform/ios/benchmark/MBXBenchViewController.h +++ b/platform/ios/platform/ios/benchmark/MBXBenchViewController.h @@ -1,4 +1,5 @@ #import +#import @interface MBXBenchViewController : UIViewController diff --git a/platform/ios/platform/ios/benchmark/MBXBenchViewController.mm b/platform/ios/platform/ios/benchmark/MBXBenchViewController.mm index 901eb07cd12..9bd47f7bad4 100644 --- a/platform/ios/platform/ios/benchmark/MBXBenchViewController.mm +++ b/platform/ios/platform/ios/benchmark/MBXBenchViewController.mm @@ -1,6 +1,7 @@ #import "MBXBenchViewController.h" #import "MBXBenchAppDelegate.h" #import "MGLMapView_Private.h" +#import "MGLMapViewDelegate.h" #include "locations.hpp" diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 596249b1a76..5da4776e426 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -1045,7 +1045,7 @@ DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMapView_Private.h; sourceTree = ""; }; DA1AC01B1E5B8774006DF1D6 /* lt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = lt; path = lt.lproj/Localizable.strings; sourceTree = ""; }; DA1AC0201E5B8917006DF1D6 /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = uk; path = uk.lproj/Foundation.stringsdict; sourceTree = ""; }; - DA1DC94A1CB6C1C2006E619F /* Mapbox GL.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mapbox GL.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + DA1DC94A1CB6C1C2006E619F /* MapLibre GL.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MapLibre GL.app"; sourceTree = BUILT_PRODUCTS_DIR; }; DA1DC9501CB6C1C2006E619F /* MBXAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXAppDelegate.h; sourceTree = ""; }; DA1DC9531CB6C1C2006E619F /* MBXViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXViewController.h; sourceTree = ""; }; DA1DC95E1CB6C1C2006E619F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -1704,7 +1704,7 @@ DA1DC94B1CB6C1C2006E619F /* Products */ = { isa = PBXGroup; children = ( - DA1DC94A1CB6C1C2006E619F /* Mapbox GL.app */, + DA1DC94A1CB6C1C2006E619F /* MapLibre GL.app */, DABCABA81CB80692000A7C39 /* Bench GL.app */, DA8847D21CBAF91600AB86E3 /* Mapbox.framework */, DAA4E4131CBB71D400178DFB /* libMapbox.a */, @@ -2539,7 +2539,7 @@ ); name = iosapp; productName = iosapp; - productReference = DA1DC94A1CB6C1C2006E619F /* Mapbox GL.app */; + productReference = DA1DC94A1CB6C1C2006E619F /* MapLibre GL.app */; productType = "com.apple.product-type.application"; }; DA2E88501CC036F400F24E7B /* test */ = { @@ -2676,7 +2676,8 @@ }; DABCABA71CB80692000A7C39 = { CreatedOnToolsVersion = 7.3; - DevelopmentTeam = GJZR2MEM28; + DevelopmentTeam = KBDAWM7T4E; + ProvisioningStyle = Manual; }; }; }; @@ -3504,6 +3505,8 @@ 96AF1AA321B615A3007CB696 /* RelWithDebInfo */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; @@ -3535,7 +3538,7 @@ INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.maplibregl; - PRODUCT_NAME = "Mapbox GL"; + PRODUCT_NAME = "MapLibre GL"; PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL TestApp Development"; }; name = RelWithDebInfo; @@ -3544,7 +3547,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = GJZR2MEM28; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = KBDAWM7T4E; HEADER_SEARCH_PATHS = ( "$(PROJECT_DIR)/../../../../include", "$(PROJECT_DIR)/../../../default/include", @@ -3561,9 +3567,11 @@ "$(PROJECT_DIR)/../../../darwin/include", ); INFOPLIST_FILE = benchmark/Info.plist; + LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.bench; + PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.bench; PRODUCT_NAME = "Bench GL"; + PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL Bench Development"; }; name = RelWithDebInfo; }; @@ -3726,6 +3734,8 @@ DA1DC95F1CB6C1C2006E619F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; @@ -3750,6 +3760,8 @@ DA1DC9601CB6C1C2006E619F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; @@ -3781,7 +3793,7 @@ INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.maplibregl; - PRODUCT_NAME = "Mapbox GL"; + PRODUCT_NAME = "MapLibre GL"; PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL TestApp Development"; }; name = Debug; @@ -3798,7 +3810,7 @@ INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.maplibregl; - PRODUCT_NAME = "Mapbox GL"; + PRODUCT_NAME = "MapLibre GL"; PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL TestApp Development"; }; name = Release; @@ -4011,7 +4023,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = GJZR2MEM28; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = KBDAWM7T4E; HEADER_SEARCH_PATHS = ( "$(PROJECT_DIR)/../../../../include", "$(PROJECT_DIR)/../../../default/include", @@ -4028,9 +4043,11 @@ "$(PROJECT_DIR)/../../../platform/darwin/include", ); INFOPLIST_FILE = benchmark/Info.plist; + LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.bench; + PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.bench; PRODUCT_NAME = "Bench GL"; + PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL Bench Development"; }; name = Debug; }; @@ -4038,7 +4055,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = GJZR2MEM28; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = KBDAWM7T4E; HEADER_SEARCH_PATHS = ( "$(PROJECT_DIR)/../../../../include", "$(PROJECT_DIR)/../../../default/include", @@ -4055,9 +4075,11 @@ "$(PROJECT_DIR)/../../../platform/darwin/include", ); INFOPLIST_FILE = benchmark/Info.plist; + LD_GENERATE_MAP_FILE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.bench; + PRODUCT_BUNDLE_IDENTIFIER = org.maplibre.bench; PRODUCT_NAME = "Bench GL"; + PROVISIONING_PROFILE_SPECIFIER = "MapLibre GL Bench Development"; }; name = Release; };