@rnmapbox/maps 10.0.15-rc.0 → 10.1.0-beta.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.
Files changed (89) hide show
  1. package/android/build.gradle +20 -0
  2. package/android/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +109 -12
  3. package/android/src/main/java-v10/com/mapbox/rctmgl/components/AbstractEventEmitter.kt +2 -3
  4. package/android/src/main/java-v10/com/mapbox/rctmgl/components/mapview/NativeMapViewModule.kt +193 -0
  5. package/android/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLAndroidTextureMapViewManager.kt +16 -2
  6. package/android/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +1 -1
  7. package/android/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +75 -160
  8. package/android/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +3 -3
  9. package/android/src/main/java-v10/com/mapbox/rctmgl/mapbox/Light.kt +6 -0
  10. package/android/src/main/old-arch/com/facebook/react/viewmanagers/MBXAndroidTextureMapViewManagerDelegate.java +89 -0
  11. package/android/src/main/old-arch/com/facebook/react/viewmanagers/MBXAndroidTextureMapViewManagerInterface.java +37 -0
  12. package/android/src/main/old-arch/com/facebook/react/viewmanagers/MBXMapViewManagerDelegate.java +89 -0
  13. package/android/src/main/old-arch/com/facebook/react/viewmanagers/MBXMapViewManagerInterface.java +37 -0
  14. package/android/src/main/old-arch/com/mapbox/rctmgl/NativeMapViewModuleSpec.java +88 -0
  15. package/ios/RCTMGL-v10/CustomHttpHeaders.swift +18 -0
  16. package/ios/RCTMGL-v10/MBXMapViewComponentView.h +18 -0
  17. package/ios/RCTMGL-v10/MBXMapViewComponentView.mm +203 -0
  18. package/ios/RCTMGL-v10/MBXMapViewManager.m +37 -0
  19. package/ios/RCTMGL-v10/MBXMapViewManager.swift +250 -0
  20. package/ios/RCTMGL-v10/MBXMapViewModule.h +18 -0
  21. package/ios/RCTMGL-v10/MBXMapViewModule.mm +167 -0
  22. package/ios/RCTMGL-v10/MGLModule.swift +15 -1
  23. package/ios/RCTMGL-v10/MGLSnapshotModule.swift +7 -1
  24. package/ios/RCTMGL-v10/RCTMGLAtmosphere.swift +4 -0
  25. package/ios/RCTMGL-v10/RCTMGLBackgroundLayer.swift +2 -1
  26. package/ios/RCTMGL-v10/RCTMGLCamera.swift +23 -0
  27. package/ios/RCTMGL-v10/RCTMGLCircleLayer.swift +4 -0
  28. package/ios/RCTMGL-v10/RCTMGLFillExtrustionLayer.swift +4 -0
  29. package/ios/RCTMGL-v10/RCTMGLFillLayer.swift +4 -0
  30. package/ios/RCTMGL-v10/RCTMGLHeatmapLayer.swift +4 -1
  31. package/ios/RCTMGL-v10/RCTMGLImageSource.swift +4 -0
  32. package/ios/RCTMGL-v10/RCTMGLImages.swift +14 -2
  33. package/ios/RCTMGL-v10/RCTMGLLayer.swift +35 -11
  34. package/ios/RCTMGL-v10/RCTMGLLight.swift +14 -4
  35. package/ios/RCTMGL-v10/RCTMGLLineLayer.swift +4 -0
  36. package/ios/RCTMGL-v10/RCTMGLLocationModule.swift +65 -12
  37. package/ios/RCTMGL-v10/RCTMGLLocationModuleV11.swift +32 -0
  38. package/ios/RCTMGL-v10/RCTMGLMapView.swift +115 -27
  39. package/ios/RCTMGL-v10/RCTMGLNativeUserLocation.swift +4 -0
  40. package/ios/RCTMGL-v10/RCTMGLOfflineModule.swift +17 -0
  41. package/ios/RCTMGL-v10/RCTMGLRasterDemSource.swift +4 -0
  42. package/ios/RCTMGL-v10/RCTMGLRasterLayer.swift +4 -0
  43. package/ios/RCTMGL-v10/RCTMGLRasterSource.swift +4 -0
  44. package/ios/RCTMGL-v10/RCTMGLShapeSource.swift +65 -3
  45. package/ios/RCTMGL-v10/RCTMGLSource.swift +4 -0
  46. package/ios/RCTMGL-v10/RCTMGLStyleValue.swift +60 -1
  47. package/ios/RCTMGL-v10/RCTMGLSymbolLayer.swift +4 -0
  48. package/ios/RCTMGL-v10/RCTMGLVectorSource.swift +4 -0
  49. package/ios/RCTMGL-v10/rnmapbox_maps.h +1 -0
  50. package/lib/commonjs/components/MapView.js +47 -11
  51. package/lib/commonjs/components/MapView.js.map +1 -1
  52. package/lib/commonjs/specs/MBXAndroidTextureMapViewNativeComponent.js +13 -0
  53. package/lib/commonjs/specs/MBXAndroidTextureMapViewNativeComponent.js.map +1 -0
  54. package/lib/commonjs/specs/MBXMapViewNativeComponent.js +11 -0
  55. package/lib/commonjs/specs/MBXMapViewNativeComponent.js.map +1 -0
  56. package/lib/commonjs/specs/NativeMapViewModule.js +11 -0
  57. package/lib/commonjs/specs/NativeMapViewModule.js.map +1 -0
  58. package/lib/commonjs/specs/codegenUtils.js +2 -0
  59. package/lib/commonjs/specs/codegenUtils.js.map +1 -0
  60. package/lib/module/components/MapView.js +47 -10
  61. package/lib/module/components/MapView.js.map +1 -1
  62. package/lib/module/specs/MBXAndroidTextureMapViewNativeComponent.js +5 -0
  63. package/lib/module/specs/MBXAndroidTextureMapViewNativeComponent.js.map +1 -0
  64. package/lib/module/specs/MBXMapViewNativeComponent.js +3 -0
  65. package/lib/module/specs/MBXMapViewNativeComponent.js.map +1 -0
  66. package/lib/module/specs/NativeMapViewModule.js +5 -0
  67. package/lib/module/specs/NativeMapViewModule.js.map +1 -0
  68. package/lib/module/specs/codegenUtils.js +2 -0
  69. package/lib/module/specs/codegenUtils.js.map +1 -0
  70. package/lib/typescript/components/MapView.d.ts +13 -3
  71. package/lib/typescript/components/MapView.d.ts.map +1 -1
  72. package/lib/typescript/specs/MBXAndroidTextureMapViewNativeComponent.d.ts +52 -0
  73. package/lib/typescript/specs/MBXAndroidTextureMapViewNativeComponent.d.ts.map +1 -0
  74. package/lib/typescript/specs/MBXMapViewNativeComponent.d.ts +52 -0
  75. package/lib/typescript/specs/MBXMapViewNativeComponent.d.ts.map +1 -0
  76. package/lib/typescript/specs/NativeMapViewModule.d.ts +21 -0
  77. package/lib/typescript/specs/NativeMapViewModule.d.ts.map +1 -0
  78. package/lib/typescript/specs/codegenUtils.d.ts +2 -0
  79. package/lib/typescript/specs/codegenUtils.d.ts.map +1 -0
  80. package/package.json +9 -1
  81. package/rnmapbox-maps.podspec +22 -4
  82. package/setup-jest.js +16 -0
  83. package/src/components/MapView.tsx +56 -12
  84. package/src/specs/MBXAndroidTextureMapViewNativeComponent.ts +63 -0
  85. package/src/specs/MBXMapViewNativeComponent.ts +63 -0
  86. package/src/specs/NativeMapViewModule.ts +54 -0
  87. package/src/specs/codegenUtils.ts +4 -0
  88. package/ios/RCTMGL-v10/RCTMGLMapViewManager.m +0 -107
  89. package/ios/RCTMGL-v10/RCTMGLMapViewManager.swift +0 -285
