@rnmapbox/maps 10.1.25 → 10.1.27

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 = "mapbox"
2
- def defaultMapboxMapsVersion = "10.17.0"
2
+ def defaultMapboxMapsVersion = "10.18.0"
3
3
 
4
4
  def safeExtGet(prop, fallback) {
5
5
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -46,7 +46,7 @@ Set `RNMapboxMapsVersion` in `android/build.gradle > buildscript > ext` section
46
46
  ```groovy
47
47
  buildscript {
48
48
  ext {
49
- RNMapboxMapsVersion = '11.3.0'
49
+ RNMapboxMapsVersion = '11.4.1'
50
50
  }
51
51
  }
52
52
  ```
@@ -70,7 +70,7 @@ buildscript {
70
70
  ```groovy
71
71
  buildscript {
72
72
  ext {
73
- RNMapboxMapsVersion = '11.3.0'
73
+ RNMapboxMapsVersion = '11.4.1'
74
74
  }
75
75
  }
76
76
  ```
@@ -152,6 +152,14 @@ class NativeMapViewModule(context: ReactApplicationContext, val viewTagResolver:
152
152
  }
153
153
  }
154
154
 
155
+ public fun setHandledMapChangedEvents(
156
+ viewRef: Double?,
157
+ events: ReadableArray,
158
+ promise: Promise
159
+ ) {
160
+ setHandledMapChangedEvents(viewRef?.toInt(), events, promise)
161
+ }
162
+
155
163
  override fun clearData(viewRef: ViewRefTag?, promise: Promise) {
156
164
  withMapViewOnUIThread(viewRef, promise) {
157
165
  it.clearData(createCommandResponse(promise))
@@ -521,7 +521,7 @@ class RNMBXLocationModule: RCTEventEmitter, LocationProviderRNMBXDelegate {
521
521
  locationProvider.setDistanceFilter(minDisplacement)
522
522
  }
523
523
  }
524
-
524
+
525
525
  @objc func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) {
526
526
  if let locationProvider = locationProvider as? LocationProviderRNMBX {
527
527
  locationProvider.setRequestsAlwaysUse(requestsAlwaysUse)
@@ -276,7 +276,15 @@ class RNMBXLocationModule: RCTEventEmitter {
276
276
  throttler.waitBetweenEvents = nil
277
277
  }
278
278
  }
279
-
279
+
280
+ @objc func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) {
281
+ // V11TODO
282
+ }
283
+
284
+ @objc func simulateHeading(_ changesPerSecond: NSNumber, increment: NSNumber) {
285
+ // V11TODO
286
+ }
287
+
280
288
  @objc
281
289
  override func startObserving() {
282
290
  super.startObserving()
@@ -4,6 +4,43 @@ import MapKit
4
4
 
5
5
  public typealias RNMBXMapViewFactoryFunc = (String, UIView) -> (MapView?)
6
6
 
7
+ /**
8
+ * InitWaiter: simple waiters gets queued unitl the init happens
9
+ */
10
+ class InitWaiter<Type> {
11
+ var object: Type? = nil;
12
+ typealias Callback = (_ t:Type) -> Void;
13
+ var waiters: [Callback] = []
14
+
15
+ /// if the object has value call immediately, otherwise queue
16
+ func callOrWait(_ callback: @escaping Callback) {
17
+ if let object = object {
18
+ callback(object)
19
+ assert(waiters.count == 0, "the object is inited but there are still waiters")
20
+ } else {
21
+ waiters.append(callback)
22
+ }
23
+ }
24
+
25
+ func hasInited() -> Bool {
26
+ return object != nil
27
+ }
28
+
29
+ /// call whan the object has inited, queued calls will be executed
30
+ func onInit(_ object: Type) {
31
+ self.object = object
32
+ let oldWaiters = waiters
33
+ waiters = []
34
+ oldWaiters.forEach { $0(object) }
35
+ }
36
+
37
+ /// reset, calls will be queued again
38
+ func reset() {
39
+ self.object = nil
40
+ }
41
+ }
42
+
43
+
7
44
  /**
8
45
  * Experimental MapView factory for advanced usecases
9
46
  */
@@ -131,8 +168,8 @@ open class RNMBXMapView: UIView {
131
168
  @objc
132
169
  var onCameraChanged: RCTDirectEventBlock?
133
170
 
134
- var styleLoaded: Bool = false
135
- var styleLoadWaiters : [(MapboxMap)->Void] = []
171
+ var styleLoadWaiters = InitWaiter<MapboxMap>()
172
+ var cameraWaiters = InitWaiter<MapView>()
136
173
 
137
174
  var features: [FeatureEntry] = []
138
175
 
@@ -220,7 +257,7 @@ open class RNMBXMapView: UIView {
220
257
  let style = mapView.mapboxMap.style
221
258
  var addToMap = false
222
259
  if mapComponent.waitForStyleLoad() {
223
- if (self.styleLoaded) {
260
+ if (self.styleLoadWaiters.hasInited()) {
224
261
  addToMap = true
225
262
  }
226
263
  } else {
@@ -307,7 +344,7 @@ open class RNMBXMapView: UIView {
307
344
 
308
345
  // MARK: - React Native properties
309
346
  let changes : PropertyChanges<RNMBXMapView> = PropertyChanges()
310
- var mapViewWaiters : [(_: MapView)->Void] = []
347
+ var mapViewWaiters = InitWaiter<MapView>()
311
348
 
312
349
  enum Property : String {
313
350
  case projection
@@ -368,18 +405,14 @@ open class RNMBXMapView: UIView {
368
405
  }
369
406
 
370
407
  func withMapView(callback: @escaping (_: MapView) -> Void) {
371
- if let mapView = _mapView {
372
- callback(mapView)
373
- } else {
374
- mapViewWaiters.append(callback)
375
- }
408
+ mapViewWaiters.callOrWait(callback)
376
409
  }
377
410
 
378
411
  func withMapboxMap(callback: @escaping (_: MapboxMap) -> Void) {
379
412
  if let mapboxMap = _mapView?.mapboxMap {
380
413
  callback(mapboxMap)
381
414
  } else {
382
- mapViewWaiters.append { mapView in
415
+ mapViewWaiters.callOrWait { mapView in
383
416
  callback(mapView.mapboxMap)
384
417
  }
385
418
  }
@@ -714,8 +747,7 @@ open class RNMBXMapView: UIView {
714
747
  if (_mapView == nil) {
715
748
  let view = createMapView()
716
749
 
717
- mapViewWaiters.forEach { $0(view) }
718
- mapViewWaiters.removeAll()
750
+ mapViewWaiters.onInit(view)
719
751
  }
720
752
  changes.apply(self)
721
753
  }
@@ -804,10 +836,11 @@ open class RNMBXMapView: UIView {
804
836
  }
805
837
 
806
838
  public func applyStyleURL() {
807
- var initialLoad = !self.styleLoaded
839
+ var initialLoad = !self.styleLoadWaiters.hasInited()
808
840
  if !initialLoad { refreshComponentsBeforeStyleChange() }
809
- self.styleLoaded = false
810
841
  if let value = reactStyleURL {
842
+ self.styleLoadWaiters.reset()
843
+
811
844
  if let _ = URL(string: value) {
812
845
  if let styleURI = StyleURI(rawValue: value) {
813
846
  mapView.mapboxMap.loadStyleURI(styleURI)
@@ -1059,13 +1092,8 @@ extension RNMBXMapView {
1059
1092
  self.onEvery(event: .styleLoaded, handler: { (self, event) in
1060
1093
  self.addFeaturesToMap(style: self.mapboxMap.style)
1061
1094
 
1062
- if !self.styleLoaded {
1063
- self.styleLoaded = true
1064
- if let mapboxMap = self.mapboxMap {
1065
- let waiters = self.styleLoadWaiters
1066
- self.styleLoadWaiters = []
1067
- waiters.forEach { $0(mapboxMap) }
1068
- }
1095
+ if !self.styleLoadWaiters.hasInited(), let mapboxMap = self.mapboxMap {
1096
+ self.styleLoadWaiters.onInit(mapboxMap)
1069
1097
  }
1070
1098
 
1071
1099
  let event = RNMBXEvent(type:.didFinishLoadingStyle, payload: nil)
@@ -1384,11 +1412,7 @@ extension RNMBXMapView {
1384
1412
  fatalError("mapboxMap is null")
1385
1413
  }
1386
1414
 
1387
- if styleLoaded {
1388
- block(mapboxMap)
1389
- } else {
1390
- styleLoadWaiters.append(block)
1391
- }
1415
+ styleLoadWaiters.callOrWait(block)
1392
1416
  }
1393
1417
  }
1394
1418
 
package/ios/install.md CHANGED
@@ -69,7 +69,7 @@ We have support for mapbox 11.
69
69
  Add the following to your Podfile:
70
70
 
71
71
  ```ruby
72
- $RNMapboxMapsVersion = '= 11.3.0'
72
+ $RNMapboxMapsVersion = '= 11.4.0'
73
73
  ```
74
74
 
75
75
  If using expo managed workflow, set the "RNMapboxMapsVersion" variable. See the [expo guide](/plugin/install.md)
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.1.25",
4
+ "version": "10.1.27",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/plugin/install.md CHANGED
@@ -20,7 +20,7 @@ After installing this package, add the [config plugin](https://docs.expo.io/guid
20
20
  [
21
21
  "@rnmapbox/maps",
22
22
  {
23
- "RNMapboxMapsVersion": "11.3.0"
23
+ "RNMapboxMapsVersion": "11.4.0"
24
24
  }
25
25
  ]
26
26
  ]
@@ -93,7 +93,7 @@ To use V11 just set the version to a 11 version, see [the ios guide](/ios/instal
93
93
  [
94
94
  "@rnmapbox/maps",
95
95
  {
96
- "RNMapboxMapsVersion": "11.3.0",
96
+ "RNMapboxMapsVersion": "11.4.0",
97
97
  "RNMapboxMapsDownloadToken": "sk.ey...qg",
98
98
  }
99
99
  ]
@@ -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.17.0'
23
+ rnMapboxMapsDefaultMapboxVersion = '~> 10.18.2'
24
24
 
25
25
  rnMapboxMapsDefaultImpl = 'mapbox'
26
26
 
@@ -75,7 +75,7 @@ else
75
75
  end
76
76
 
77
77
  if $RNMapboxMapsUseV11 != nil
78
- warn "WARNING: $RNMapboxMapsUseV11 is deprecated just set $RNMapboxMapsVersion to '= 11.0.0"
78
+ warn "WARNING: $RNMapboxMapsUseV11 is deprecated just set $RNMapboxMapsVersion to '= 11.4.0"
79
79
  end
80
80
 
81
81
  if $MapboxImplVersion =~ /(~>|>=|=|>)?\S*11\./