@maplibre/maplibre-react-native 10.1.0 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/MLRN/CameraStop.h +1 -1
- package/ios/MLRN/CameraStop.m +58 -60
- package/ios/MLRN/CameraUpdateItem.h +2 -1
- package/ios/MLRN/CameraUpdateItem.m +132 -132
- package/ios/MLRN/CameraUpdateQueue.m +43 -47
- package/ios/MLRN/FilterParser.h +1 -1
- package/ios/MLRN/FilterParser.m +5 -6
- package/ios/MLRN/MLRNBackgroundLayer.m +10 -9
- package/ios/MLRN/MLRNBackgroundLayerManager.m +4 -5
- package/ios/MLRN/MLRNCallout.h +1 -1
- package/ios/MLRN/MLRNCallout.m +37 -36
- package/ios/MLRN/MLRNCalloutManager.m +2 -3
- package/ios/MLRN/MLRNCamera.h +1 -1
- package/ios/MLRN/MLRNCamera.m +169 -182
- package/ios/MLRN/MLRNCameraManager.m +4 -6
- package/ios/MLRN/MLRNCircleLayer.m +17 -14
- package/ios/MLRN/MLRNCircleLayerManager.m +4 -5
- package/ios/MLRN/MLRNCustomHeaders.h +2 -2
- package/ios/MLRN/MLRNCustomHeaders.m +63 -63
- package/ios/MLRN/MLRNEvent.h +3 -3
- package/ios/MLRN/MLRNEvent.m +19 -24
- package/ios/MLRN/MLRNEventProtocol.h +1 -1
- package/ios/MLRN/MLRNFillExtrusionLayer.m +18 -14
- package/ios/MLRN/MLRNFillExtrusionLayerManager.m +4 -5
- package/ios/MLRN/MLRNFillLayer.m +16 -14
- package/ios/MLRN/MLRNFillLayerManager.m +4 -5
- package/ios/MLRN/MLRNHeatmapLayer.m +17 -14
- package/ios/MLRN/MLRNHeatmapLayerManager.m +4 -5
- package/ios/MLRN/MLRNImageQueue.h +4 -1
- package/ios/MLRN/MLRNImageQueue.m +29 -32
- package/ios/MLRN/MLRNImageQueueOperation.h +1 -1
- package/ios/MLRN/MLRNImageQueueOperation.m +92 -91
- package/ios/MLRN/MLRNImageSource.m +36 -38
- package/ios/MLRN/MLRNImageSourceManager.m +2 -3
- package/ios/MLRN/MLRNImageUtils.h +3 -3
- package/ios/MLRN/MLRNImageUtils.m +15 -14
- package/ios/MLRN/MLRNImages.h +0 -1
- package/ios/MLRN/MLRNImages.m +89 -91
- package/ios/MLRN/MLRNImagesManager.m +4 -5
- package/ios/MLRN/MLRNLayer.h +9 -11
- package/ios/MLRN/MLRNLayer.m +170 -182
- package/ios/MLRN/MLRNLight.m +21 -23
- package/ios/MLRN/MLRNLightManager.m +2 -3
- package/ios/MLRN/MLRNLineLayer.m +17 -15
- package/ios/MLRN/MLRNLineLayerManager.m +4 -6
- package/ios/MLRN/MLRNLocation.h +1 -1
- package/ios/MLRN/MLRNLocation.m +16 -17
- package/ios/MLRN/MLRNLocationManager.m +109 -124
- package/ios/MLRN/MLRNLocationManagerDelegate.h +3 -3
- package/ios/MLRN/MLRNLocationModule.h +1 -1
- package/ios/MLRN/MLRNLocationModule.m +40 -55
- package/ios/MLRN/MLRNLogging.h +1 -4
- package/ios/MLRN/MLRNLogging.m +84 -89
- package/ios/MLRN/MLRNMapTouchEvent.h +2 -2
- package/ios/MLRN/MLRNMapTouchEvent.m +50 -49
- package/ios/MLRN/MLRNMapView.h +43 -36
- package/ios/MLRN/MLRNMapView.m +409 -440
- package/ios/MLRN/MLRNMapViewManager.m +489 -502
- package/ios/MLRN/MLRNModule.h +1 -1
- package/ios/MLRN/MLRNModule.m +111 -105
- package/ios/MLRN/MLRNNativeUserLocation.m +24 -27
- package/ios/MLRN/MLRNNativeUserLocationManager.m +4 -8
- package/ios/MLRN/MLRNOfflineModule.h +1 -1
- package/ios/MLRN/MLRNOfflineModule.m +416 -421
- package/ios/MLRN/MLRNPointAnnotation.h +2 -2
- package/ios/MLRN/MLRNPointAnnotation.m +154 -175
- package/ios/MLRN/MLRNPointAnnotationManager.m +2 -3
- package/ios/MLRN/MLRNRasterLayer.m +16 -12
- package/ios/MLRN/MLRNRasterLayerManager.m +4 -5
- package/ios/MLRN/MLRNRasterSource.m +21 -17
- package/ios/MLRN/MLRNRasterSourceManager.m +2 -3
- package/ios/MLRN/MLRNShapeSource.h +17 -16
- package/ios/MLRN/MLRNShapeSource.m +94 -102
- package/ios/MLRN/MLRNShapeSourceManager.h +2 -2
- package/ios/MLRN/MLRNShapeSourceManager.m +86 -90
- package/ios/MLRN/MLRNSnapshotModule.h +1 -1
- package/ios/MLRN/MLRNSnapshotModule.m +51 -53
- package/ios/MLRN/MLRNSource.h +12 -12
- package/ios/MLRN/MLRNSource.m +82 -88
- package/ios/MLRN/MLRNStyleValue.h +1 -1
- package/ios/MLRN/MLRNStyleValue.m +128 -128
- package/ios/MLRN/MLRNSymbolLayer.m +17 -13
- package/ios/MLRN/MLRNSymbolLayerManager.m +4 -5
- package/ios/MLRN/MLRNTileSource.h +1 -1
- package/ios/MLRN/MLRNTileSource.m +21 -20
- package/ios/MLRN/MLRNUserLocation.h +1 -1
- package/ios/MLRN/MLRNUserLocation.m +10 -12
- package/ios/MLRN/MLRNUtils.h +18 -11
- package/ios/MLRN/MLRNUtils.m +168 -160
- package/ios/MLRN/MLRNVectorLayer.m +28 -34
- package/ios/MLRN/MLRNVectorSource.h +3 -1
- package/ios/MLRN/MLRNVectorSource.m +14 -11
- package/ios/MLRN/MLRNVectorSourceManager.h +2 -2
- package/ios/MLRN/MLRNVectorSourceManager.m +36 -39
- package/ios/MLRN/ViewManager.h +1 -1
- package/ios/MLRN/ViewManager.m +29 -35
- package/lib/commonjs/components/MarkerView.js +1 -1
- package/lib/commonjs/components/UserLocation.js +8 -38
- package/lib/commonjs/components/UserLocation.js.map +1 -1
- package/lib/commonjs/components/UserLocationPuck.js +52 -0
- package/lib/commonjs/components/UserLocationPuck.js.map +1 -0
- package/lib/commonjs/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +12 -9
- package/lib/commonjs/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/module/components/MarkerView.js +1 -1
- package/lib/module/components/UserLocation.js +7 -36
- package/lib/module/components/UserLocation.js.map +1 -1
- package/lib/module/components/UserLocationPuck.js +48 -0
- package/lib/module/components/UserLocationPuck.js.map +1 -0
- package/lib/module/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +11 -7
- package/lib/module/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/typescript/commonjs/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +0 -1
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +0 -1
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +0 -1
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/MarkerView.tsx +1 -1
- package/src/components/UserLocation.tsx +13 -51
- package/src/components/UserLocationPuck.tsx +62 -0
- package/src/components/UserLocationPuckHeading.tsx +33 -0
- package/lib/commonjs/components/HeadingIndicator.js.map +0 -1
- package/lib/module/components/HeadingIndicator.js.map +0 -1
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts.map +0 -1
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts.map +0 -1
- package/src/components/HeadingIndicator.tsx +0 -26
|
@@ -1,172 +1,157 @@
|
|
|
1
|
-
#import <CoreLocation/CoreLocation.h>
|
|
2
1
|
#import "MLRNLocationManager.h"
|
|
2
|
+
#import <CoreLocation/CoreLocation.h>
|
|
3
3
|
|
|
4
|
-
@interface MLRNLocationManager()<CLLocationManagerDelegate>
|
|
4
|
+
@interface MLRNLocationManager () <CLLocationManagerDelegate>
|
|
5
5
|
@end
|
|
6
6
|
|
|
7
|
-
@implementation MLRNLocationManager
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
- (instancetype)init
|
|
26
|
-
{
|
|
27
|
-
if (self = [super init]) {
|
|
28
|
-
[self _setupLocationManager];
|
|
29
|
-
listeners = [[NSMutableArray alloc] init];
|
|
30
|
-
displacement = 0.0;
|
|
31
|
-
}
|
|
32
|
-
return self;
|
|
7
|
+
@implementation MLRNLocationManager {
|
|
8
|
+
CLLocationManager *locationManager;
|
|
9
|
+
CLLocation *lastKnownLocation;
|
|
10
|
+
CLHeading *lastKnownHeading;
|
|
11
|
+
CLLocationDistance displacement;
|
|
12
|
+
NSMutableArray<MLRNLocationBlock> *listeners;
|
|
13
|
+
BOOL isListening;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
+ (id)sharedInstance {
|
|
17
|
+
static MLRNLocationManager *manager = nil;
|
|
18
|
+
static dispatch_once_t onceToken;
|
|
19
|
+
dispatch_once(&onceToken, ^{
|
|
20
|
+
manager = [[self alloc] init];
|
|
21
|
+
});
|
|
22
|
+
return manager;
|
|
33
23
|
}
|
|
34
24
|
|
|
35
|
-
- (
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
[
|
|
25
|
+
- (instancetype)init {
|
|
26
|
+
if (self = [super init]) {
|
|
27
|
+
[self _setupLocationManager];
|
|
28
|
+
listeners = [[NSMutableArray alloc] init];
|
|
29
|
+
displacement = 0.0;
|
|
30
|
+
}
|
|
31
|
+
return self;
|
|
39
32
|
}
|
|
40
33
|
|
|
41
|
-
- (void)
|
|
42
|
-
|
|
34
|
+
- (void)dealloc {
|
|
35
|
+
locationManager.delegate = nil;
|
|
36
|
+
[self stop];
|
|
37
|
+
}
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
- (void)start:(CLLocationDistance)minDisplacement {
|
|
40
|
+
displacement = minDisplacement;
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
if ([self isEnabled]) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
47
|
+
[self->locationManager requestWhenInUseAuthorization];
|
|
48
|
+
[self->locationManager startUpdatingLocation];
|
|
49
|
+
[self->locationManager startUpdatingHeading];
|
|
50
|
+
[self->locationManager setDistanceFilter:(minDisplacement)];
|
|
51
|
+
self->isListening = YES;
|
|
52
|
+
});
|
|
57
53
|
}
|
|
58
54
|
|
|
59
|
-
- (void)setMinDisplacement:(CLLocationDistance)minDisplacement
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
displacement = minDisplacement;
|
|
55
|
+
- (void)setMinDisplacement:(CLLocationDistance)minDisplacement {
|
|
56
|
+
displacement = minDisplacement;
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
59
|
+
[self->locationManager setDistanceFilter:(minDisplacement)];
|
|
60
|
+
});
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
- (void)stop
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
63
|
+
- (void)stop {
|
|
64
|
+
if (![self isEnabled]) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
69
|
+
[self->locationManager stopUpdatingLocation];
|
|
70
|
+
[self->locationManager stopUpdatingHeading];
|
|
71
|
+
self->isListening = NO;
|
|
72
|
+
});
|
|
80
73
|
}
|
|
81
74
|
|
|
82
|
-
- (BOOL)isEnabled
|
|
83
|
-
|
|
84
|
-
return isListening;
|
|
75
|
+
- (BOOL)isEnabled {
|
|
76
|
+
return isListening;
|
|
85
77
|
}
|
|
86
78
|
|
|
87
|
-
- (MLRNLocation *)getLastKnownLocation
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return location;
|
|
79
|
+
- (MLRNLocation *)getLastKnownLocation {
|
|
80
|
+
CLLocation *newLastLocation = locationManager.location;
|
|
81
|
+
if (newLastLocation) {
|
|
82
|
+
lastKnownLocation = newLastLocation;
|
|
83
|
+
}
|
|
84
|
+
MLRNLocation *location = [self _convertToMapboxLocation:lastKnownLocation];
|
|
85
|
+
return location;
|
|
95
86
|
}
|
|
96
87
|
|
|
97
|
-
- (void)addListener:(MLRNLocationBlock)listener
|
|
98
|
-
{
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
88
|
+
- (void)addListener:(MLRNLocationBlock)listener {
|
|
89
|
+
if (![listeners containsObject:listener]) {
|
|
90
|
+
[listeners addObject:listener];
|
|
91
|
+
}
|
|
102
92
|
}
|
|
103
93
|
|
|
104
|
-
- (void)removeListener:(MLRNLocationBlock)listener
|
|
105
|
-
|
|
106
|
-
NSUInteger indexOf = [listeners indexOfObject:listener];
|
|
94
|
+
- (void)removeListener:(MLRNLocationBlock)listener {
|
|
95
|
+
NSUInteger indexOf = [listeners indexOfObject:listener];
|
|
107
96
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
if (indexOf == NSNotFound) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
111
100
|
|
|
112
|
-
|
|
101
|
+
[listeners removeObjectAtIndex:indexOf];
|
|
113
102
|
}
|
|
114
103
|
|
|
115
|
-
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)heading
|
|
116
|
-
|
|
117
|
-
lastKnownHeading = heading;
|
|
104
|
+
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)heading {
|
|
105
|
+
lastKnownHeading = heading;
|
|
118
106
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
107
|
+
if (displacement > 0) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
122
110
|
|
|
123
|
-
|
|
111
|
+
[self _updateDelegate];
|
|
124
112
|
}
|
|
125
113
|
|
|
126
|
-
- (void)locationManager:(CLLocationManager *)manager
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
114
|
+
- (void)locationManager:(CLLocationManager *)manager
|
|
115
|
+
didUpdateLocations:(NSArray<CLLocation *> *)locations {
|
|
116
|
+
lastKnownLocation = [locations lastObject];
|
|
117
|
+
[self _updateDelegate];
|
|
130
118
|
}
|
|
131
119
|
|
|
132
|
-
- (void)_setupLocationManager
|
|
133
|
-
|
|
134
|
-
__weak MLRNLocationManager *weakSelf = self;
|
|
120
|
+
- (void)_setupLocationManager {
|
|
121
|
+
__weak MLRNLocationManager *weakSelf = self;
|
|
135
122
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
123
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
124
|
+
self->locationManager = [[CLLocationManager alloc] init];
|
|
125
|
+
self->locationManager.delegate = weakSelf;
|
|
126
|
+
});
|
|
140
127
|
}
|
|
141
128
|
|
|
142
|
-
- (void)_updateDelegate
|
|
143
|
-
{
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
129
|
+
- (void)_updateDelegate {
|
|
130
|
+
if (_delegate == nil) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
147
133
|
|
|
148
|
-
|
|
134
|
+
MLRNLocation *userLocation = [self _convertToMapboxLocation:lastKnownLocation];
|
|
149
135
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
136
|
+
if (listeners.count > 0) {
|
|
137
|
+
for (int i = 0; i < listeners.count; i++) {
|
|
138
|
+
MLRNLocationBlock listener = listeners[i];
|
|
139
|
+
listener(userLocation);
|
|
155
140
|
}
|
|
141
|
+
}
|
|
156
142
|
|
|
157
|
-
|
|
143
|
+
[_delegate locationManager:self didUpdateLocation:userLocation];
|
|
158
144
|
}
|
|
159
145
|
|
|
160
|
-
- (MLRNLocation *)_convertToMapboxLocation:(CLLocation *)location
|
|
161
|
-
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
146
|
+
- (MLRNLocation *)_convertToMapboxLocation:(CLLocation *)location {
|
|
147
|
+
if (location == nil) {
|
|
148
|
+
return nil;
|
|
149
|
+
}
|
|
165
150
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
151
|
+
MLRNLocation *userLocation = [[MLRNLocation alloc] init];
|
|
152
|
+
userLocation.location = location;
|
|
153
|
+
userLocation.heading = lastKnownHeading;
|
|
154
|
+
return userLocation;
|
|
170
155
|
}
|
|
171
156
|
|
|
172
157
|
@end
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
@class MLRNLocationManager;
|
|
6
6
|
|
|
7
|
-
@protocol MLRNLocationManagerDelegate<NSObject>
|
|
7
|
+
@protocol MLRNLocationManagerDelegate <NSObject>
|
|
8
8
|
|
|
9
|
-
- (void)locationManager:(MLRNLocationManager *)locationManager
|
|
9
|
+
- (void)locationManager:(MLRNLocationManager *)locationManager
|
|
10
|
+
didUpdateLocation:(MLRNLocation *)location;
|
|
10
11
|
|
|
11
12
|
@end
|
|
12
|
-
|
|
@@ -1,91 +1,76 @@
|
|
|
1
1
|
#import <CoreLocation/CoreLocation.h>
|
|
2
2
|
|
|
3
|
+
#import "MLRNEventTypes.h"
|
|
3
4
|
#import "MLRNLocation.h"
|
|
4
|
-
#import "MLRNLocationModule.h"
|
|
5
5
|
#import "MLRNLocationManager.h"
|
|
6
6
|
#import "MLRNLocationManagerDelegate.h"
|
|
7
|
-
#import "
|
|
7
|
+
#import "MLRNLocationModule.h"
|
|
8
8
|
|
|
9
|
-
@interface MLRNLocationModule() <MLRNLocationManagerDelegate>
|
|
9
|
+
@interface MLRNLocationModule () <MLRNLocationManagerDelegate>
|
|
10
10
|
@end
|
|
11
11
|
|
|
12
|
-
@implementation MLRNLocationModule
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
BOOL hasListeners;
|
|
12
|
+
@implementation MLRNLocationModule {
|
|
13
|
+
MLRNLocationManager *locationManager;
|
|
14
|
+
BOOL hasListeners;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
RCT_EXPORT_MODULE();
|
|
19
18
|
|
|
20
|
-
+ (BOOL)requiresMainQueueSetup
|
|
21
|
-
|
|
22
|
-
return NO;
|
|
19
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
20
|
+
return NO;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
- (instancetype)init
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return self;
|
|
23
|
+
- (instancetype)init {
|
|
24
|
+
if (self = [super init]) {
|
|
25
|
+
locationManager = [[MLRNLocationManager alloc] init];
|
|
26
|
+
locationManager.delegate = self;
|
|
27
|
+
}
|
|
28
|
+
return self;
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
- (void)startObserving
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
hasListeners = YES;
|
|
31
|
+
- (void)startObserving {
|
|
32
|
+
[super startObserving];
|
|
33
|
+
hasListeners = YES;
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
- (void)stopObserving
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
hasListeners = NO;
|
|
36
|
+
- (void)stopObserving {
|
|
37
|
+
[super stopObserving];
|
|
38
|
+
hasListeners = NO;
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
- (NSArray<NSString *> *)supportedEvents
|
|
47
|
-
|
|
48
|
-
return @[RCT_MAPBOX_USER_LOCATION_UPDATE];
|
|
41
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
42
|
+
return @[ RCT_MAPBOX_USER_LOCATION_UPDATE ];
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
RCT_EXPORT_METHOD(start:(CLLocationDistance)minDisplacement)
|
|
52
|
-
{
|
|
45
|
+
RCT_EXPORT_METHOD(start : (CLLocationDistance)minDisplacement) {
|
|
53
46
|
[locationManager start:minDisplacement];
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
RCT_EXPORT_METHOD(pause)
|
|
57
|
-
{
|
|
58
|
-
[locationManager stop];
|
|
59
|
-
}
|
|
49
|
+
RCT_EXPORT_METHOD(pause) { [locationManager stop]; }
|
|
60
50
|
|
|
61
|
-
RCT_EXPORT_METHOD(stop)
|
|
62
|
-
{
|
|
63
|
-
[locationManager stop];
|
|
64
|
-
}
|
|
51
|
+
RCT_EXPORT_METHOD(stop) { [locationManager stop]; }
|
|
65
52
|
|
|
66
|
-
RCT_EXPORT_METHOD(setMinDisplacement:(CLLocationDistance)minDisplacement)
|
|
67
|
-
|
|
68
|
-
[locationManager setMinDisplacement:minDisplacement];
|
|
53
|
+
RCT_EXPORT_METHOD(setMinDisplacement : (CLLocationDistance)minDisplacement) {
|
|
54
|
+
[locationManager setMinDisplacement:minDisplacement];
|
|
69
55
|
}
|
|
70
56
|
|
|
71
|
-
RCT_EXPORT_METHOD(getLastKnownLocation:(RCTPromiseResolveBlock)
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
RCT_EXPORT_METHOD(getLastKnownLocation : (RCTPromiseResolveBlock)
|
|
58
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
59
|
+
MLRNLocation *lastKnownLocation = [locationManager getLastKnownLocation];
|
|
60
|
+
resolve(lastKnownLocation);
|
|
75
61
|
}
|
|
76
62
|
|
|
77
|
-
- (void)locationManager:(MLRNLocationManager *)locationManager
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
- (void)locationManager:(MLRNLocationManager *)locationManager
|
|
64
|
+
didUpdateLocation:(MLRNLocation *)location {
|
|
65
|
+
if (!hasListeners) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
82
68
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
if (self.bridge == nil) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
86
72
|
|
|
87
|
-
|
|
73
|
+
[self sendEventWithName:RCT_MAPBOX_USER_LOCATION_UPDATE body:[location toJSON]];
|
|
88
74
|
}
|
|
89
75
|
|
|
90
76
|
@end
|
|
91
|
-
|
package/ios/MLRN/MLRNLogging.h
CHANGED
|
@@ -4,14 +4,11 @@
|
|
|
4
4
|
#import <Foundation/Foundation.h>
|
|
5
5
|
#import <React/RCTEventEmitter.h>
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
@class MLNLoggingConfiguration;
|
|
9
8
|
|
|
10
9
|
@interface MLRNLogging : RCTEventEmitter <RCTBridgeModule>
|
|
11
10
|
|
|
12
|
-
@property (nonatomic, nonnull) MLNLoggingConfiguration*
|
|
13
|
-
|
|
14
|
-
- (void)setLoggingLevel:(nonnull NSString*) logLevel;
|
|
11
|
+
@property (nonatomic, nonnull) MLNLoggingConfiguration* loggingConfiguration;
|
|
15
12
|
|
|
16
13
|
@end
|
|
17
14
|
|
package/ios/MLRN/MLRNLogging.m
CHANGED
|
@@ -2,131 +2,126 @@
|
|
|
2
2
|
|
|
3
3
|
@import MapLibre;
|
|
4
4
|
|
|
5
|
-
@interface MLRNLogging()
|
|
5
|
+
@interface MLRNLogging ()
|
|
6
6
|
@property (nonatomic) BOOL hasListeners;
|
|
7
7
|
@end
|
|
8
8
|
|
|
9
9
|
@implementation MLRNLogging
|
|
10
10
|
|
|
11
11
|
+ (id)allocWithZone:(NSZone *)zone {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
static MLRNLogging *sharedInstance = nil;
|
|
13
|
+
static dispatch_once_t onceToken;
|
|
14
|
+
dispatch_once(&onceToken, ^{
|
|
15
|
+
sharedInstance = [super allocWithZone:zone];
|
|
16
|
+
});
|
|
17
|
+
return sharedInstance;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
-(id)init {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
- (id)init {
|
|
21
|
+
if (self = [super init]) {
|
|
22
|
+
self.loggingConfiguration = [MLNLoggingConfiguration sharedConfiguration];
|
|
23
|
+
[self.loggingConfiguration setLoggingLevel:MLNLoggingLevelWarning];
|
|
24
|
+
__weak typeof(self) weakSelf = self;
|
|
25
|
+
self.loggingConfiguration.handler =
|
|
26
|
+
^(MLNLoggingLevel loggingLevel, NSString *filePath, NSUInteger line, NSString *message) {
|
|
27
|
+
[weakSelf sendLogWithLevel:loggingLevel filePath:filePath line:line message:message];
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
}
|
|
30
|
+
return self;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
RCT_EXPORT_MODULE();
|
|
33
34
|
|
|
34
|
-
+ (BOOL)requiresMainQueueSetup
|
|
35
|
-
|
|
36
|
-
return YES;
|
|
35
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
36
|
+
return YES;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
- (NSArray<NSString *> *)supportedEvents
|
|
40
|
-
|
|
41
|
-
return @[@"LogEvent"];
|
|
39
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
40
|
+
return @[ @"LogEvent" ];
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
- (void)startObserving
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
self.hasListeners = true;
|
|
43
|
+
- (void)startObserving {
|
|
44
|
+
[super startObserving];
|
|
45
|
+
self.hasListeners = true;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
- (void)stopObserving
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
self.hasListeners = false;
|
|
48
|
+
- (void)stopObserving {
|
|
49
|
+
[super stopObserving];
|
|
50
|
+
self.hasListeners = false;
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
- (void)sendLogWithLevel:(MLNLoggingLevel)loggingLevel
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
- (void)sendLogWithLevel:(MLNLoggingLevel)loggingLevel
|
|
54
|
+
filePath:(NSString *)filePath
|
|
55
|
+
line:(NSUInteger)line
|
|
56
|
+
message:(NSString *)message {
|
|
57
|
+
if (!self.hasListeners) return;
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
NSString *level = @"n/a";
|
|
60
|
+
switch (loggingLevel) {
|
|
62
61
|
case MLNLoggingLevelInfo:
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
level = @"info";
|
|
63
|
+
break;
|
|
65
64
|
case MLNLoggingLevelError:
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
level = @"error";
|
|
66
|
+
break;
|
|
68
67
|
#if MLN_LOGGING_ENABLE_DEBUG
|
|
69
68
|
case MLNLoggingLevelDebug:
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
level = @"debug";
|
|
70
|
+
break;
|
|
72
71
|
#endif
|
|
73
72
|
case MLNLoggingLevelWarning:
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
level = @"warning";
|
|
74
|
+
break;
|
|
76
75
|
case MLNLoggingLevelNone:
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
level = @"none";
|
|
77
|
+
break;
|
|
79
78
|
case MLNLoggingLevelFault:
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
level = @"fault";
|
|
80
|
+
break;
|
|
82
81
|
case MLNLoggingLevelVerbose:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
body[@"type"] = type;
|
|
101
|
-
}
|
|
102
|
-
[self sendEventWithName:@"LogEvent" body:body];
|
|
82
|
+
level = @"verbose";
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
NSString *type = nil;
|
|
87
|
+
if ([message hasPrefix:@"Failed to load glyph range"]) {
|
|
88
|
+
type = @"missing_font";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
NSMutableDictionary *body =
|
|
92
|
+
[@{@"level" : level, @"message" : message, @"filePath" : filePath, @"line" : @(line)}
|
|
93
|
+
mutableCopy];
|
|
94
|
+
|
|
95
|
+
if (type != nil) {
|
|
96
|
+
body[@"type"] = type;
|
|
97
|
+
}
|
|
98
|
+
[self sendEventWithName:@"LogEvent" body:body];
|
|
103
99
|
}
|
|
104
100
|
|
|
105
|
-
RCT_EXPORT_METHOD(setLogLevel: (nonnull NSString*)logLevel)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
} else if ([logLevel isEqualToString:@"debug"]) {
|
|
101
|
+
RCT_EXPORT_METHOD(setLogLevel : (nonnull NSString *)logLevel) {
|
|
102
|
+
MLNLoggingLevel mlnLogLevel = MLNLoggingLevelNone;
|
|
103
|
+
if ([logLevel isEqualToString:@"none"]) {
|
|
104
|
+
mlnLogLevel = MLNLoggingLevelNone;
|
|
105
|
+
} else if ([logLevel isEqualToString:@"debug"]) {
|
|
106
|
+
mlnLogLevel = MLNLoggingLevelInfo;
|
|
107
|
+
} else if ([logLevel isEqualToString:@"fault"]) {
|
|
108
|
+
mlnLogLevel = MLNLoggingLevelFault;
|
|
109
|
+
} else if ([logLevel isEqualToString:@"error"]) {
|
|
110
|
+
mlnLogLevel = MLNLoggingLevelError;
|
|
111
|
+
} else if ([logLevel isEqualToString:@"warning"]) {
|
|
112
|
+
mlnLogLevel = MLNLoggingLevelWarning;
|
|
113
|
+
} else if ([logLevel isEqualToString:@"info"]) {
|
|
114
|
+
mlnLogLevel = MLNLoggingLevelInfo;
|
|
115
|
+
} else if ([logLevel isEqualToString:@"debug"]) {
|
|
121
116
|
#if MLN_LOGGING_ENABLE_DEBUG
|
|
122
|
-
|
|
117
|
+
mlnLogLevel = MLNLoggingLevelDebug;
|
|
123
118
|
#else
|
|
124
|
-
|
|
119
|
+
mlnLogLevel = MLNLoggingLevelVerbose;
|
|
125
120
|
#endif
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
} else if ([logLevel isEqualToString:@"verbose"]) {
|
|
122
|
+
mlnLogLevel = MLNLoggingLevelVerbose;
|
|
123
|
+
}
|
|
124
|
+
self.loggingConfiguration.loggingLevel = mlnLogLevel;
|
|
130
125
|
}
|
|
131
126
|
|
|
132
127
|
@end
|