@rnmapbox/maps 10.0.12-rc.0 → 10.0.12-rc.2

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.
@@ -1,5 +1,5 @@
1
1
  def defaultMapboxMapsImpl = "maplibre"
2
- def defaultMapboxMapsVersion = "10.14.1"
2
+ def defaultMapboxMapsVersion = "10.15.0"
3
3
 
4
4
  def safeExtGet(prop, fallback) {
5
5
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -42,6 +42,126 @@ protocol LocationProviderRCTMGLDelegate : AnyObject {
42
42
  func locationManager(_ locationManager: LocationProviderRCTMGL, didUpdateLocation: RCTMGLLocation)
43
43
  }
44
44
 
45
+ class RCTMGLAppleLocationProvider: NSObject {
46
+ private var locationProvider: CLLocationManager
47
+ private var privateLocationProviderOptions: LocationOptions {
48
+ didSet {
49
+ locationProvider.distanceFilter = privateLocationProviderOptions.distanceFilter
50
+ locationProvider.desiredAccuracy = privateLocationProviderOptions.desiredAccuracy
51
+ locationProvider.activityType = privateLocationProviderOptions.activityType
52
+ }
53
+ }
54
+ private weak var delegate: LocationProviderDelegate?
55
+
56
+ public var headingOrientation: CLDeviceOrientation {
57
+ didSet { locationProvider.headingOrientation = headingOrientation }
58
+ }
59
+
60
+ public override init() {
61
+ locationProvider = CLLocationManager()
62
+ privateLocationProviderOptions = LocationOptions()
63
+ headingOrientation = locationProvider.headingOrientation
64
+ super.init()
65
+ locationProvider.delegate = self
66
+ }
67
+ }
68
+
69
+ extension RCTMGLAppleLocationProvider: LocationProvider {
70
+
71
+ public var locationProviderOptions: LocationOptions {
72
+ get { privateLocationProviderOptions }
73
+ set { privateLocationProviderOptions = newValue }
74
+ }
75
+
76
+ public var authorizationStatus: CLAuthorizationStatus {
77
+ if #available(iOS 14.0, *) {
78
+ return locationProvider.authorizationStatus
79
+ } else {
80
+ return CLLocationManager.authorizationStatus()
81
+ }
82
+ }
83
+
84
+ public var accuracyAuthorization: CLAccuracyAuthorization {
85
+ if #available(iOS 14.0, *) {
86
+ return locationProvider.accuracyAuthorization
87
+ } else {
88
+ return .fullAccuracy
89
+ }
90
+ }
91
+
92
+ public var heading: CLHeading? {
93
+ return locationProvider.heading
94
+ }
95
+
96
+ public func setDelegate(_ delegate: LocationProviderDelegate) {
97
+ self.delegate = delegate
98
+ }
99
+
100
+ public func requestAlwaysAuthorization() {
101
+ locationProvider.requestAlwaysAuthorization()
102
+ }
103
+
104
+ public func requestWhenInUseAuthorization() {
105
+ locationProvider.requestWhenInUseAuthorization()
106
+ }
107
+
108
+ @available(iOS 14.0, *)
109
+ public func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String) {
110
+ locationProvider.requestTemporaryFullAccuracyAuthorization(withPurposeKey: purposeKey)
111
+ }
112
+
113
+ public func startUpdatingLocation() {
114
+ locationProvider.startUpdatingLocation()
115
+ }
116
+
117
+ public func stopUpdatingLocation() {
118
+ locationProvider.stopUpdatingLocation()
119
+ }
120
+
121
+ public func startUpdatingHeading() {
122
+ locationProvider.startUpdatingHeading()
123
+ }
124
+
125
+ public func stopUpdatingHeading() {
126
+ locationProvider.stopUpdatingHeading()
127
+ }
128
+
129
+ public func dismissHeadingCalibrationDisplay() {
130
+ locationProvider.dismissHeadingCalibrationDisplay()
131
+ }
132
+ }
133
+
134
+ extension RCTMGLAppleLocationProvider: CLLocationManagerDelegate {
135
+ public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
136
+ delegate?.locationProvider(self, didUpdateLocations: locations)
137
+ }
138
+
139
+ public func locationManager(_ manager: CLLocationManager, didUpdateHeading heading: CLHeading) {
140
+ delegate?.locationProvider(self, didUpdateHeading: heading)
141
+ }
142
+
143
+ public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
144
+ delegate?.locationProvider(self, didFailWithError: error)
145
+ }
146
+
147
+ @available(iOS 14.0, *)
148
+ public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
149
+ delegate?.locationProviderDidChangeAuthorization(self)
150
+ }
151
+
152
+ public func locationManagerShouldDisplayHeadingCalibration(_ manager: CLLocationManager) -> Bool {
153
+ guard let calibratingDelegate = delegate as? CalibratingLocationProviderDelegate else {
154
+ return false
155
+ }
156
+
157
+ return calibratingDelegate.locationProviderShouldDisplayHeadingCalibration(self)
158
+ }
159
+ }
160
+
161
+ internal protocol CalibratingLocationProviderDelegate: LocationProviderDelegate {
162
+ func locationProviderShouldDisplayHeadingCalibration(_ locationProvider: LocationProvider) -> Bool
163
+ }
164
+
45
165
  /// LocationProviderRCTMGL listens to updates from a locationProvider and implements the LocationProvider interface itself
46
166
  /// So it can be source of Mapbox locationProduces (which updates location pluck and viewport if configured) as well as source to updates
47
167
  /// to RCTMGLLocationModules.
@@ -84,7 +204,7 @@ class LocationProviderRCTMGL : LocationProviderDelegate {
84
204
  }
85
205
 
86
206
  init() {
87
- provider = AppleLocationProvider()
207
+ provider = RCTMGLAppleLocationProvider()
88
208
  provider.setDelegate(self)
89
209
  }
90
210
 
@@ -222,6 +342,17 @@ extension LocationProviderRCTMGL: LocationProvider {
222
342
  func setDelegate(_ delegate: LocationProviderDelegate) {
223
343
  provider.setDelegate(self)
224
344
  locationProviderDelage = delegate
345
+
346
+ if let lastLocation = lastKnownLocation {
347
+ DispatchQueue.main.async {
348
+ self.locationProviderDelage?.locationProvider(self, didUpdateLocations: [lastLocation])
349
+ }
350
+ }
351
+ if let lastHeading = lastKnownHeading {
352
+ DispatchQueue.main.async { [self] in
353
+ self.locationProviderDelage?.locationProvider(self, didUpdateHeading: lastHeading)
354
+ }
355
+ }
225
356
  }
226
357
 
227
358
  func requestAlwaysAuthorization() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.12-rc.0",
4
+ "version": "10.0.12-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -20,7 +20,7 @@ require 'json'
20
20
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
21
21
 
22
22
  ## Warning: these lines are scanned by autogenerate.js
23
- rnMapboxMapsDefaultMapboxVersion = '~> 10.14.0'
23
+ rnMapboxMapsDefaultMapboxVersion = '~> 10.15.0'
24
24
  rnMapboxMapsDefaultMapboxGLVersion = '~> 5.9.0'
25
25
  rnMapboxMapsDefaultMapLibreVersion = 'exactVersion 5.12.1'
26
26