diff options
-rw-r--r-- | include/mbgl/ios/MGLMetricsLocationManager.h | 4 | ||||
-rw-r--r-- | platform/ios/MGLMapboxEvents.m | 7 |
2 files changed, 10 insertions, 1 deletions
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]; |