@rnmapbox/maps 10.0.0-beta.79 → 10.0.0-beta.80
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/RCTMGL-v10/RCTMGLCamera.swift +3 -3
- package/ios/RCTMGL-v10/RCTMGLInteractiveElement.swift +0 -1
- package/ios/RCTMGL-v10/RCTMGLLocationModule.swift +70 -47
- package/ios/RCTMGL-v10/RCTMGLOfflineModule.m +2 -0
- package/ios/RCTMGL-v10/RCTMGLOfflineModule.swift +31 -0
- package/ios/RCTMGL-v10/RCTMGLPointAnnotation.swift +4 -1
- package/package.json +1 -1
|
@@ -217,7 +217,7 @@ class RCTMGLCamera : RCTMGLMapComponentBase {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
func
|
|
220
|
+
func _disableUserTracking(_ map: MapView) {
|
|
221
221
|
map.viewport.idle()
|
|
222
222
|
}
|
|
223
223
|
|
|
@@ -263,12 +263,12 @@ class RCTMGLCamera : RCTMGLMapComponentBase {
|
|
|
263
263
|
let userTrackingMode = UserTrackingMode(rawValue: self.followUserMode ?? UserTrackingMode.normal.rawValue)
|
|
264
264
|
guard let userTrackingMode = userTrackingMode else {
|
|
265
265
|
Logger.error("RCTMGLCamera: Unexpected followUserMode \(optional: self.followUserMode)")
|
|
266
|
-
self.
|
|
266
|
+
self._disableUserTracking(map)
|
|
267
267
|
return
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
guard self.followUserLocation && userTrackingMode != .none else {
|
|
271
|
-
self.
|
|
271
|
+
self._disableUserTracking(map)
|
|
272
272
|
return
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -38,31 +38,50 @@ internal class EmptyLocationProviderDelegate: LocationProviderDelegate {
|
|
|
38
38
|
func locationProviderDidChangeAuthorization(_ provider: LocationProvider) {}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
protocol
|
|
42
|
-
func locationManager(_ locationManager:
|
|
41
|
+
protocol LocationProviderRCTMGLDelegate : AnyObject {
|
|
42
|
+
func locationManager(_ locationManager: LocationProviderRCTMGL, didUpdateLocation: RCTMGLLocation)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
/// LocationProviderRCTMGL listens to updates from a locationProvider and implements the LocationProvider interface itself
|
|
46
|
+
/// So it can be source of both updates to Mapbox mapView.location, and camera location updates as well as source to updates
|
|
47
|
+
/// to RCTMGLLocationModules.
|
|
48
|
+
class LocationProviderRCTMGL : LocationProviderDelegate {
|
|
46
49
|
enum LocationUpdateType {
|
|
47
50
|
case heading
|
|
48
51
|
case location
|
|
49
52
|
}
|
|
50
|
-
|
|
53
|
+
|
|
51
54
|
var provider: LocationProvider
|
|
52
55
|
|
|
53
56
|
var lastKnownLocation : CLLocation?
|
|
54
57
|
var lastKnownHeading : CLHeading?
|
|
55
58
|
var shouldRequestAlwaysAuthorization: Bool?
|
|
56
59
|
|
|
57
|
-
weak var delegate:
|
|
60
|
+
weak var delegate: LocationProviderRCTMGLDelegate?
|
|
58
61
|
weak var locationProviderDelage: LocationProviderDelegate?
|
|
59
62
|
|
|
60
63
|
var headingSimulator: Timer? = nil
|
|
61
64
|
var simulatedHeading: Double = 0.0
|
|
62
65
|
var simulatedHeadingIncrement: Double = 1.0
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
struct Status {
|
|
69
|
+
var provider = (updatingLocation: false, updatingHeading: false)
|
|
70
|
+
var rctmglModule = false
|
|
71
|
+
|
|
72
|
+
var shouldUpdateLocation: Bool {
|
|
73
|
+
return provider.updatingLocation || rctmglModule
|
|
74
|
+
}
|
|
75
|
+
var shouldUpdateHeading: Bool {
|
|
76
|
+
return provider.updatingHeading || rctmglModule
|
|
77
|
+
}
|
|
78
|
+
}
|
|
63
79
|
|
|
64
|
-
var
|
|
65
|
-
|
|
80
|
+
var started = Status(provider: (updatingLocation: false, updatingHeading: false), rctmglModule: false) {
|
|
81
|
+
didSet {
|
|
82
|
+
_syncStarted(oldValue: oldValue, started: started)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
66
85
|
|
|
67
86
|
init() {
|
|
68
87
|
provider = AppleLocationProvider()
|
|
@@ -84,23 +103,36 @@ class RCTMGLLocationManager : LocationProviderDelegate {
|
|
|
84
103
|
provider.requestAlwaysAuthorization()
|
|
85
104
|
}
|
|
86
105
|
provider.requestWhenInUseAuthorization()
|
|
87
|
-
|
|
88
|
-
provider.startUpdatingHeading()
|
|
89
|
-
provider.startUpdatingLocation()
|
|
106
|
+
started.rctmglModule = true
|
|
90
107
|
}
|
|
91
108
|
|
|
92
109
|
func stop() {
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
started.rctmglModule = false
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
func _syncStarted(oldValue: Status, started: Status) {
|
|
114
|
+
var stoppedSomething = false
|
|
115
|
+
if (oldValue.shouldUpdateLocation != started.shouldUpdateLocation) {
|
|
116
|
+
if started.shouldUpdateLocation {
|
|
117
|
+
provider.setDelegate(self)
|
|
118
|
+
provider.startUpdatingLocation()
|
|
119
|
+
} else {
|
|
120
|
+
provider.stopUpdatingLocation()
|
|
121
|
+
stoppedSomething = true
|
|
122
|
+
}
|
|
95
123
|
}
|
|
96
|
-
|
|
97
|
-
|
|
124
|
+
|
|
125
|
+
if (oldValue.shouldUpdateHeading != started.shouldUpdateHeading) {
|
|
126
|
+
if started.shouldUpdateHeading {
|
|
127
|
+
provider.setDelegate(self)
|
|
128
|
+
provider.startUpdatingHeading()
|
|
129
|
+
} else {
|
|
130
|
+
provider.stopUpdatingHeading()
|
|
131
|
+
stoppedSomething = true
|
|
132
|
+
}
|
|
98
133
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
func _clearProviderDelegateIfNotListening() {
|
|
103
|
-
if !startUpdatingHeadingCalled && !startUpdatingLocationCalled {
|
|
134
|
+
|
|
135
|
+
if stoppedSomething && !started.shouldUpdateLocation && !started.shouldUpdateHeading {
|
|
104
136
|
provider.setDelegate(EmptyLocationProviderDelegate())
|
|
105
137
|
}
|
|
106
138
|
}
|
|
@@ -159,7 +191,7 @@ class RCTMGLLocationManager : LocationProviderDelegate {
|
|
|
159
191
|
|
|
160
192
|
// MARK: LocationProvider
|
|
161
193
|
|
|
162
|
-
extension
|
|
194
|
+
extension LocationProviderRCTMGL: LocationProvider {
|
|
163
195
|
var locationProviderOptions: LocationOptions {
|
|
164
196
|
get {
|
|
165
197
|
provider.locationProviderOptions
|
|
@@ -209,15 +241,11 @@ extension RCTMGLLocationManager: LocationProvider {
|
|
|
209
241
|
}
|
|
210
242
|
|
|
211
243
|
func startUpdatingLocation() {
|
|
212
|
-
|
|
213
|
-
provider.startUpdatingLocation()
|
|
244
|
+
started.provider.updatingLocation = true
|
|
214
245
|
}
|
|
215
246
|
|
|
216
247
|
func stopUpdatingLocation() {
|
|
217
|
-
provider.
|
|
218
|
-
startUpdatingLocationCalled = false
|
|
219
|
-
|
|
220
|
-
_clearProviderDelegateIfNotListening()
|
|
248
|
+
started.provider.updatingLocation = false
|
|
221
249
|
}
|
|
222
250
|
|
|
223
251
|
var headingOrientation: CLDeviceOrientation {
|
|
@@ -230,15 +258,11 @@ extension RCTMGLLocationManager: LocationProvider {
|
|
|
230
258
|
}
|
|
231
259
|
|
|
232
260
|
func startUpdatingHeading() {
|
|
233
|
-
|
|
234
|
-
provider.startUpdatingHeading()
|
|
261
|
+
started.provider.updatingHeading = true
|
|
235
262
|
}
|
|
236
263
|
|
|
237
264
|
func stopUpdatingHeading() {
|
|
238
|
-
|
|
239
|
-
provider.stopUpdatingHeading()
|
|
240
|
-
|
|
241
|
-
_clearProviderDelegateIfNotListening()
|
|
265
|
+
started.provider.updatingHeading = false
|
|
242
266
|
}
|
|
243
267
|
|
|
244
268
|
func dismissHeadingCalibrationDisplay() {
|
|
@@ -273,7 +297,7 @@ final public class SimulatedHeading: CLHeading {
|
|
|
273
297
|
}
|
|
274
298
|
}
|
|
275
299
|
|
|
276
|
-
extension
|
|
300
|
+
extension LocationProviderRCTMGL {
|
|
277
301
|
func simulateHeading(changesPerSecond: Int, increment: Double) {
|
|
278
302
|
self.simulatedHeadingIncrement = increment
|
|
279
303
|
DispatchQueue.main.async {
|
|
@@ -294,18 +318,18 @@ extension RCTMGLLocationManager {
|
|
|
294
318
|
}
|
|
295
319
|
}
|
|
296
320
|
|
|
297
|
-
|
|
321
|
+
// LocationModule is a sigleton class
|
|
298
322
|
@objc(RCTMGLLocationModule)
|
|
299
|
-
class RCTMGLLocationModule: RCTEventEmitter,
|
|
323
|
+
class RCTMGLLocationModule: RCTEventEmitter, LocationProviderRCTMGLDelegate {
|
|
300
324
|
|
|
301
325
|
static weak var shared : RCTMGLLocationModule? = nil
|
|
302
326
|
|
|
303
|
-
var
|
|
327
|
+
var locationProviderRCTMGL : LocationProviderRCTMGL
|
|
304
328
|
var hasListener = false
|
|
305
329
|
|
|
306
330
|
var locationProvider : LocationProvider {
|
|
307
331
|
get {
|
|
308
|
-
return
|
|
332
|
+
return locationProviderRCTMGL
|
|
309
333
|
}
|
|
310
334
|
}
|
|
311
335
|
|
|
@@ -318,9 +342,9 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
|
|
|
318
342
|
)
|
|
319
343
|
|
|
320
344
|
override init() {
|
|
321
|
-
|
|
345
|
+
locationProviderRCTMGL = LocationProviderRCTMGL()
|
|
322
346
|
super.init()
|
|
323
|
-
|
|
347
|
+
locationProviderRCTMGL.delegate = self
|
|
324
348
|
RCTMGLLocationModule.shared = self
|
|
325
349
|
}
|
|
326
350
|
|
|
@@ -340,12 +364,12 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
|
|
|
340
364
|
}
|
|
341
365
|
|
|
342
366
|
@objc func start(_ minDisplacement: CLLocationDistance) {
|
|
343
|
-
if minDisplacement >= 0.0 {
|
|
344
|
-
|
|
367
|
+
if minDisplacement >= 0.0 { locationProviderRCTMGL.setDistanceFilter(minDisplacement) }
|
|
368
|
+
locationProviderRCTMGL.start()
|
|
345
369
|
}
|
|
346
370
|
|
|
347
371
|
@objc func stop() {
|
|
348
|
-
|
|
372
|
+
locationProviderRCTMGL.stop()
|
|
349
373
|
}
|
|
350
374
|
|
|
351
375
|
@objc func getLastKnownLocation() -> RCTMGLLocation? {
|
|
@@ -353,15 +377,15 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
|
|
|
353
377
|
}
|
|
354
378
|
|
|
355
379
|
@objc func setMinDisplacement(_ minDisplacement: CLLocationDistance) {
|
|
356
|
-
|
|
380
|
+
locationProviderRCTMGL.setDistanceFilter(minDisplacement)
|
|
357
381
|
}
|
|
358
382
|
|
|
359
383
|
@objc func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) {
|
|
360
|
-
|
|
384
|
+
locationProviderRCTMGL.setRequestsAlwaysUse(requestsAlwaysUse);
|
|
361
385
|
}
|
|
362
386
|
|
|
363
387
|
@objc func simulateHeading(_ changesPerSecond: NSNumber, increment: NSNumber) {
|
|
364
|
-
|
|
388
|
+
locationProviderRCTMGL.simulateHeading(changesPerSecond: changesPerSecond.intValue, increment: increment.doubleValue)
|
|
365
389
|
}
|
|
366
390
|
|
|
367
391
|
@objc
|
|
@@ -376,7 +400,7 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
|
|
|
376
400
|
hasListener = false
|
|
377
401
|
}
|
|
378
402
|
|
|
379
|
-
func locationManager(_ locationManager:
|
|
403
|
+
func locationManager(_ locationManager: LocationProviderRCTMGL, didUpdateLocation location: RCTMGLLocation) {
|
|
380
404
|
guard hasListener, let _ = bridge else {
|
|
381
405
|
return
|
|
382
406
|
}
|
|
@@ -416,7 +440,6 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
|
|
|
416
440
|
|
|
417
441
|
return false;
|
|
418
442
|
}
|
|
419
|
-
|
|
420
443
|
}
|
|
421
444
|
|
|
422
445
|
|
|
@@ -29,4 +29,6 @@ RCT_EXTERN_METHOD(deletePack:(NSString *)name
|
|
|
29
29
|
|
|
30
30
|
RCT_EXTERN_METHOD(migrateOfflineCache:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
31
31
|
|
|
32
|
+
RCT_EXTERN_METHOD(resetDatabase:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
33
|
+
|
|
32
34
|
@end
|
|
@@ -572,6 +572,37 @@ class RCTMGLOfflineModule: RCTEventEmitter {
|
|
|
572
572
|
reject("migrateOfflineCache", error.localizedDescription, error)
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
|
+
|
|
576
|
+
@objc
|
|
577
|
+
func resetDatabase(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
578
|
+
self.tileStore.allTileRegions { result in
|
|
579
|
+
switch result {
|
|
580
|
+
case .success(let regions):
|
|
581
|
+
regions.forEach { region in
|
|
582
|
+
self.tileStore.removeTileRegion(forId: region.id)
|
|
583
|
+
}
|
|
584
|
+
self.offlineManager.allStylePacks { result in
|
|
585
|
+
switch result {
|
|
586
|
+
case .success(let packs):
|
|
587
|
+
packs.forEach { pack in
|
|
588
|
+
if let url = logged("RCTMGLOfflineModule.resetDatabase invalid styleURI",fn: { return URL(string: pack.styleURI) }),
|
|
589
|
+
let styleUri = logged("RCTMGLOfflineModule.resetDatabase invalid styleURI2", fn: { return StyleURI(url: url) }) {
|
|
590
|
+
self.offlineManager.removeStylePack(for: styleUri)
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
resolve(nil)
|
|
594
|
+
case .failure(let error):
|
|
595
|
+
Logger.log(level:.error, message: "RCTMGLOfflineModule.resetDatabase/allStylePacks \(error.localizedDescription) \(error)")
|
|
596
|
+
reject("RCTMGLOfflineModule.resetDatabase/allStylePacks", error.localizedDescription, error)
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
case .failure(let error):
|
|
600
|
+
Logger.log(level:.error, message: "RCTMGLOfflineModule.resetDatabase/allTileRegions \(error.localizedDescription) \(error)")
|
|
601
|
+
reject("RCTMGLOfflineModule.resetDatabase/allTileRegions", error.localizedDescription, error)
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
}
|
|
575
606
|
}
|
|
576
607
|
|
|
577
608
|
// MARK: progress throttle
|
|
@@ -236,7 +236,10 @@ extension RCTMGLPointAnnotation {
|
|
|
236
236
|
|
|
237
237
|
@discardableResult
|
|
238
238
|
func addIfPossible() -> Bool {
|
|
239
|
-
if !added
|
|
239
|
+
if !added
|
|
240
|
+
&& annotation.point.coordinates.isValid()
|
|
241
|
+
&& (logged("PointAnnotation: missing id attribute") { return id }) != nil,
|
|
242
|
+
let pointAnnotationManager = map?.pointAnnotationManager {
|
|
240
243
|
pointAnnotationManager.add(annotation)
|
|
241
244
|
added = true
|
|
242
245
|
return true
|