summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLLocationManager.h
blob: d6cfab60d85eceb032ae645789b6abaf7b699b50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol MGLLocationManagerDelegate;

/**
 The `MGLLocationManager` protocol defines a set of methods that a class must
 implement in order to serve as the location manager of an `MGLMapView`. A location
 manager is responsible for notifying the map view about location-related events,
 such as a change in the user’s location. This protocol is similar to the
 Core Location framework’s `CLLocationManager` class, but your implementation
 does not need to be based on `CLLocationManager`.
 
 To receive location updates from an object that conforms to the `MGLLocationManager`
 protocol, use the optional methods available in the `MGLLocationManagerDelegate` protocol.
 */
@protocol MGLLocationManager <NSObject>

@optional

#pragma mark Configuring Location Update Precision

/**
 Specifies the minimum distance (measured in meters) a device must move horizontally
 before a location update is generated.
 
 The default value of this property is `kCLDistanceFilterNone` when `MGLMapView` uses its
 default location manager.
 
 @see `CLLocationManager.distanceFilter`
 */
@property(nonatomic, assign) CLLocationDistance distanceFilter;

/**
 Specifies the accuracy of the location data.
 
 The default value is `kCLLocationAccuracyBest` when `MGLMapView` uses its
 default location manager.
 
 @note Determining a location with greater accuracy requires more time and more power.
 
 @see `CLLocationManager.desiredAccuracy`
 */
@property (nonatomic, assign) CLLocationAccuracy desiredAccuracy;

/**
 Specifies the type of user activity associated with the location updates.
 
 The location manager uses this property as a cue to determine when location updates
 may be automatically paused.
 
 The default value is `CLActivityTypeOther` when `MGLMapView` uses its
 default location manager.
 
 @see `CLLocationManager.activityType`
 */
@property (nonatomic, assign) CLActivityType activityType;

@required

/**
 The delegate to receive location updates.
 
 Do not set the location manager’s delegate yourself. `MGLMapView` sets this property
 after the location manager becomes `MGLMapView`’s location manager.
 */
@property (nonatomic, weak) id<MGLLocationManagerDelegate> delegate;

#pragma mark Requesting Authorization for Location Services

/**
 Returns the current localization authorization status.
 
 @see `+[CLLocationManger authorizationStatus]`
 */
@property (nonatomic, readonly) CLAuthorizationStatus authorizationStatus;

/**
 Requests permission to use the location services whenever the app is running.
 */
- (void)requestAlwaysAuthorization;

/**
 Requests permission to use the location services while the app is in
 the foreground.
 */
- (void)requestWhenInUseAuthorization;

#pragma mark Initiating Location Updates

/**
 Starts the generation of location updates that reports the user's current location.
 */
- (void)startUpdatingLocation;

/**
 Stops the generation of location updates.
 */
- (void)stopUpdatingLocation;

#pragma mark Initiating Heading Updates

/**
 Specifies a physical device orientation.
 */
@property (nonatomic) CLDeviceOrientation headingOrientation;

/**
 Starts the generation of heading updates that reports the user's current hading.
 */
- (void)startUpdatingHeading;

/**
 Stops the generation of heading updates.
 */
- (void)stopUpdatingHeading;

/**
 Dissmisses immediately the heading calibration view from screen.
 */
- (void)dismissHeadingCalibrationDisplay;

@end

/**
 The `MGLLocationManagerDelegate` protocol defines a set of methods that respond
 to location updates from an `MGLLocationManager` object that is serving as the
 location manager of an `MGLMapView`.
 */
@protocol MGLLocationManagerDelegate <NSObject>

#pragma mark Responding to Location Updates

/**
 Notifies the delegate with the new location data.
 
 @param manager The location manager reporting the update.
 @param locations An array of `CLLocation` objects in chronological order,
 with the last object representing the most recent location. This array
 contains multiple `CLLocation` objects when `MGLMapView` uses  its
 default location manager.
 */
- (void)locationManager:(id<MGLLocationManager>)manager
     didUpdateLocations:(NSArray<CLLocation *> *)locations;

#pragma mark Responding to Heading Updates

/**
 Notifies the delegate with the new heading data.
 
 @param manager The location manager reporting the update.
 @param newHeading The new heading update.
 */
- (void)locationManager:(id<MGLLocationManager>)manager
       didUpdateHeading:(CLHeading *)newHeading;

/**
 Asks the delegate if the calibration alert should be displayed.
 
 @param manager The location manager reporting the calibration.
 */
- (BOOL)locationManagerShouldDisplayHeadingCalibration:(id<MGLLocationManager>)manager;

#pragma mark Responding to Location Updates Errors

/**
 Notifies the delegate that the location manager was unable to retrieve
 location updates.
 
 @param manager The location manager reporting the error.
 @param error An error object containing the error code that indicates
 why the location manager failed.
 */
- (void)locationManager:(id<MGLLocationManager>)manager
       didFailWithError:(nonnull NSError *)error;

@optional

@end

NS_ASSUME_NONNULL_END