diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-05-30 17:01:12 -0400 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-07-20 09:46:38 -0700 |
commit | af7d647ae349dc072da19ee375b8385f6178235f (patch) | |
tree | 8c2202f17c8e08d447ae56ace9beb3bf69742ef6 | |
parent | 357c777664ecc4fa7cddab8a4f835533354f02de (diff) | |
download | qtlocation-mapboxgl-af7d647ae349dc072da19ee375b8385f6178235f.tar.gz |
[ios] MGLMapView update to new location manager API.
-rw-r--r-- | platform/darwin/src/MGLLocationManager.m | 7 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/project.pbxproj | 5 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.h | 4 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 17 |
4 files changed, 25 insertions, 8 deletions
diff --git a/platform/darwin/src/MGLLocationManager.m b/platform/darwin/src/MGLLocationManager.m index 01f8ac32af..ad2604d84b 100644 --- a/platform/darwin/src/MGLLocationManager.m +++ b/platform/darwin/src/MGLLocationManager.m @@ -64,6 +64,13 @@ [self.locationManager stopUpdatingLocation]; } +- (void)dealloc +{ + [self.locationManager stopUpdatingLocation]; + [self.locationManager stopUpdatingHeading]; + self.delegate = nil; +} + #pragma mark - CLLocationManagerDelegate - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 73c959ab38..25062f342a 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -2647,6 +2647,7 @@ }; DA1DC9491CB6C1C2006E619F = { CreatedOnToolsVersion = 7.3; + DevelopmentTeam = 26847786Y6; LastSwiftMigration = 0820; }; DA25D5B81CCD9EDE00607828 = { @@ -3621,7 +3622,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 26847786Y6; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; @@ -3634,7 +3635,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 26847786Y6; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index 04a7a06313..e43d219485 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -2,7 +2,6 @@ #import "MGLMapCamera.h" #import <UIKit/UIKit.h> -#import <CoreLocation/CoreLocation.h> #import "MGLFoundation.h" #import "MGLTypes.h" @@ -22,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol MGLOverlay; @protocol MGLCalloutView; @protocol MGLFeature; +@protocol MGLLocationManager; /** The default deceleration rate for a map view. */ extern MGL_EXPORT const CGFloat MGLMapViewDecelerationRateNormal; @@ -296,6 +296,8 @@ MGL_EXPORT IB_DESIGNABLE #pragma mark Displaying the User’s Location +@property (nonatomic, nullable) id<MGLLocationManager> locationManager; + /** A Boolean value indicating whether the map may display the user location. diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index e4906e3688..5528112161 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -73,6 +73,7 @@ #import "MGLAnnotationContainerView_Private.h" #import "MGLAttributionInfo_Private.h" #import "MGLMapAccessibilityElement.h" +#import "MGLLocationManager_Private.h" #include <algorithm> #include <cstdlib> @@ -184,7 +185,7 @@ public: @interface MGLMapView () <UIGestureRecognizerDelegate, GLKViewDelegate, - CLLocationManagerDelegate, + MGLLocationManagerDelegate, MGLSMCalloutViewDelegate, MGLCalloutViewDelegate, MGLMultiPointDelegate, @@ -225,7 +226,6 @@ public: /// Indicates how thoroughly the map view is tracking the user location. @property (nonatomic) MGLUserTrackingState userTrackingState; -@property (nonatomic) CLLocationManager *locationManager; @property (nonatomic) CGFloat scale; @property (nonatomic) CGFloat angle; @property (nonatomic) CGFloat quickZoomStart; @@ -4687,13 +4687,20 @@ public: #pragma mark - User Location - +- (void)setLocationManager:(id<MGLLocationManager>)locationManager +{ + _locationManager = locationManager; + _locationManager.delegate = self; + [self validateLocationServices]; +} + - (void)validateLocationServices { BOOL shouldEnableLocationServices = self.showsUserLocation && !self.dormant; if (shouldEnableLocationServices && ! self.locationManager) { - self.locationManager = [[CLLocationManager alloc] init]; + self.locationManager = [[MGLCLLocationManager alloc] init]; if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { @@ -4966,12 +4973,12 @@ public: } } -- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations +- (void)locationManager:(MGLCLLocationManager *)manager didUpdateLocations:(NSArray *)locations { [self locationManager:manager didUpdateLocations:locations animated:YES]; } -- (void)locationManager:(__unused CLLocationManager *)manager didUpdateLocations:(NSArray *)locations animated:(BOOL)animated +- (void)locationManager:(__unused MGLCLLocationManager *)manager didUpdateLocations:(NSArray *)locations animated:(BOOL)animated { CLLocation *oldLocation = self.userLocation.location; CLLocation *newLocation = locations.lastObject; |