@rnmapbox/maps 10.1.25 → 10.1.26

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))
@@ -4,6 +4,42 @@ 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
+ waiters.forEach { $0(object) }
33
+ waiters = []
34
+ }
35
+
36
+ /// reset, calls will be queued again
37
+ func reset() {
38
+ self.object = nil
39
+ }
40
+ }
41
+
42
+
7
43
  /**
8
44
  * Experimental MapView factory for advanced usecases
9
45
  */
@@ -131,8 +167,8 @@ open class RNMBXMapView: UIView {
131
167
  @objc
132
168
  var onCameraChanged: RCTDirectEventBlock?
133
169
 
134
- var styleLoaded: Bool = false
135
- var styleLoadWaiters : [(MapboxMap)->Void] = []
170
+ var styleLoadWaiters = InitWaiter<MapboxMap>()
171
+ var cameraWaiters = InitWaiter<MapView>()
136
172
 
137
173
  var features: [FeatureEntry] = []
138
174
 
@@ -220,7 +256,7 @@ open class RNMBXMapView: UIView {
220
256
  let style = mapView.mapboxMap.style
221
257
  var addToMap = false
222
258
  if mapComponent.waitForStyleLoad() {
223
- if (self.styleLoaded) {
259
+ if (self.styleLoadWaiters.hasInited()) {
224
260
  addToMap = true
225
261
  }
226
262
  } else {
@@ -307,7 +343,7 @@ open class RNMBXMapView: UIView {
307
343
 
308
344
  // MARK: - React Native properties
309
345
  let changes : PropertyChanges<RNMBXMapView> = PropertyChanges()
310
- var mapViewWaiters : [(_: MapView)->Void] = []
346
+ var mapViewWaiters = InitWaiter<MapView>()
311
347
 
312
348
  enum Property : String {
313
349
  case projection
@@ -368,18 +404,14 @@ open class RNMBXMapView: UIView {
368
404
  }
369
405
 
370
406
  func withMapView(callback: @escaping (_: MapView) -> Void) {
371
- if let mapView = _mapView {
372
- callback(mapView)
373
- } else {
374
- mapViewWaiters.append(callback)
375
- }
407
+ mapViewWaiters.callOrWait(callback)
376
408
  }
377
409
 
378
410
  func withMapboxMap(callback: @escaping (_: MapboxMap) -> Void) {
379
411
  if let mapboxMap = _mapView?.mapboxMap {
380
412
  callback(mapboxMap)
381
413
  } else {
382
- mapViewWaiters.append { mapView in
414
+ mapViewWaiters.callOrWait { mapView in
383
415
  callback(mapView.mapboxMap)
384
416
  }
385
417
  }
@@ -714,8 +746,7 @@ open class RNMBXMapView: UIView {
714
746
  if (_mapView == nil) {
715
747
  let view = createMapView()
716
748
 
717
- mapViewWaiters.forEach { $0(view) }
718
- mapViewWaiters.removeAll()
749
+ mapViewWaiters.onInit(view)
719
750
  }
720
751
  changes.apply(self)
721
752
  }
@@ -804,10 +835,11 @@ open class RNMBXMapView: UIView {
804
835
  }
805
836
 
806
837
  public func applyStyleURL() {
807
- var initialLoad = !self.styleLoaded
838
+ var initialLoad = !self.styleLoadWaiters.hasInited()
808
839
  if !initialLoad { refreshComponentsBeforeStyleChange() }
809
- self.styleLoaded = false
810
840
  if let value = reactStyleURL {
841
+ self.styleLoadWaiters.reset()
842
+
811
843
  if let _ = URL(string: value) {
812
844
  if let styleURI = StyleURI(rawValue: value) {
813
845
  mapView.mapboxMap.loadStyleURI(styleURI)
@@ -1059,13 +1091,8 @@ extension RNMBXMapView {
1059
1091
  self.onEvery(event: .styleLoaded, handler: { (self, event) in
1060
1092
  self.addFeaturesToMap(style: self.mapboxMap.style)
1061
1093
 
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
- }
1094
+ if !self.styleLoadWaiters.hasInited(), let mapboxMap = self.mapboxMap {
1095
+ self.styleLoadWaiters.onInit(mapboxMap)
1069
1096
  }
1070
1097
 
1071
1098
  let event = RNMBXEvent(type:.didFinishLoadingStyle, payload: nil)
@@ -1384,11 +1411,7 @@ extension RNMBXMapView {
1384
1411
  fatalError("mapboxMap is null")
1385
1412
  }
1386
1413
 
1387
- if styleLoaded {
1388
- block(mapboxMap)
1389
- } else {
1390
- styleLoadWaiters.append(block)
1391
- }
1414
+ styleLoadWaiters.callOrWait(block)
1392
1415
  }
1393
1416
  }
1394
1417
 
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.26",
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\./