@@ -0,0 +1,32 @@
1
+ #if RNMBX_11
2
+ import MapboxMaps
3
+
4
+ let RCT_MAPBOX_USER_LOCATION_UPDATE = "MapboxUserLocationUpdate";
5
+
6
+ @objc(RCTMGLLocationModule)
7
+ class RCTMGLLocationModule: RCTEventEmitter {
8
+
9
+ static weak var shared : RCTMGLLocationModule? = nil
10
+
11
+ override init() {
12
+ super.init()
13
+ RCTMGLLocationModule.shared = self
14
+ }
15
+
16
+ @objc
17
+ override static func requiresMainQueueSetup() -> Bool {
18
+ return true
19
+ }
20
+
21
+ @objc override func supportedEvents() -> [String]
22
+ {
23
+ return [RCT_MAPBOX_USER_LOCATION_UPDATE];
24
+ }
25
+
26
+ var locationProvider : LocationProvider & HeadingProvider {
27
+ get {
28
+ fatalError("RCTMGLLocationModule.locationProvider not implemented")
29
+ }
30
+ }
31
+ }
32
+ #endif
@@ -14,6 +14,56 @@ class FeatureEntry {
14
14
  }
15
15
  }
16
16
 
17
+
18
+ #if RNMBX_11
19
+ extension QueriedRenderedFeature {
20
+ var feature : Feature { return queriedFeature.feature }
21
+ }
22
+ #else
23
+ typealias QueriedRenderedFeature = QueriedFeature
24
+ #endif
25
+
26
+ #if RNMBX_11
27
+ public struct MapEventType<Payload> {
28
+ var method: (_ map: MapboxMap) -> Signal<Payload>
29
+
30
+ init(_ method: @escaping (MapboxMap) -> Signal<Payload>) {
31
+ self.method = method
32
+ }
33
+
34
+ /// The style has been fully loaded, and the map has rendered all visible tiles.
35
+ public static var mapLoaded: MapEventType<MapLoaded> { .init( \.onMapLoaded ) }
36
+ /// An error that has occurred while loading the Map.
37
+ public static var mapLoadingError: MapEventType<MapLoadingError> { .init(\.onMapLoadingError) }
38
+ /// The requested style has been fully loaded.
39
+ public static var styleLoaded: MapEventType<StyleLoaded> { .init(\.onStyleLoaded) }
40
+ /// The requested style data has been loaded.
41
+ public static var styleDataLoaded: MapEventType<StyleDataLoaded> { .init(\.onStyleDataLoaded) }
42
+ /// The camera has changed.
43
+ public static var cameraChanged: MapEventType<CameraChanged> { .init(\.onCameraChanged) }
44
+ /// The map has entered the idle state.
45
+ public static var mapIdle: MapEventType<MapIdle> { .init(\.onMapIdle) }
46
+ /// The source has been added.
47
+ public static var sourceAdded: MapEventType<SourceAdded> { .init(\.onSourceAdded) }
48
+ /// The source has been removed.
49
+ public static var sourceRemoved: MapEventType<SourceRemoved> { .init(\.onSourceRemoved) }
50
+ /// A source data has been loaded.
51
+ public static var sourceDataLoaded: MapEventType<SourceDataLoaded> { .init(\.onSourceDataLoaded) }
52
+ /// A style has a missing image.
53
+ public static var styleImageMissing: MapEventType<StyleImageMissing> { .init(\.onStyleImageMissing) }
54
+ /// An image added to the style is no longer needed and can be removed.
55
+ public static var styleImageRemoveUnused: MapEventType<StyleImageRemoveUnused> { .init(\.onStyleImageRemoveUnused) }
56
+ /// The map started rendering a frame.
57
+ public static var renderFrameStarted: MapEventType<RenderFrameStarted> { .init(\.onRenderFrameStarted) }
58
+ /// The map finished rendering a frame.
59
+ public static var renderFrameFinished: MapEventType<RenderFrameFinished> { .init(\.onRenderFrameFinished) }
60
+ /// Resource requiest as been made.
61
+ public static var resourceRequest: MapEventType<ResourceRequest> { .init(\.onResourceRequest) }
62
+ }
63
+
64
+ typealias MapLoadingErrorPayload = MapLoadingError
65
+ #endif
66
+
17
67
  class RCTMGLCameraChanged : RCTMGLEvent, RCTEvent {
18
68
  init(type: EventType, payload: [String:Any?]?, reactTag: NSNumber) {
19
69
  super.init(type: type, payload: payload)
@@ -47,7 +97,7 @@ class RCTMGLCameraChanged : RCTMGLEvent, RCTEvent {
47
97
  }
48
98
  }
49
99
 
50
- @objc(RCTMGLMapView)
100
+ @objc(MBXMapView)
51
101
  open class RCTMGLMapView : MapView {
52
102
  var tapDelegate: IgnoreRCTMGLMakerViewGestureDelegate? = nil
53
103
 
@@ -83,6 +133,10 @@ open class RCTMGLMapView : MapView {
83
133
 
84
134
  var layerWaiters : [String:[(String) -> Void]] = [:]
85
135
 
136
+ #if RNMBX_11
137
+ var cancelables = Set<AnyCancelable>()
138
+ #endif
139
+
86
140
  lazy var pointAnnotationManager : PointAnnotationManager = {
87
141
  let result = PointAnnotationManager(annotations: annotations, mapView: mapView)
88
142
  self._removeMapboxLongPressGestureRecognizer()
@@ -153,9 +207,14 @@ open class RCTMGLMapView : MapView {
153
207
  }
154
208
 
155
209
  public required init(frame:CGRect, eventDispatcher: RCTEventDispatcherProtocol) {
210
+ #if RNMBX_11
211
+ self.eventDispatcher = eventDispatcher
212
+ super.init(frame: frame, mapInitOptions: MapInitOptions())
213
+ #else
156
214
  let resourceOptions = ResourceOptions(accessToken: MGLModule.accessToken!)
157
215
  self.eventDispatcher = eventDispatcher
158
216
  super.init(frame: frame, mapInitOptions: MapInitOptions(resourceOptions: resourceOptions))
217
+ #endif
159
218
 
160
219
  self.mapView.gestures.delegate = self
161
220
 
@@ -193,14 +252,14 @@ open class RCTMGLMapView : MapView {
193
252
 
194
253
  // MARK: - React Native properties
195
254
 
196
- @objc func setReactProjection(_ value: String?) {
255
+ @objc public func setReactProjection(_ value: String?) {
197
256
  if let value = value {
198
257
  let projection = StyleProjection(name: value == "globe" ? .globe : .mercator)
199
258
  try! self.mapboxMap.style.setProjection(projection)
200
259
  }
201
260
  }
202
261
 
203
- @objc func setReactLocalizeLabels(_ value: NSDictionary?) {
262
+ @objc public func setReactLocalizeLabels(_ value: NSDictionary?) {
204
263
  onMapStyleLoaded { _ in
205
264
  if let value = value {
206
265
  logged("RCTMGLMapVIew.setReactLocalizeLabels") {
@@ -214,34 +273,34 @@ open class RCTMGLMapView : MapView {
214
273
  }
215
274
 
216
275
 
217
- @objc func setReactAttributionEnabled(_ value: Bool) {
276
+ @objc public func setReactAttributionEnabled(_ value: Bool) {
218
277
  mapView.ornaments.options.attributionButton.visibility = value ? .visible : .hidden
219
278
  }
220
279
 
221
- @objc func setReactAttributionPosition(_ position: [String: NSNumber]) {
280
+ @objc public func setReactAttributionPosition(_ position: [String: NSNumber]) {
222
281
  if let ornamentOptions = self.getOrnamentOptionsFromPosition(position) {
223
282
  mapView.ornaments.options.attributionButton.position = ornamentOptions.position
224
283
  mapView.ornaments.options.attributionButton.margins = ornamentOptions.margins
225
284
  }
226
285
  }
227
286
 
228
- @objc func setReactLogoEnabled(_ value: Bool) {
287
+ @objc public func setReactLogoEnabled(_ value: Bool) {
229
288
  mapView.ornaments.options.logo.visibility = value ? .visible : .hidden
230
289
  }
231
290
 
232
- @objc func setReactLogoPosition(_ position: [String: NSNumber]) {
291
+ @objc public func setReactLogoPosition(_ position: [String: NSNumber]) {
233
292
  if let ornamentOptions = self.getOrnamentOptionsFromPosition(position) {
234
293
  mapView.ornaments.options.logo.position = ornamentOptions.position
235
294
  mapView.ornaments.options.logo.margins = ornamentOptions.margins
236
295
  }
237
296
  }
238
297
 
239
- @objc func setReactCompassEnabled(_ value: Bool) {
298
+ @objc public func setReactCompassEnabled(_ value: Bool) {
240
299
  compassEnabled = value
241
300
  refreshCompassVisibility()
242
301
  }
243
302
 
244
- @objc func setReactCompassFadeWhenNorth(_ value: Bool) {
303
+ @objc public func setReactCompassFadeWhenNorth(_ value: Bool) {
245
304
  compassFadeWhenNorth = value
246
305
  refreshCompassVisibility()
247
306
  }
@@ -256,7 +315,7 @@ open class RCTMGLMapView : MapView {
256
315
  refreshCompassImage()
257
316
  }
258
317
 
259
- @objc func setReactCompassPosition(_ position: [String: NSNumber]) {
318
+ @objc public func setReactCompassPosition(_ position: [String: NSNumber]) {
260
319
  if let ornamentOptions = self.getOrnamentOptionsFromPosition(position) {
261
320
  mapView.ornaments.options.compass.position = ornamentOptions.position
262
321
  mapView.ornaments.options.compass.margins = ornamentOptions.margins
@@ -286,15 +345,15 @@ open class RCTMGLMapView : MapView {
286
345
  }
287
346
  }
288
347
 
289
- @objc func setReactCompassViewPosition(_ position: NSInteger) {
348
+ @objc public func setReactCompassViewPosition(_ position: NSInteger) {
290
349
  mapView.ornaments.options.compass.position = toOrnamentPositon(Int(truncating: NSNumber(value: position)))
291
350
  }
292
351
 
293
- @objc func setReactCompassViewMargins(_ margins: CGPoint) {
352
+ @objc public func setReactCompassViewMargins(_ margins: CGPoint) {
294
353
  mapView.ornaments.options.compass.margins = margins;
295
354
  }
296
355
 
297
- @objc func setReactCompassImage(_ image: String) {
356
+ @objc public func setReactCompassImage(_ image: String) {
298
357
  compassImage = image.isEmpty ? nil : image
299
358
  refreshCompassImage()
300
359
  }
@@ -312,33 +371,33 @@ open class RCTMGLMapView : MapView {
312
371
  }
313
372
  }
314
373
 
315
- @objc func setReactScaleBarEnabled(_ value: Bool) {
374
+ @objc public func setReactScaleBarEnabled(_ value: Bool) {
316
375
  self.mapView.ornaments.options.scaleBar.visibility = value ? .visible : .hidden
317
376
  }
318
377
 
319
- @objc func setReactScaleBarPosition(_ position: [String: NSNumber]) {
378
+ @objc public func setReactScaleBarPosition(_ position: [String: NSNumber]) {
320
379
  if let ornamentOptions = self.getOrnamentOptionsFromPosition(position) {
321
380
  mapView.ornaments.options.scaleBar.position = ornamentOptions.position
322
381
  mapView.ornaments.options.scaleBar.margins = ornamentOptions.margins
323
382
  }
324
383
  }
325
384
 
326
- @objc func setReactZoomEnabled(_ value: Bool) {
385
+ @objc public func setReactZoomEnabled(_ value: Bool) {
327
386
  self.mapView.gestures.options.quickZoomEnabled = value
328
387
  self.mapView.gestures.options.doubleTapToZoomInEnabled = value
329
388
  self.mapView.gestures.options.pinchZoomEnabled = value
330
389
  }
331
390
 
332
- @objc func setReactScrollEnabled(_ value: Bool) {
391
+ @objc public func setReactScrollEnabled(_ value: Bool) {
333
392
  self.mapView.gestures.options.panEnabled = value
334
393
  self.mapView.gestures.options.pinchPanEnabled = value
335
394
  }
336
395
 
337
- @objc func setReactRotateEnabled(_ value: Bool) {
396
+ @objc public func setReactRotateEnabled(_ value: Bool) {
338
397
  self.mapView.gestures.options.rotateEnabled = value
339
398
  }
340
399
 
341
- @objc func setReactPitchEnabled(_ value: Bool) {
400
+ @objc public func setReactPitchEnabled(_ value: Bool) {
342
401
  self.mapView.gestures.options.pitchEnabled = value
343
402
  }
344
403
 
@@ -368,7 +427,7 @@ open class RCTMGLMapView : MapView {
368
427
  addFeaturesToMap(style: style)
369
428
  }
370
429
 
371
- @objc func setReactStyleURL(_ value: String?) {
430
+ @objc public func setReactStyleURL(_ value: String?) {
372
431
  var initialLoad = !self.styleLoaded
373
432
  if !initialLoad { refreshComponentsBeforeStyleChange() }
374
433
  self.styleLoaded = false
@@ -426,6 +485,25 @@ open class RCTMGLMapView : MapView {
426
485
  // MARK: - event handlers
427
486
 
428
487
  extension RCTMGLMapView {
488
+ #if RNMBX_11
489
+ private func onEvery<T>(event: MapEventType<T>, handler: @escaping (RCTMGLMapView, T) -> Void) {
490
+ let signal = event.method(self.mapView.mapboxMap)
491
+ signal.observe { [weak self] (mapEvent) in
492
+ guard let self = self else { return }
493
+
494
+ handler(self, mapEvent)
495
+ }.store(in: &cancelables)
496
+ }
497
+
498
+ private func onNext<T>(event: MapEventType<T>, handler: @escaping (RCTMGLMapView, T) -> Void) {
499
+ let signal = event.method(self.mapView.mapboxMap)
500
+ signal.observeNext { [weak self] (mapEvent) in
501
+ guard let self = self else { return }
502
+
503
+ handler(self, mapEvent)
504
+ }.store(in: &cancelables)
505
+ }
506
+ #else
429
507
  private func onEvery<Payload>(event: MapEvents.Event<Payload>, handler: @escaping (RCTMGLMapView, MapEvent<Payload>) -> Void) {
430
508
  let eventListener = self.mapView.mapboxMap.onEvery(event: event) { [weak self](mapEvent) in
431
509
  guard let self = self else { return }
@@ -445,8 +523,9 @@ extension RCTMGLMapView {
445
523
  handler(self, mapEvent)
446
524
  }
447
525
  }
526
+ #endif
448
527
 
449
- @objc func setReactOnMapChange(_ value: @escaping RCTBubblingEventBlock) {
528
+ @objc public func setReactOnMapChange(_ value: @escaping RCTBubblingEventBlock) {
450
529
  self.reactOnMapChange = value
451
530
 
452
531
  self.onEvery(event: .cameraChanged, handler: { (self, cameraEvent) in
@@ -538,8 +617,13 @@ extension RCTMGLMapView {
538
617
  public func setupEvents() {
539
618
  self.onEvery(event: .mapLoadingError, handler: { (self, event) in
540
619
  let eventPayload : MapLoadingErrorPayload = event.payload
620
+ #if RNMBX_11
621
+ let error = eventPayload
622
+ #else
623
+ let error = eventPayload.error
624
+ #endif
541
625
  var payload : [String:String] = [
542
- "error": eventPayload.error.errorDescription ?? eventPayload.error.localizedDescription
626
+ "error": error.errorDescription ?? error.localizedDescription
543
627
  ]
544
628
  if let tileId = eventPayload.tileId {
545
629
  payload["tileId"] = "x:\(tileId.x) y:\(tileId.y) z:\(tileId.z)"
@@ -550,7 +634,7 @@ extension RCTMGLMapView {
550
634
  let rctmglEvent = RCTMGLEvent(type: .mapLoadingError, payload: payload);
551
635
  self.fireEvent(event: rctmglEvent, callback: self.reactOnMapChange)
552
636
 
553
- if let message = eventPayload.error.errorDescription {
637
+ if let message = error.errorDescription {
554
638
  Logger.log(level: .error, message: "MapLoad error \(message)")
555
639
  } else {
556
640
  Logger.log(level: .error, message: "MapLoad error \(event)")
@@ -664,7 +748,7 @@ class IgnoreRCTMGLMakerViewGestureDelegate : NSObject, UIGestureRecognizerDelega
664
748
 
665
749
  extension RCTMGLMapView {
666
750
 
667
- @objc func setReactOnPress(_ value: @escaping RCTBubblingEventBlock) {
751
+ @objc public func setReactOnPress(_ value: @escaping RCTBubblingEventBlock) {
668
752
  self.reactOnPress = value
669
753
 
670
754
  let singleTapGestureRecognizer = self.mapView.gestures.singleTapGestureRecognizer
@@ -676,7 +760,7 @@ extension RCTMGLMapView {
676
760
  singleTapGestureRecognizer.delegate = tapDelegate
677
761
  }
678
762
 
679
- @objc func setReactOnLongPress(_ value: @escaping RCTBubblingEventBlock) {
763
+ @objc public func setReactOnLongPress(_ value: @escaping RCTBubblingEventBlock) {
680
764
  self.reactOnLongPress = value
681
765
 
682
766
  let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(doHandleLongPress(_:)))
@@ -692,7 +776,7 @@ extension RCTMGLMapView: GestureManagerDelegate {
692
776
  return sources.filter { $0.isTouchable() }
693
777
  }
694
778
 
695
- private func doHandleTapInSources(sources: [RCTMGLInteractiveElement], tapPoint: CGPoint, hits: [String: [QueriedFeature]], touchedSources: [RCTMGLInteractiveElement], callback: @escaping (_ hits: [String: [QueriedFeature]], _ touchedSources: [RCTMGLInteractiveElement]) -> Void) {
779
+ private func doHandleTapInSources(sources: [RCTMGLInteractiveElement], tapPoint: CGPoint, hits: [String: [QueriedRenderedFeature]], touchedSources: [RCTMGLInteractiveElement], callback: @escaping (_ hits: [String: [QueriedRenderedFeature]], _ touchedSources: [RCTMGLInteractiveElement]) -> Void) {
696
780
  DispatchQueue.main.async {
697
781
  if let source = sources.first {
698
782
  let hitbox = source.hitbox;
@@ -864,7 +948,7 @@ extension RCTMGLMapView: GestureManagerDelegate {
864
948
 
865
949
  extension RCTMGLMapView
866
950
  {
867
- @objc func takeSnap(
951
+ @objc public func takeSnap(
868
952
  writeToDisk:Bool) -> URL
869
953
  {
870
954
  UIGraphicsBeginImageContextWithOptions(self.bounds.size, true, 0);
@@ -905,6 +989,9 @@ extension RCTMGLMapView {
905
989
  let layer = logged("setSourceVisibility.layer", info: { "\(layerInfo.id)" }) {
906
990
  try style.layer(withId: layerInfo.id)
907
991
  }
992
+ #if RNMBX_11
993
+ // RNMBX_11_TODO
994
+ #else
908
995
  if let layer = layer {
909
996
  if layer.source == sourceId {
910
997
  var good = true
@@ -922,6 +1009,7 @@ extension RCTMGLMapView {
922
1009
  }
923
1010
  }
924
1011
  }
1012
+ #endif
925
1013
  }
926
1014
  }
927
1015
  }
@@ -18,7 +18,11 @@ class RCTMGLNativeUserLocation : UIView, RCTMGLMapComponent {
18
18
  func _applySettings(_ map: RCTMGLMapView) {
19
19
  map.location.options.puckType = .puck2D(.makeDefault(showBearing: iosShowsUserHeadingIndicator))
20
20
  if (iosShowsUserHeadingIndicator) {
21
+ #if RNMBX_11
22
+ map.location.options.puckBearing = .heading
23
+ #else
21
24
  map.location.options.puckBearingSource = .heading
25
+ #endif
22
26
  map.location.options.puckBearingEnabled = true
23
27
  } else {
24
28
  map.location.options.puckBearingEnabled = false
@@ -33,11 +33,19 @@ class RCTMGLOfflineModule: RCTEventEmitter {
33
33
  }
34
34
 
35
35
  lazy var offlineManager : OfflineManager = {
36
+ #if RNMBX_11
37
+ return OfflineManager()
38
+ #else
36
39
  return OfflineManager(resourceOptions: .init(accessToken: MGLModule.accessToken!))
40
+ #endif
37
41
  }()
38
42
 
39
43
  lazy var offlineRegionManager: OfflineRegionManager = {
44
+ #if RNMBX_11
45
+ return OfflineRegionManager()
46
+ #else
40
47
  return OfflineRegionManager(resourceOptions: .init(accessToken: MGLModule.accessToken!))
48
+ #endif
41
49
  }()
42
50
 
43
51
  lazy var tileStore : TileStore = {
@@ -350,11 +358,20 @@ class RCTMGLOfflineModule: RCTEventEmitter {
350
358
 
351
359
  let stylePackLoadOptions = StylePackLoadOptions(glyphsRasterizationMode: .ideographsRasterizedLocally, metadata: pack.metadata)
352
360
 
361
+ #if RNMBX_11
353
362
  let descriptorOptions = TilesetDescriptorOptions(
354
363
  styleURI: styleURI,
355
364
  zoomRange: zoomRange,
365
+ tilesets: [], // RNMBX_11_TODO
356
366
  stylePackOptions: stylePackLoadOptions
357
367
  )
368
+ #else
369
+ let descriptorOptions = TilesetDescriptorOptions(
370
+ styleURI: styleURI,
371
+ zoomRange: zoomRange,
372
+ stylePackOptions: stylePackLoadOptions
373
+ )
374
+ #endif
358
375
  let tilesetDescriptor = self.offlineManager.createTilesetDescriptor(for: descriptorOptions)
359
376
 
360
377
  let loadOptions = TileRegionLoadOptions(
@@ -30,7 +30,11 @@ class RCTMGLRasterDemSource : RCTMGLSource {
30
30
 
31
31
  override func makeSource() -> Source
32
32
  {
33
+ #if RNMBX_11 // RNMBX_11_TODO
34
+ var result = SourceType(id: "raster-dem-source-id-todo")
35
+ #else
33
36
  var result = SourceType()
37
+ #endif
34
38
  if let url = url {
35
39
  result.url = url
36
40
  } else if let tileUrlTemplates = tileUrlTemplates {
@@ -6,7 +6,11 @@ class RCTMGLRasterLayer: RCTMGLLayer {
6
6
 
7
7
  override func makeLayer(style: Style) throws -> Layer {
8
8
  // let source : ImageSource = try self.sourceWithSourceID(in: style)
9
+ #if RNMBX_11
10
+ var layer = LayerType(id: self.id!, source: sourceID!)
11
+ #else
9
12
  var layer = LayerType(id: self.id!)
13
+ #endif
10
14
  layer.source = sourceID
11
15
  return layer
12
16
  }
@@ -18,7 +18,11 @@ class RCTMGLRasterSource : RCTMGLSource {
18
18
 
19
19
  override func makeSource() -> Source
20
20
  {
21
+ #if RNMBX_11
22
+ var result = RasterSource(id: self.id)
23
+ #else
21
24
  var result = RasterSource()
25
+ #endif
22
26
  if let url = url {
23
27
  result.url = url
24
28
  } else {
@@ -65,7 +65,11 @@ class RCTMGLShapeSource : RCTMGLSource {
65
65
 
66
66
  override func makeSource() -> Source
67
67
  {
68
+ #if RNMBX_11
69
+ var result = GeoJSONSource(id: id)
70
+ #else
68
71
  var result = GeoJSONSource()
72
+ #endif
69
73
 
70
74
  if let shape = shape {
71
75
  do {
@@ -211,8 +215,14 @@ extension RCTMGLShapeSource
211
215
  return .featureCollection(featureCollection)
212
216
  case .geometry(let geometry):
213
217
  return .geometry(geometry)
218
+ #if RNMBX_11
219
+ case .string(_):
220
+ // RNMBX_11_TODO
221
+ throw RCTMGLError.parseError("url as shape is not supported when updating a ShapeSource")
222
+ #else
214
223
  case .url(_):
215
224
  throw RCTMGLError.parseError("url as shape is not supported when updating a ShapeSource")
225
+ #endif
216
226
  }
217
227
  }
218
228
 
@@ -243,6 +253,58 @@ extension RCTMGLShapeSource
243
253
  }
244
254
  }
245
255
 
256
+ #if !RNMBX_11
257
+ class DummyCancellable : Cancelable {
258
+ func cancel() {}
259
+ }
260
+
261
+ #if false
262
+ extension MapboxMap {
263
+ @discardableResult
264
+ public func getGeoJsonClusterExpansionZoom(forSourceId sourceId: String,
265
+ feature: Feature,
266
+ completion: @escaping (Result<FeatureExtensionValue, Error>) -> Void) -> Cancelable {
267
+ self.queryFeatureExtension(for: sourceId,
268
+ feature: feature,
269
+ extension: "supercluster",
270
+ extensionField: "expansion-zoom",
271
+ args: nil,
272
+ completion: completion)
273
+ return DummyCancellable()
274
+ }
275
+ @discardableResult
276
+ public func getGeoJsonClusterChildren(forSourceId sourceId: String,
277
+ feature: Feature,
278
+ completion: @escaping (Result<FeatureExtensionValue, Error>) -> Void) -> Cancelable {
279
+ self.queryFeatureExtension(for: sourceId,
280
+ feature: feature,
281
+ extension: "supercluster",
282
+ extensionField: "children",
283
+ args: nil,
284
+ completion: completion)
285
+ return DummyCancellable()
286
+ }
287
+
288
+ @discardableResult
289
+ public func getGeoJsonClusterLeaves(forSourceId sourceId: String,
290
+ feature: Feature,
291
+ limit: UInt64 = 10,
292
+ offset: UInt64 = 0,
293
+ completion: @escaping (Result<FeatureExtensionValue, Error>) -> Void) -> Cancelable {
294
+ self.queryFeatureExtension(for: sourceId,
295
+ feature: /*MapboxCommon.Feature(*/feature/*)*/,
296
+ extension: "supercluster",
297
+ extensionField: "leaves",
298
+ args: ["limit": limit, "offset": offset],
299
+ completion: completion)
300
+ return DummyCancellable()
301
+ }
302
+
303
+
304
+ }
305
+ #endif
306
+ #endif
307
+
246
308
  // MARK: - getClusterExpansionZoom/getClusterLeaves
247
309
 
248
310
  extension RCTMGLShapeSource
@@ -261,7 +323,7 @@ extension RCTMGLShapeSource
261
323
  }) {
262
324
  let cluster : Feature = try parse(featureJSON);
263
325
 
264
- mapView.mapboxMap.queryFeatureExtension(for: self.id, feature: cluster, extension: "supercluster", extensionField: "expansion-zoom") { result in
326
+ mapView.mapboxMap.getGeoJsonClusterExpansionZoom(forSourceId: self.id, feature: cluster) { result in
265
327
  switch result {
266
328
  case .success(let features):
267
329
  guard let value = features.value as? NSNumber else {
@@ -291,7 +353,7 @@ extension RCTMGLShapeSource
291
353
  completion(.failure(error!))
292
354
  }) {
293
355
  let cluster : Feature = try parse(featureJSON);
294
- mapView.mapboxMap.queryFeatureExtension(for: self.id, feature: cluster, extension: "supercluster", extensionField: "leaves", args: ["limit": UInt64(number),"offset": UInt64(offset)]) {
356
+ mapView.mapboxMap.getGeoJsonClusterLeaves(forSourceId: self.id, feature: cluster, limit: UInt64(number), offset: UInt64(offset)) {
295
357
  result in
296
358
  switch result {
297
359
  case .success(let features):
@@ -313,7 +375,7 @@ extension RCTMGLShapeSource
313
375
  completion(.failure(error!))
314
376
  }) {
315
377
  let cluster : Feature = try parse(featureJSON);
316
- mapView.mapboxMap.queryFeatureExtension(for: self.id, feature: cluster, extension: "supercluster", extensionField: "children") {
378
+ mapView.mapboxMap.getGeoJsonClusterChildren(forSourceId: self.id, feature: cluster) {
317
379
  result in
318
380
  switch result {
319
381
  case .success(let features):
@@ -83,7 +83,11 @@ class RCTMGLSource : RCTMGLInteractiveElement {
83
83
  self.ownsSource = true
84
84
  self.source = source
85
85
  logged("SyleSource.addToMap", info: {"id: \(optional: self.id)"}) {
86
+ #if RNMBX_11
87
+ try style.addSource(source)
88
+ #else
86
89
  try style.addSource(source, id: self.id)
90
+ #endif
87
91
  }
88
92
  }
89
93