summaryrefslogtreecommitdiff
path: root/platform/ios/MGLUserLocation.m
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2015-04-02 16:58:24 -0700
committerJustin R. Miller <incanus@codesorcery.net>2015-04-02 16:58:24 -0700
commit9a416c449cbcb1fc6f7b10ebef9fa14e8fb446ed (patch)
treed6678b3161a905f4994133522cfcb22ebba72696 /platform/ios/MGLUserLocation.m
parent7c05f941a8c001ad770a79fc2ae59093d0dcdcd2 (diff)
downloadqtlocation-mapboxgl-9a416c449cbcb1fc6f7b10ebef9fa14e8fb446ed.tar.gz
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.
Diffstat (limited to 'platform/ios/MGLUserLocation.m')
-rw-r--r--platform/ios/MGLUserLocation.m29
1 files changed, 21 insertions, 8 deletions
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