Files
MapLibreParticleLab/platform/ios/src/MGLUserLocation.h
Ian Wagner e78620c705 [ios] Set location to nil until the user's location is determined
The documentation for the `location` property states that "This property contains `nil` if the map view is not currently showing the user location or if the user’s location has not yet been determined." The iOS SDK presently returns a garbage value, which has some rather annoying consequences when the value should logically be nullable. This change should rectify the issue.

With _location no longer initialized to an invalid coordinate, trying to access `_location.coordinate` when `_location == nil` will return `0, 0`, which is a valid coordinate.
2017-08-28 16:41:55 -04:00

52 lines
1.5 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import "MGLFoundation.h"
#import "MGLAnnotation.h"
NS_ASSUME_NONNULL_BEGIN
/**
The MGLUserLocation class defines a specific type of annotation that identifies
the user’s current location. You do not create instances of this class
directly. Instead, you retrieve an existing `MGLUserLocation` object from the
`userLocation` property of the map view displayed in your application.
*/
MGL_EXPORT
@interface MGLUserLocation : NSObject <MGLAnnotation, NSSecureCoding>
#pragma mark Determining the User’s Position
/**
The current location of the device. (read-only)
This property returns `nil` if the user’s location has not yet been determined.
*/
@property (nonatomic, readonly, nullable) CLLocation *location;
/**
A Boolean value indicating whether the user’s location is currently being
updated. (read-only)
*/
@property (nonatomic, readonly, getter=isUpdating) BOOL updating;
/**
The heading of the user location. (read-only)
This property is `nil` if the user location tracking mode is not
`MGLUserTrackingModeFollowWithHeading`.
*/
@property (nonatomic, readonly, nullable) CLHeading *heading;
#pragma mark Accessing the User Annotation Text
/** The title to display for the user location annotation. */
@property (nonatomic, copy) NSString *title;
/** The subtitle to display for the user location annotation. */
@property (nonatomic, copy, nullable) NSString *subtitle;
@end
NS_ASSUME_NONNULL_END