@rnmapbox/maps 10.2.7 → 10.2.8
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/android/build.gradle +9 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt +8 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt +7 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt +180 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleValue.kt +4 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXModule.kt +2 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXOfflineModuleLegacy.kt +10 -0
- package/android/src/main/mapbox-v11-compat/v10/com/mapbox/maps/extension/style/layers/generated/RasterParticleLayer.kt +58 -0
- package/android/src/main/mapbox-v11-compat/v10/com/mapbox/maps/extension/style/sources/generated/RasterArraySource.kt +20 -0
- package/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/components/styles/layers/RNMBXRasterParticleLayer.kt +22 -0
- package/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/components/styles/layers/RNMBXRasterParticleLayerManager.kt +59 -0
- package/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterArraySource.kt +16 -0
- package/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterArraySourceManager.kt +59 -0
- package/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/v11compat/StyleFactory.kt +45 -0
- package/android/src/main/mapbox-v11-compat/v11/com/rnmapbox/rnmbx/components/styles/layers/RNMBXRasterParticleLayer.kt +38 -0
- package/android/src/main/mapbox-v11-compat/v11/com/rnmapbox/rnmbx/components/styles/layers/RNMBXRasterParticleLayerManager.kt +85 -0
- package/android/src/main/mapbox-v11-compat/v11/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterArraySource.kt +41 -0
- package/android/src/main/mapbox-v11-compat/v11/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterArraySourceManager.kt +76 -0
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXRasterArraySourceManagerDelegate.java +54 -0
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXRasterArraySourceManagerInterface.java +23 -0
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXRasterParticleLayerManagerDelegate.java +66 -0
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXRasterParticleLayerManagerInterface.java +27 -0
- package/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.m +2 -0
- package/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift +5 -0
- package/ios/RNMBX/RNMBXCamera.swift +88 -17
- package/ios/RNMBX/RNMBXCameraModule.h +3 -2
- package/ios/RNMBX/RNMBXCameraModule.mm +8 -16
- package/ios/RNMBX/RNMBXCustomLocationProvider.swift +18 -24
- package/ios/RNMBX/RNMBXImageModule.h +3 -2
- package/ios/RNMBX/RNMBXImageModule.mm +8 -16
- package/ios/RNMBX/RNMBXImages.swift +1 -4
- package/ios/RNMBX/RNMBXInteractiveElement.swift +22 -15
- package/ios/RNMBX/RNMBXMapView.swift +68 -6
- package/ios/RNMBX/RNMBXNativeUserLocation.swift +6 -6
- package/ios/RNMBX/RNMBXPointAnnotation.swift +6 -8
- package/ios/RNMBX/RNMBXPointAnnotationModule.h +3 -2
- package/ios/RNMBX/RNMBXPointAnnotationModule.mm +8 -16
- package/ios/RNMBX/RNMBXRasterArraySource.swift +47 -0
- package/ios/RNMBX/RNMBXRasterArraySourceComponentView.h +15 -0
- package/ios/RNMBX/RNMBXRasterArraySourceComponentView.mm +168 -0
- package/ios/RNMBX/RNMBXRasterArraySourceViewManager.swift +16 -0
- package/ios/RNMBX/RNMBXRasterParticleLayer.swift +100 -0
- package/ios/RNMBX/RNMBXRasterParticleLayerComponentView.h +15 -0
- package/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm +121 -0
- package/ios/RNMBX/RNMBXRasterParticleLayerViewManager.swift +17 -0
- package/ios/RNMBX/RNMBXShapeSource.swift +5 -4
- package/ios/RNMBX/RNMBXShapeSourceModule.h +3 -2
- package/ios/RNMBX/RNMBXShapeSourceModule.mm +8 -16
- package/ios/RNMBX/RNMBXSource.swift +51 -21
- package/ios/RNMBX/RNMBXStyle.swift +152 -27
- package/ios/RNMBX/RNMBXStyleValue.swift +27 -0
- package/ios/RNMBX/RNMBXViewport.swift +13 -13
- package/ios/RNMBX/RNMBXViewportModule.h +3 -2
- package/ios/RNMBX/RNMBXViewportModule.mm +8 -16
- package/lib/commonjs/plugin/build/withMapbox.js +1 -1
- package/lib/commonjs/plugin/src/withMapbox.ts +13 -3
- package/lib/module/Mapbox.native.js +2 -0
- package/lib/module/Mapbox.native.js.map +1 -1
- package/lib/module/RNMBXModule.js.map +1 -1
- package/lib/module/components/PointAnnotation.js.map +1 -1
- package/lib/module/components/RasterArraySource.js +67 -0
- package/lib/module/components/RasterArraySource.js.map +1 -0
- package/lib/module/components/RasterParticleLayer.js +40 -0
- package/lib/module/components/RasterParticleLayer.js.map +1 -0
- package/lib/module/modules/offline/offlineManagerLegacy.js +14 -0
- package/lib/module/modules/offline/offlineManagerLegacy.js.map +1 -1
- package/lib/module/specs/RNMBXRasterArraySourceNativeComponent.ts +22 -0
- package/lib/module/specs/RNMBXRasterParticleLayerNativeComponent.ts +39 -0
- package/lib/module/utils/MapboxStyles.js.map +1 -1
- package/lib/module/utils/styleMap.js +9 -0
- package/lib/module/utils/styleMap.js.map +1 -1
- package/lib/typescript/plugin/src/withMapbox.d.ts.map +1 -1
- package/lib/typescript/scripts/autogenHelpers/generateCodeWithEjs.d.mts.map +1 -1
- package/lib/typescript/scripts/autogenHelpers/globals.d.mts +1 -1
- package/lib/typescript/scripts/autogenHelpers/globals.d.mts.map +1 -1
- package/lib/typescript/src/Mapbox.native.d.ts +3 -1
- package/lib/typescript/src/Mapbox.native.d.ts.map +1 -1
- package/lib/typescript/src/RNMBXModule.d.ts.map +1 -1
- package/lib/typescript/src/components/PointAnnotation.d.ts +1 -1
- package/lib/typescript/src/components/PointAnnotation.d.ts.map +1 -1
- package/lib/typescript/src/components/RasterArraySource.d.ts +72 -0
- package/lib/typescript/src/components/RasterArraySource.d.ts.map +1 -0
- package/lib/typescript/src/components/RasterParticleLayer.d.ts +80 -0
- package/lib/typescript/src/components/RasterParticleLayer.d.ts.map +1 -0
- package/lib/typescript/src/modules/offline/offlineManagerLegacy.d.ts +11 -0
- package/lib/typescript/src/modules/offline/offlineManagerLegacy.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXRasterArraySourceNativeComponent.d.ts +16 -0
- package/lib/typescript/src/specs/RNMBXRasterArraySourceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/RNMBXRasterParticleLayerNativeComponent.d.ts +25 -0
- package/lib/typescript/src/specs/RNMBXRasterParticleLayerNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/utils/MapboxStyles.d.ts +44 -2
- package/lib/typescript/src/utils/MapboxStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/styleMap.d.ts.map +1 -1
- package/package.json +13 -1
- package/plugin/build/withMapbox.js +1 -1
- package/plugin/src/withMapbox.ts +13 -3
- package/rnmapbox-maps.podspec +1 -1
- package/src/Mapbox.native.ts +3 -0
- package/src/RNMBXModule.ts +1 -4
- package/src/components/PointAnnotation.tsx +2 -2
- package/src/components/RasterArraySource.tsx +134 -0
- package/src/components/RasterParticleLayer.tsx +117 -0
- package/src/modules/offline/offlineManagerLegacy.ts +14 -0
- package/src/specs/RNMBXRasterArraySourceNativeComponent.ts +22 -0
- package/src/specs/RNMBXRasterParticleLayerNativeComponent.ts +39 -0
- package/src/utils/MapboxStyles.ts +47 -1
- package/src/utils/styleMap.ts +10 -0
|
@@ -3,15 +3,15 @@ import MapboxMaps
|
|
|
3
3
|
let TAG = "RNMBXCustomLocationProvider"
|
|
4
4
|
|
|
5
5
|
@objc
|
|
6
|
-
public class RNMBXCustomLocationProvider: UIView,
|
|
6
|
+
public class RNMBXCustomLocationProvider: UIView, RNMBXMapAndMapViewComponent {
|
|
7
7
|
var map: RNMBXMapView? = nil
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
let changes : PropertyChanges<RNMBXCustomLocationProvider> = PropertyChanges()
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
enum Property: String {
|
|
12
12
|
case coordinate
|
|
13
13
|
case heading
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
func apply(locationProvider: RNMBXCustomLocationProvider) {
|
|
16
16
|
switch self {
|
|
17
17
|
case .coordinate: locationProvider.applyCoordinate()
|
|
@@ -19,61 +19,55 @@ public class RNMBXCustomLocationProvider: UIView, RNMBXMapComponent {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
@objc
|
|
24
24
|
public var coordinate: [Double] = [] {
|
|
25
25
|
didSet { changed(.coordinate) }
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
@objc
|
|
29
29
|
public var heading: NSNumber = 0.0 {
|
|
30
30
|
didSet { changed(.heading) }
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
func changed(_ property: Property) {
|
|
34
34
|
changes.add(name: property.rawValue, update: property.apply)
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
@objc
|
|
38
38
|
override public func didSetProps(_ props: [String]) {
|
|
39
39
|
if customLocationProvider != nil {
|
|
40
40
|
changes.apply(self)
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
var customLocationProvider: CustomLocationProvider? = nil
|
|
45
45
|
#if RNMBX_11
|
|
46
46
|
#else
|
|
47
47
|
var defaultLocationProvider: LocationProvider?
|
|
48
48
|
#endif
|
|
49
49
|
|
|
50
|
-
public func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
50
|
+
public func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
|
|
51
51
|
self.map = map
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
changes.apply(self)
|
|
55
|
-
}
|
|
52
|
+
installCustomeLocationProviderIfNeeded(mapView: mapView)
|
|
53
|
+
changes.apply(self)
|
|
56
54
|
}
|
|
57
|
-
|
|
55
|
+
|
|
58
56
|
private func applyCoordinate() {
|
|
59
57
|
updateCoordinate(latitude: coordinate[1], longitude: coordinate[0])
|
|
60
58
|
}
|
|
61
|
-
|
|
59
|
+
|
|
62
60
|
private func applyHeading() {
|
|
63
61
|
updateHeading(heading: heading.doubleValue)
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
public func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
|
|
67
|
-
|
|
68
|
-
removeCustomLocationProvider(mapView: mapView)
|
|
69
|
-
}
|
|
63
|
+
|
|
64
|
+
public func removeFromMap(_ map: RNMBXMapView, mapView: MapView, reason: RemovalReason) -> Bool {
|
|
65
|
+
removeCustomLocationProvider(mapView: mapView)
|
|
70
66
|
self.map = nil
|
|
71
67
|
return true
|
|
72
68
|
}
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
false
|
|
76
|
-
}
|
|
70
|
+
// Uses default implementation from RNMBXMapComponentProtocol extension (returns false)
|
|
77
71
|
}
|
|
78
72
|
|
|
79
73
|
#if RNMBX_11
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
#import <UIKit/UIKit.h>
|
|
3
|
+
#import "RNMBXViewResolver.h"
|
|
3
4
|
|
|
4
5
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
6
|
#import "rnmapbox_maps_specs.h"
|
|
@@ -9,9 +10,9 @@
|
|
|
9
10
|
|
|
10
11
|
@interface RNMBXImageModule : NSObject
|
|
11
12
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
12
|
-
<NativeRNMBXImageModuleSpec>
|
|
13
|
+
<NativeRNMBXImageModuleSpec, RNMBXViewResolverDelegate>
|
|
13
14
|
#else
|
|
14
|
-
<RCTBridgeModule>
|
|
15
|
+
<RCTBridgeModule, RNMBXViewResolverDelegate>
|
|
15
16
|
#endif
|
|
16
17
|
|
|
17
18
|
@end
|
|
@@ -27,22 +27,14 @@ RCT_EXPORT_MODULE();
|
|
|
27
27
|
|
|
28
28
|
- (void)withImage:(nonnull NSNumber*)viewRef block:(void (^)(RNMBXImage *))block reject:(RCTPromiseRejectBlock)reject methodName:(NSString *)methodName
|
|
29
29
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
RNMBXImage *view = [uiManager viewForReactTag:viewRef];
|
|
39
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
40
|
-
if (view != nil) {
|
|
41
|
-
block(view);
|
|
42
|
-
} else {
|
|
43
|
-
reject(methodName, [NSString stringWithFormat:@"Unknown reactTag: %@", viewRef], nil);
|
|
44
|
-
}
|
|
45
|
-
}];
|
|
30
|
+
[RNMBXViewResolver withViewRef:viewRef
|
|
31
|
+
delegate:self
|
|
32
|
+
expectedClass:[RNMBXImage class]
|
|
33
|
+
block:^(UIView *view) {
|
|
34
|
+
block((RNMBXImage *)view);
|
|
35
|
+
}
|
|
36
|
+
reject:reject
|
|
37
|
+
methodName:methodName];
|
|
46
38
|
}
|
|
47
39
|
|
|
48
40
|
|
|
@@ -74,11 +74,8 @@ open class RNMBXImages : UIView, RNMBXMapComponent {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// MARK: - RNMBXMapComponent
|
|
77
|
+
// Uses default implementation from RNMBXMapComponentProtocol extension (returns false)
|
|
77
78
|
|
|
78
|
-
public func waitForStyleLoad() -> Bool {
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
81
|
-
|
|
82
79
|
public func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
83
80
|
self.style = style
|
|
84
81
|
imageManager = map.imageManager
|
|
@@ -1,38 +1,43 @@
|
|
|
1
1
|
import MapboxMaps
|
|
2
2
|
|
|
3
3
|
@objc
|
|
4
|
-
public class RNMBXInteractiveElement : UIView,
|
|
4
|
+
public class RNMBXInteractiveElement : UIView, RNMBXMapAndMapViewComponent {
|
|
5
5
|
weak var map : RNMBXMapView? = nil
|
|
6
|
+
weak var mapView : MapView? = nil
|
|
6
7
|
|
|
7
8
|
static let hitboxDefault = 44.0
|
|
8
9
|
|
|
9
10
|
@objc public var draggable: Bool = false
|
|
10
|
-
|
|
11
|
+
|
|
11
12
|
@objc public var hasPressListener: Bool = false
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
@objc public var hitbox : [String:NSNumber] = [
|
|
14
15
|
"width": NSNumber(value: hitboxDefault),
|
|
15
16
|
"height": NSNumber(value: hitboxDefault)
|
|
16
17
|
]
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
@objc public var id: String! = nil {
|
|
19
20
|
willSet {
|
|
20
21
|
if id != nil && newValue != id {
|
|
21
22
|
Logger.log(level:.warn, message: "Changing id from: \(optional: id) to \(optional: newValue), changing of id is not supported")
|
|
22
|
-
if let map = map
|
|
23
|
+
if let map = map, let mapView = mapView {
|
|
24
|
+
removeFromMap(map, mapView: mapView, reason: .ComponentChange)
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
didSet {
|
|
26
29
|
if oldValue != nil && oldValue != id {
|
|
27
|
-
if let map = map
|
|
30
|
+
if let map = map, let mapView = mapView {
|
|
31
|
+
addToMap(map, mapView: mapView, style: mapView.mapboxMap.style)
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
|
-
|
|
36
|
+
|
|
32
37
|
@objc public var onDragStart: RCTBubblingEventBlock? = nil
|
|
33
|
-
|
|
38
|
+
|
|
34
39
|
@objc public var onPress: RCTBubblingEventBlock? = nil
|
|
35
|
-
|
|
40
|
+
|
|
36
41
|
func getLayerIDs() -> [String] {
|
|
37
42
|
return []
|
|
38
43
|
}
|
|
@@ -40,24 +45,26 @@ public class RNMBXInteractiveElement : UIView, RNMBXMapComponent {
|
|
|
40
45
|
func isDraggable() -> Bool {
|
|
41
46
|
return draggable
|
|
42
47
|
}
|
|
43
|
-
|
|
48
|
+
|
|
44
49
|
func isTouchable() -> Bool {
|
|
45
50
|
return hasPressListener
|
|
46
51
|
}
|
|
47
|
-
|
|
48
|
-
// MARK: -
|
|
49
|
-
public func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
52
|
+
|
|
53
|
+
// MARK: - RNMBXMapAndMapViewComponent
|
|
54
|
+
public func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
|
|
50
55
|
if (self.id == nil) {
|
|
51
56
|
Logger.log(level: .error, message: "id is required on \(self) but not specified")
|
|
52
57
|
}
|
|
53
58
|
self.map = map
|
|
59
|
+
self.mapView = mapView
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
public func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
|
|
62
|
+
public func removeFromMap(_ map: RNMBXMapView, mapView: MapView, reason: RemovalReason) -> Bool {
|
|
57
63
|
self.map = nil
|
|
64
|
+
self.mapView = nil
|
|
58
65
|
return true
|
|
59
66
|
}
|
|
60
|
-
|
|
67
|
+
|
|
61
68
|
public func waitForStyleLoad() -> Bool {
|
|
62
69
|
return true
|
|
63
70
|
}
|
|
@@ -60,11 +60,11 @@ public class RNMBXMapViewFactory {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
class FeatureEntry {
|
|
63
|
-
let feature: RNMBXMapComponent
|
|
63
|
+
let feature: AnyObject // Can be RNMBXMapComponent or RNMBXMapAndMapViewComponent
|
|
64
64
|
let view: UIView
|
|
65
65
|
var addedToMap: Bool = false
|
|
66
66
|
|
|
67
|
-
init(feature:
|
|
67
|
+
init(feature: AnyObject, view: UIView, addedToMap: Bool = false) {
|
|
68
68
|
self.feature = feature
|
|
69
69
|
self.view = view
|
|
70
70
|
self.addedToMap = addedToMap
|
|
@@ -269,7 +269,27 @@ open class RNMBXMapView: UIView, RCTInvalidating {
|
|
|
269
269
|
|
|
270
270
|
@objc public func addToMap(_ subview: UIView) {
|
|
271
271
|
withMapView { mapView in
|
|
272
|
-
|
|
272
|
+
// Check for RNMBXMapAndMapViewComponent first (requires MapView)
|
|
273
|
+
if let mapAndMapViewComponent = subview as? RNMBXMapAndMapViewComponent {
|
|
274
|
+
let style = mapView.mapboxMap.style
|
|
275
|
+
var addToMap = false
|
|
276
|
+
if mapAndMapViewComponent.waitForStyleLoad() {
|
|
277
|
+
if (self.styleLoadWaiters.hasInited()) {
|
|
278
|
+
addToMap = true
|
|
279
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
addToMap = true
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
let entry = FeatureEntry(feature: mapAndMapViewComponent, view: subview, addedToMap: false)
|
|
285
|
+
if (addToMap) {
|
|
286
|
+
mapAndMapViewComponent.addToMap(self, mapView: mapView, style: style)
|
|
287
|
+
entry.addedToMap = true
|
|
288
|
+
}
|
|
289
|
+
self.features.append(entry)
|
|
290
|
+
}
|
|
291
|
+
// Fallback to RNMBXMapComponent (doesn't require MapView)
|
|
292
|
+
else if let mapComponent = subview as? RNMBXMapComponent {
|
|
273
293
|
let style = mapView.mapboxMap.style
|
|
274
294
|
var addToMap = false
|
|
275
295
|
if mapComponent.waitForStyleLoad() {
|
|
@@ -296,7 +316,26 @@ open class RNMBXMapView: UIView, RCTInvalidating {
|
|
|
296
316
|
}
|
|
297
317
|
|
|
298
318
|
@objc public func removeFromMap(_ subview: UIView) {
|
|
299
|
-
|
|
319
|
+
// Check for RNMBXMapAndMapViewComponent first (requires MapView)
|
|
320
|
+
if let mapAndMapViewComponent = subview as? RNMBXMapAndMapViewComponent {
|
|
321
|
+
var entryIndex = features.firstIndex { $0.view == subview }
|
|
322
|
+
if let entryIndex = entryIndex {
|
|
323
|
+
var entry = features[entryIndex]
|
|
324
|
+
if (entry.addedToMap) {
|
|
325
|
+
// mapView should always be non-nil here if our invariants hold
|
|
326
|
+
guard let mapView = _mapView else {
|
|
327
|
+
Logger.error("RNMBXMapView.removeFromMap: CRITICAL - mapView is nil for component that requires it: \(type(of: subview))")
|
|
328
|
+
features.remove(at: entryIndex)
|
|
329
|
+
return
|
|
330
|
+
}
|
|
331
|
+
mapAndMapViewComponent.removeFromMap(self, mapView: mapView, reason: .OnDestroy)
|
|
332
|
+
entry.addedToMap = false
|
|
333
|
+
}
|
|
334
|
+
features.remove(at: entryIndex)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// Fallback to RNMBXMapComponent (doesn't require MapView)
|
|
338
|
+
else if let mapComponent = subview as? RNMBXMapComponent {
|
|
300
339
|
var entryIndex = features.firstIndex { $0.view == subview }
|
|
301
340
|
if let entryIndex = entryIndex {
|
|
302
341
|
var entry = features[entryIndex]
|
|
@@ -842,16 +881,39 @@ open class RNMBXMapView: UIView, RCTInvalidating {
|
|
|
842
881
|
private func removeAllFeaturesFromMap(reason: RemovalReason) {
|
|
843
882
|
features.forEach { entry in
|
|
844
883
|
if (entry.addedToMap) {
|
|
845
|
-
|
|
884
|
+
// Handle RNMBXMapAndMapViewComponent
|
|
885
|
+
if let mapAndMapViewComponent = entry.feature as? RNMBXMapAndMapViewComponent {
|
|
886
|
+
guard let mapView = _mapView else {
|
|
887
|
+
Logger.error("RNMBXMapView.removeAllFeaturesFromMap: mapView is nil")
|
|
888
|
+
return
|
|
889
|
+
}
|
|
890
|
+
mapAndMapViewComponent.removeFromMap(self, mapView: mapView, reason: reason)
|
|
891
|
+
}
|
|
892
|
+
// Handle RNMBXMapComponent
|
|
893
|
+
else if let mapComponent = entry.feature as? RNMBXMapComponent {
|
|
894
|
+
mapComponent.removeFromMap(self, reason: reason)
|
|
895
|
+
}
|
|
846
896
|
entry.addedToMap = false
|
|
847
897
|
}
|
|
848
898
|
}
|
|
849
899
|
}
|
|
850
900
|
|
|
851
901
|
private func addFeaturesToMap(style: Style) {
|
|
902
|
+
guard let mapView = _mapView else {
|
|
903
|
+
Logger.error("RNMBXMapView.addFeaturesToMap: mapView is nil")
|
|
904
|
+
return
|
|
905
|
+
}
|
|
906
|
+
|
|
852
907
|
features.forEach { entry in
|
|
853
908
|
if (!entry.addedToMap) {
|
|
854
|
-
|
|
909
|
+
// Handle RNMBXMapAndMapViewComponent
|
|
910
|
+
if let mapAndMapViewComponent = entry.feature as? RNMBXMapAndMapViewComponent {
|
|
911
|
+
mapAndMapViewComponent.addToMap(self, mapView: mapView, style: style)
|
|
912
|
+
}
|
|
913
|
+
// Handle RNMBXMapComponent
|
|
914
|
+
else if let mapComponent = entry.feature as? RNMBXMapComponent {
|
|
915
|
+
mapComponent.addToMap(self, style: style)
|
|
916
|
+
}
|
|
855
917
|
entry.addedToMap = true
|
|
856
918
|
}
|
|
857
919
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import MapboxMaps
|
|
2
2
|
|
|
3
3
|
@objc
|
|
4
|
-
public class RNMBXNativeUserLocation: UIView,
|
|
4
|
+
public class RNMBXNativeUserLocation: UIView, RNMBXMapAndMapViewComponent {
|
|
5
5
|
weak var map : RNMBXMapView! = nil
|
|
6
6
|
var imageManager: ImageManager? = nil
|
|
7
7
|
|
|
@@ -200,19 +200,19 @@ public class RNMBXNativeUserLocation: UIView, RNMBXMapComponent {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
public func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
203
|
+
public func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
|
|
204
204
|
self.map = map
|
|
205
|
-
|
|
205
|
+
|
|
206
206
|
_fetchImages(map)
|
|
207
207
|
_apply()
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
public func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
|
|
211
|
-
if
|
|
210
|
+
public func removeFromMap(_ map: RNMBXMapView, mapView: MapView, reason: RemovalReason) -> Bool {
|
|
211
|
+
if let location = mapView.location {
|
|
212
212
|
location.options.puckType = nil
|
|
213
213
|
location.options.puckType = .none
|
|
214
214
|
} else {
|
|
215
|
-
Logger.error("RNMBXNativeUserLocation
|
|
215
|
+
Logger.error("[RNMBXNativeUserLocation] removeFromMap, location is null")
|
|
216
216
|
}
|
|
217
217
|
removeSubscriptions()
|
|
218
218
|
self.map = nil
|
|
@@ -248,18 +248,16 @@ public class RNMBXPointAnnotation : RNMBXInteractiveElement {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
// MARK: -
|
|
252
|
-
|
|
253
|
-
public override func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
254
|
-
super.addToMap(map, style: style)
|
|
255
|
-
self.map = map
|
|
251
|
+
// MARK: - RNMBXMapAndMapViewComponent
|
|
252
|
+
|
|
253
|
+
public override func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
|
|
254
|
+
super.addToMap(map, mapView: mapView, style: style)
|
|
256
255
|
addIfPossible()
|
|
257
256
|
}
|
|
258
257
|
|
|
259
|
-
public override func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
|
|
258
|
+
public override func removeFromMap(_ map: RNMBXMapView, mapView: MapView, reason: RemovalReason) -> Bool {
|
|
260
259
|
removeIfAdded()
|
|
261
|
-
|
|
262
|
-
return true
|
|
260
|
+
return super.removeFromMap(map, mapView: mapView, reason: reason)
|
|
263
261
|
}
|
|
264
262
|
|
|
265
263
|
// MARK: - RNMBXInteractiveElement
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
#import <UIKit/UIKit.h>
|
|
3
|
+
#import "RNMBXViewResolver.h"
|
|
3
4
|
|
|
4
5
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
6
|
#import "rnmapbox_maps_specs.h"
|
|
@@ -9,9 +10,9 @@
|
|
|
9
10
|
|
|
10
11
|
@interface RNMBXPointAnnotationModule : NSObject
|
|
11
12
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
12
|
-
<NativeRNMBXPointAnnotationModuleSpec>
|
|
13
|
+
<NativeRNMBXPointAnnotationModuleSpec, RNMBXViewResolverDelegate>
|
|
13
14
|
#else
|
|
14
|
-
<RCTBridgeModule>
|
|
15
|
+
<RCTBridgeModule, RNMBXViewResolverDelegate>
|
|
15
16
|
#endif
|
|
16
17
|
|
|
17
18
|
@end
|
|
@@ -27,22 +27,14 @@ RCT_EXPORT_MODULE();
|
|
|
27
27
|
|
|
28
28
|
- (void)withPointAnnotation:(nonnull NSNumber*)viewRef block:(void (^)(RNMBXPointAnnotation *))block reject:(RCTPromiseRejectBlock)reject methodName:(NSString *)methodName
|
|
29
29
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
RNMBXPointAnnotation *view = [uiManager viewForReactTag:viewRef];
|
|
39
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
40
|
-
if (view != nil) {
|
|
41
|
-
block(view);
|
|
42
|
-
} else {
|
|
43
|
-
reject(methodName, [NSString stringWithFormat:@"Unknown reactTag: %@", viewRef], nil);
|
|
44
|
-
}
|
|
45
|
-
}];
|
|
30
|
+
[RNMBXViewResolver withViewRef:viewRef
|
|
31
|
+
delegate:self
|
|
32
|
+
expectedClass:[RNMBXPointAnnotation class]
|
|
33
|
+
block:^(UIView *view) {
|
|
34
|
+
block((RNMBXPointAnnotation *)view);
|
|
35
|
+
}
|
|
36
|
+
reject:reject
|
|
37
|
+
methodName:methodName];
|
|
46
38
|
}
|
|
47
39
|
|
|
48
40
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#if RNMBX_11
|
|
2
|
+
@_spi(Experimental) import MapboxMaps
|
|
3
|
+
|
|
4
|
+
@objc
|
|
5
|
+
public class RNMBXRasterArraySource : RNMBXSource {
|
|
6
|
+
typealias SourceType = RasterArraySource
|
|
7
|
+
|
|
8
|
+
@objc public var url: String? = nil
|
|
9
|
+
|
|
10
|
+
@objc public var tileUrlTemplates: [String]? = nil
|
|
11
|
+
|
|
12
|
+
@objc public var minZoomLevel: NSNumber?
|
|
13
|
+
@objc public var maxZoomLevel: NSNumber?
|
|
14
|
+
@objc public var tileSize: NSNumber?
|
|
15
|
+
|
|
16
|
+
@objc public var sourceBounds: [NSNumber]? = nil
|
|
17
|
+
|
|
18
|
+
override func makeSource() -> Source
|
|
19
|
+
{
|
|
20
|
+
// Note: tileSize and bounds are read-only after initialization in RasterArraySource
|
|
21
|
+
// They can only be set via the constructor or are derived from the source
|
|
22
|
+
var result = RasterArraySource(id: self.id)
|
|
23
|
+
if let url = url {
|
|
24
|
+
result.url = url
|
|
25
|
+
} else {
|
|
26
|
+
result.tiles = tileUrlTemplates
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if let minZoomLevel = minZoomLevel {
|
|
30
|
+
result.minzoom = minZoomLevel.doubleValue
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if let maxZoomLevel = maxZoomLevel {
|
|
34
|
+
result.maxzoom = maxZoomLevel.doubleValue
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Note: tileSize and bounds are read-only properties in RasterArraySource
|
|
38
|
+
// and cannot be set directly. They are either:
|
|
39
|
+
// - Derived from the TileJSON when using url
|
|
40
|
+
// - Use default values when using tiles
|
|
41
|
+
// If custom values are needed, they should be included in the TileJSON response
|
|
42
|
+
|
|
43
|
+
return result
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
#endif
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
#import <React/RCTUIManager.h>
|
|
6
|
+
#import <React/RCTViewComponentView.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@interface RNMBXRasterArraySourceComponentView : RCTViewComponentView
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
14
|
+
|
|
15
|
+
#endif // RCT_NEW_ARCH_ENABLED
|