From def309ba245635eeff53b3a5fb3b3821272d4d7c Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 6 Apr 2015 23:15:00 -0500 Subject: #1216 - Adding start and stop location manager update to pause and resume functions. --- include/mbgl/ios/MGLMetricsLocationManager.h | 4 +++- platform/ios/MGLMapboxEvents.m | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/mbgl/ios/MGLMetricsLocationManager.h b/include/mbgl/ios/MGLMetricsLocationManager.h index 7281d05010..5f3b568187 100644 --- a/include/mbgl/ios/MGLMetricsLocationManager.h +++ b/include/mbgl/ios/MGLMetricsLocationManager.h @@ -2,8 +2,10 @@ @interface MGLMetricsLocationManager : NSObject -// This method can be called from any thread. +// These methods can be called from any thread. // + (instancetype)sharedManager; ++ (void) startUpdatingLocation; ++ (void) stopUpdatingLocation; @end diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 593a983904..0f3422b86d 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -231,6 +231,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; + (void) pauseMetricsCollection { assert([[NSThread currentThread] isMainThread]); [MGLMapboxEvents sharedManager].isPaused = YES; + [MGLMetricsLocationManager stopUpdatingLocation]; } // Must be called from the main thread. @@ -238,6 +239,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; + (void) resumeMetricsCollection { assert([[NSThread currentThread] isMainThread]); [MGLMapboxEvents sharedManager].isPaused = NO; + [MGLMetricsLocationManager startUpdatingLocation]; } // Can be called from any thread. Can be called rapidly from @@ -268,6 +270,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; return; } + // Metrics Collection Has Been Paused + if (_isPaused) { + return; + } + if (!event) return; NSMutableDictionary *evt = [[NSMutableDictionary alloc] initWithDictionary:attributeDictionary]; -- cgit v1.2.1