From 9a416c449cbcb1fc6f7b10ebef9fa14e8fb446ed Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Thu, 2 Apr 2015 16:58:24 -0700 Subject: Improvements to docs & user location framework. * Cleans up & documents more APIs, especially in location. * Moves `coordinate` internal and makes use of `location` to retrieve it. * Moves `title` & `subtitle` internal since part of `MGLAnnotation` protocol. * Enables `isUpdating` by privately associating weakly with a map view. --- platform/ios/MGLUserLocation.m | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'platform/ios/MGLUserLocation.m') diff --git a/platform/ios/MGLUserLocation.m b/platform/ios/MGLUserLocation.m index 054dfa686d..056f0a4470 100644 --- a/platform/ios/MGLUserLocation.m +++ b/platform/ios/MGLUserLocation.m @@ -1,17 +1,21 @@ #import "MGLUserLocation_Private.h" -@implementation MGLUserLocation -{ - CLLocationCoordinate2D _coordinate; -} +#import "MGLMapView.h" + +@interface MGLUserLocation () + +@property (nonatomic, copy) NSString *title; +@property (nonatomic, copy) NSString *subtitle; + +@end -@synthesize coordinate = _coordinate; +@implementation MGLUserLocation - (instancetype)init { if (self = [super init]) { - _coordinate = CLLocationCoordinate2DMake(MAXFLOAT, MAXFLOAT); + _location = [[CLLocation alloc] initWithLatitude:MAXFLOAT longitude:MAXFLOAT]; } return self; @@ -34,11 +38,15 @@ { [self willChangeValueForKey:@"location"]; _location = newLocation; - _coordinate = _location.coordinate; [self didChangeValueForKey:@"location"]; } } +- (BOOL)isUpdating +{ + return self.mapView.userTrackingMode != MGLUserTrackingModeNone; +} + - (void)setHeading:(CLHeading *)newHeading { if (newHeading.trueHeading != _heading.trueHeading) @@ -49,9 +57,14 @@ } } +- (CLLocationCoordinate2D)coordinate +{ + return self.location.coordinate; +} + - (NSString *)title { - if ( ! _title) return @"Current Location"; + return (_title ? _title : @"Current Location"); } @end -- cgit v1.2.1