@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
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "RNMBXRasterArraySourceComponentView.h"
|
|
4
|
+
#import "RNMBXFabricHelpers.h"
|
|
5
|
+
|
|
6
|
+
#import <React/RCTConversions.h>
|
|
7
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
8
|
+
|
|
9
|
+
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
|
+
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
11
|
+
#import <react/renderer/components/rnmapbox_maps_specs/Props.h>
|
|
12
|
+
#import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
|
|
13
|
+
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
#if RNMBX_11
|
|
17
|
+
|
|
18
|
+
@interface RNMBXRasterArraySourceComponentView () <RCTRNMBXRasterArraySourceViewProtocol>
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@implementation RNMBXRasterArraySourceComponentView {
|
|
22
|
+
RNMBXRasterArraySource *_view;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Needed because of this: https://github.com/facebook/react-native/pull/37274
|
|
26
|
+
+ (void)load
|
|
27
|
+
{
|
|
28
|
+
[super load];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
32
|
+
{
|
|
33
|
+
if (self = [super initWithFrame:frame]) {
|
|
34
|
+
static const auto defaultProps = std::make_shared<const RNMBXRasterArraySourceProps>();
|
|
35
|
+
_props = defaultProps;
|
|
36
|
+
[self prepareView];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return self;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)prepareView
|
|
43
|
+
{
|
|
44
|
+
_view = [[RNMBXRasterArraySource alloc] init];
|
|
45
|
+
self.contentView = _view;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)prepareForRecycle
|
|
49
|
+
{
|
|
50
|
+
[super prepareForRecycle];
|
|
51
|
+
[self prepareView];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
55
|
+
{
|
|
56
|
+
if ([childComponentView isKindOfClass:[RCTViewComponentView class]]) {
|
|
57
|
+
[_view insertReactSubviewInternal:((RCTViewComponentView *)childComponentView).contentView at:index];
|
|
58
|
+
} else {
|
|
59
|
+
RCTLogError(@"Tried to add view that is not RCTViewComponentView: %@", childComponentView);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
64
|
+
{
|
|
65
|
+
if ([childComponentView isKindOfClass:[RCTViewComponentView class]]) {
|
|
66
|
+
[_view removeReactSubviewInternal:((RCTViewComponentView *)childComponentView).contentView];
|
|
67
|
+
} else {
|
|
68
|
+
RCTLogError(@"Tried to remove view that is not RCTViewComponentView: %@", childComponentView);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#pragma mark - RCTComponentViewProtocol
|
|
73
|
+
|
|
74
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
75
|
+
{
|
|
76
|
+
return concreteComponentDescriptorProvider<RNMBXRasterArraySourceComponentDescriptor>();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
80
|
+
{
|
|
81
|
+
const auto &newProps = static_cast<const RNMBXRasterArraySourceProps &>(*props);
|
|
82
|
+
id idx = RNMBXConvertFollyDynamicToId(newProps.id);
|
|
83
|
+
if (idx != nil) {
|
|
84
|
+
_view.id = idx;
|
|
85
|
+
}
|
|
86
|
+
id existing = RNMBXConvertFollyDynamicToId(newProps.existing);
|
|
87
|
+
if (existing != nil) {
|
|
88
|
+
_view.existing = existing;
|
|
89
|
+
}
|
|
90
|
+
id url = RNMBXConvertFollyDynamicToId(newProps.url);
|
|
91
|
+
if (url != nil) {
|
|
92
|
+
_view.url = url;
|
|
93
|
+
}
|
|
94
|
+
id tileUrlTemplates = RNMBXConvertFollyDynamicToId(newProps.tileUrlTemplates);
|
|
95
|
+
if (tileUrlTemplates != nil) {
|
|
96
|
+
_view.tileUrlTemplates = tileUrlTemplates;
|
|
97
|
+
}
|
|
98
|
+
id minZoomLevel = RNMBXConvertFollyDynamicToId(newProps.minZoomLevel);
|
|
99
|
+
if (minZoomLevel != nil) {
|
|
100
|
+
_view.minZoomLevel = minZoomLevel;
|
|
101
|
+
}
|
|
102
|
+
id maxZoomLevel = RNMBXConvertFollyDynamicToId(newProps.maxZoomLevel);
|
|
103
|
+
if (maxZoomLevel != nil) {
|
|
104
|
+
_view.maxZoomLevel = maxZoomLevel;
|
|
105
|
+
}
|
|
106
|
+
id tileSize = RNMBXConvertFollyDynamicToId(newProps.tileSize);
|
|
107
|
+
if (tileSize != nil) {
|
|
108
|
+
_view.tileSize = tileSize;
|
|
109
|
+
}
|
|
110
|
+
id sourceBounds = RNMBXConvertFollyDynamicToId(newProps.sourceBounds);
|
|
111
|
+
if (sourceBounds != nil) {
|
|
112
|
+
_view.sourceBounds = sourceBounds;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[super updateProps:props oldProps:oldProps];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@end
|
|
119
|
+
|
|
120
|
+
Class<RCTComponentViewProtocol> RNMBXRasterArraySourceCls(void)
|
|
121
|
+
{
|
|
122
|
+
return RNMBXRasterArraySourceComponentView.class;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#else // !RNMBX_11
|
|
126
|
+
|
|
127
|
+
// RasterArraySource is only available in Mapbox v11+
|
|
128
|
+
// Provide a stub implementation for v10 builds
|
|
129
|
+
|
|
130
|
+
@interface RNMBXRasterArraySourceComponentView () <RCTRNMBXRasterArraySourceViewProtocol>
|
|
131
|
+
@end
|
|
132
|
+
|
|
133
|
+
@implementation RNMBXRasterArraySourceComponentView
|
|
134
|
+
|
|
135
|
+
+ (void)load
|
|
136
|
+
{
|
|
137
|
+
[super load];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
141
|
+
{
|
|
142
|
+
if (self = [super initWithFrame:frame]) {
|
|
143
|
+
static const auto defaultProps = std::make_shared<const RNMBXRasterArraySourceProps>();
|
|
144
|
+
_props = defaultProps;
|
|
145
|
+
}
|
|
146
|
+
return self;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
150
|
+
{
|
|
151
|
+
return concreteComponentDescriptorProvider<RNMBXRasterArraySourceComponentDescriptor>();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
155
|
+
{
|
|
156
|
+
[super updateProps:props oldProps:oldProps];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@end
|
|
160
|
+
|
|
161
|
+
Class<RCTComponentViewProtocol> RNMBXRasterArraySourceCls(void)
|
|
162
|
+
{
|
|
163
|
+
return RNMBXRasterArraySourceComponentView.class;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#endif // RNMBX_11
|
|
167
|
+
|
|
168
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import MapboxMaps
|
|
3
|
+
|
|
4
|
+
#if RNMBX_11
|
|
5
|
+
@objc(RNMBXRasterArraySourceViewManager)
|
|
6
|
+
class RNMBXRasterArraySourceViewManager : RCTViewManager {
|
|
7
|
+
@objc
|
|
8
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
override func view() -> UIView! {
|
|
13
|
+
return RNMBXRasterArraySource()
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
#endif
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#if RNMBX_11
|
|
2
|
+
@_spi(Experimental) import MapboxMaps
|
|
3
|
+
|
|
4
|
+
@objc(RNMBXRasterParticleLayer)
|
|
5
|
+
public class RNMBXRasterParticleLayer: RNMBXLayer {
|
|
6
|
+
typealias LayerType = RasterParticleLayer
|
|
7
|
+
|
|
8
|
+
override func makeLayer(style: Style) throws -> Layer {
|
|
9
|
+
var layer = LayerType(id: self.id!, source: sourceID!)
|
|
10
|
+
layer.source = sourceID
|
|
11
|
+
return layer
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// @{codepart-replace-start(LayerPropsCommon.codepart-swift.ejs,{layerType:"RasterParticle"})}
|
|
15
|
+
func setCommonOptions(_ layer: inout RasterParticleLayer) -> Bool {
|
|
16
|
+
var changed = false
|
|
17
|
+
|
|
18
|
+
#if RNMBX_11
|
|
19
|
+
if let sourceLayerID = sourceLayerID {
|
|
20
|
+
layer.sourceLayer = sourceLayerID
|
|
21
|
+
changed = true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if let sourceID = sourceID {
|
|
25
|
+
if !(existingLayer && sourceID == DEFAULT_SOURCE_ID) && hasSource() {
|
|
26
|
+
layer.source = sourceID
|
|
27
|
+
changed = true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if let filter = filter, filter.count > 0 {
|
|
32
|
+
do {
|
|
33
|
+
let data = try JSONSerialization.data(withJSONObject: filter, options: .prettyPrinted)
|
|
34
|
+
let decodedExpression = try JSONDecoder().decode(Expression.self, from: data)
|
|
35
|
+
layer.filter = decodedExpression
|
|
36
|
+
changed = true
|
|
37
|
+
} catch {
|
|
38
|
+
Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
return changed
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override func setOptions(_ layer: inout Layer) {
|
|
47
|
+
super.setOptions(&layer)
|
|
48
|
+
if var actualLayer = layer as? LayerType {
|
|
49
|
+
if self.setCommonOptions(&actualLayer) {
|
|
50
|
+
layer = actualLayer
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
Logger.log(level: .error, message: "Expected layer type to be RasterParticle but was \(type(of: layer))")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
override func apply(style : Style) throws {
|
|
58
|
+
try style.updateLayer(withId: id, type: LayerType.self) { (layer : inout RasterParticleLayer) in
|
|
59
|
+
if self.styleLayer != nil {
|
|
60
|
+
self.setOptions(&self.styleLayer!)
|
|
61
|
+
}
|
|
62
|
+
if let styleLayer = self.styleLayer as? LayerType {
|
|
63
|
+
layer = styleLayer
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// @{codepart-replace-end}
|
|
68
|
+
|
|
69
|
+
override func addStyles() {
|
|
70
|
+
if let style : Style = self.style,
|
|
71
|
+
let reactStyle = reactStyle {
|
|
72
|
+
let styler = RNMBXStyle(style: self.style!)
|
|
73
|
+
styler.bridge = self.bridge
|
|
74
|
+
|
|
75
|
+
if var styleLayer = self.styleLayer as? LayerType {
|
|
76
|
+
styler.rasterParticleLayer(
|
|
77
|
+
layer: &styleLayer,
|
|
78
|
+
reactStyle: reactStyle,
|
|
79
|
+
oldReactStyle: oldReatStyle,
|
|
80
|
+
applyUpdater:{ (updater) in logged("RNMBXRasterParticleLayer.updateLayer") {
|
|
81
|
+
try style.updateLayer(withId: self.id, type: LayerType.self) { (layer: inout LayerType) in updater(&layer) }
|
|
82
|
+
}},
|
|
83
|
+
isValid: { return self.isAddedToMap() }
|
|
84
|
+
)
|
|
85
|
+
self.styleLayer = styleLayer
|
|
86
|
+
} else {
|
|
87
|
+
fatalError("[xxx] layer is not raster particle layer?!!! \(optional: self.styleLayer)")
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func isAddedToMap() -> Bool {
|
|
93
|
+
return true
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override func layerType() -> Layer.Type {
|
|
97
|
+
return LayerType.self
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
#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 RNMBXRasterParticleLayerComponentView : RCTViewComponentView
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
14
|
+
|
|
15
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "RNMBXRasterParticleLayerComponentView.h"
|
|
4
|
+
#import "RNMBXFabricHelpers.h"
|
|
5
|
+
|
|
6
|
+
#import <React/RCTConversions.h>
|
|
7
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
8
|
+
#import <React/RCTBridge+Private.h>
|
|
9
|
+
|
|
10
|
+
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
11
|
+
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
12
|
+
#import <react/renderer/components/rnmapbox_maps_specs/Props.h>
|
|
13
|
+
#import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
|
|
14
|
+
|
|
15
|
+
using namespace facebook::react;
|
|
16
|
+
|
|
17
|
+
#if RNMBX_11
|
|
18
|
+
|
|
19
|
+
@interface RNMBXRasterParticleLayerComponentView () <RCTRNMBXRasterParticleLayerViewProtocol>
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
@implementation RNMBXRasterParticleLayerComponentView {
|
|
23
|
+
RNMBXRasterParticleLayer *_view;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Needed because of this: https://github.com/facebook/react-native/pull/37274
|
|
27
|
+
+ (void)load
|
|
28
|
+
{
|
|
29
|
+
[super load];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
33
|
+
{
|
|
34
|
+
if (self = [super initWithFrame:frame]) {
|
|
35
|
+
static const auto defaultProps = std::make_shared<const RNMBXRasterParticleLayerProps>();
|
|
36
|
+
_props = defaultProps;
|
|
37
|
+
[self prepareView];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return self;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)prepareView
|
|
44
|
+
{
|
|
45
|
+
_view = [[RNMBXRasterParticleLayer alloc] init];
|
|
46
|
+
_view.bridge = [RCTBridge currentBridge];
|
|
47
|
+
self.contentView = _view;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#pragma mark - RCTComponentViewProtocol
|
|
51
|
+
|
|
52
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
53
|
+
{
|
|
54
|
+
return concreteComponentDescriptorProvider<RNMBXRasterParticleLayerComponentDescriptor>();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
58
|
+
{
|
|
59
|
+
const auto &newProps = static_cast<const RNMBXRasterParticleLayerProps &>(*props);
|
|
60
|
+
RNMBXSetCommonLayerProps(newProps, _view);
|
|
61
|
+
|
|
62
|
+
[super updateProps:props oldProps:oldProps];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void)prepareForRecycle
|
|
66
|
+
{
|
|
67
|
+
[super prepareForRecycle];
|
|
68
|
+
[self prepareView];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@end
|
|
72
|
+
|
|
73
|
+
Class<RCTComponentViewProtocol> RNMBXRasterParticleLayerCls(void)
|
|
74
|
+
{
|
|
75
|
+
return RNMBXRasterParticleLayerComponentView.class;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#else // !RNMBX_11
|
|
79
|
+
|
|
80
|
+
// RasterParticleLayer is only available in Mapbox v11+
|
|
81
|
+
// Provide a stub implementation for v10 builds
|
|
82
|
+
|
|
83
|
+
@interface RNMBXRasterParticleLayerComponentView () <RCTRNMBXRasterParticleLayerViewProtocol>
|
|
84
|
+
@end
|
|
85
|
+
|
|
86
|
+
@implementation RNMBXRasterParticleLayerComponentView
|
|
87
|
+
|
|
88
|
+
+ (void)load
|
|
89
|
+
{
|
|
90
|
+
[super load];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
94
|
+
{
|
|
95
|
+
if (self = [super initWithFrame:frame]) {
|
|
96
|
+
static const auto defaultProps = std::make_shared<const RNMBXRasterParticleLayerProps>();
|
|
97
|
+
_props = defaultProps;
|
|
98
|
+
}
|
|
99
|
+
return self;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
103
|
+
{
|
|
104
|
+
return concreteComponentDescriptorProvider<RNMBXRasterParticleLayerComponentDescriptor>();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
108
|
+
{
|
|
109
|
+
[super updateProps:props oldProps:oldProps];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@end
|
|
113
|
+
|
|
114
|
+
Class<RCTComponentViewProtocol> RNMBXRasterParticleLayerCls(void)
|
|
115
|
+
{
|
|
116
|
+
return RNMBXRasterParticleLayerComponentView.class;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#endif // RNMBX_11
|
|
120
|
+
|
|
121
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
#if RNMBX_11
|
|
4
|
+
@objc(RNMBXRasterParticleLayerViewManager)
|
|
5
|
+
class RNMBXRasterParticleLayerViewManager: RCTViewManager {
|
|
6
|
+
@objc
|
|
7
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
8
|
+
return false
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
override func view() -> UIView! {
|
|
12
|
+
let layer = RNMBXRasterParticleLayer()
|
|
13
|
+
layer.bridge = self.bridge
|
|
14
|
+
return layer
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
#endif
|
|
@@ -55,15 +55,16 @@ public class RNMBXShapeSource : RNMBXSource {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
|
|
59
|
+
public override func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
|
|
60
|
+
super.addToMap(map, mapView:mapView, style: style)
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
public override func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
|
|
63
|
+
public override func removeFromMap(_ map: RNMBXMapView, mapView: MapView, reason: RemovalReason) -> Bool {
|
|
63
64
|
if (reason == .ViewRemoval) {
|
|
64
65
|
shapeAnimator?.unsubscribe(consumer: self)
|
|
65
66
|
}
|
|
66
|
-
return super.removeFromMap(map, reason: reason)
|
|
67
|
+
return super.removeFromMap(map, mapView:mapView, reason: reason)
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
@objc public var cluster : NSNumber?
|
|
@@ -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 RNMBXShapeSourceModule : NSObject
|
|
11
12
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
12
|
-
<NativeRNMBXShapeSourceModuleSpec>
|
|
13
|
+
<NativeRNMBXShapeSourceModuleSpec, 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)withShapeSource:(nonnull NSNumber*)viewRef block:(void (^)(RNMBXShapeSource *))block reject:(RCTPromiseRejectBlock)reject methodName:(NSString *)methodName
|
|
29
29
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
RNMBXShapeSource *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:[RNMBXShapeSource class]
|
|
33
|
+
block:^(UIView *view) {
|
|
34
|
+
block((RNMBXShapeSource *)view);
|
|
35
|
+
}
|
|
36
|
+
reject:reject
|
|
37
|
+
methodName:methodName];
|
|
46
38
|
}
|
|
47
39
|
|
|
48
40
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
@objc
|
|
4
4
|
public class RNMBXSource : RNMBXInteractiveElement {
|
|
5
5
|
var layers: [RNMBXSourceConsumer] = []
|
|
6
|
-
var components: [
|
|
6
|
+
var components: [RNMBXMapComponentProtocol] = [] // Use base protocol to store both types
|
|
7
7
|
|
|
8
8
|
var source : Source? = nil
|
|
9
9
|
|
|
@@ -38,34 +38,50 @@ public class RNMBXSource : RNMBXInteractiveElement {
|
|
|
38
38
|
|
|
39
39
|
@objc public func insertReactSubviewInternal(_ subview: UIView!, at atIndex: Int) {
|
|
40
40
|
if let layer = subview as? RNMBXSourceConsumer {
|
|
41
|
-
if let map = map {
|
|
42
|
-
layer.addToMap(map, style:
|
|
41
|
+
if let map = map, let mapView = mapView {
|
|
42
|
+
layer.addToMap(map, style: mapView.mapboxMap.style)
|
|
43
43
|
}
|
|
44
44
|
layers.append(layer)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
}
|
|
46
|
+
// Check for more specific protocol first (RNMBXMapAndMapViewComponent is a subtype of RNMBXMapComponent)
|
|
47
|
+
else if let mapAndMapViewComponent = subview as? RNMBXMapAndMapViewComponent {
|
|
48
|
+
if let map = map, let mapView = mapView {
|
|
49
|
+
mapAndMapViewComponent.addToMap(map, mapView: mapView, style: mapView.mapboxMap.style)
|
|
50
|
+
}
|
|
51
|
+
components.append(mapAndMapViewComponent)
|
|
52
|
+
}
|
|
53
|
+
else if let component = subview as? RNMBXMapComponent {
|
|
54
|
+
if let map = map, let mapView = mapView {
|
|
55
|
+
component.addToMap(map, style: mapView.mapboxMap.style)
|
|
48
56
|
}
|
|
49
57
|
components.append(component)
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
|
-
|
|
60
|
+
|
|
53
61
|
@objc public override func removeReactSubview(_ subview: UIView!) {
|
|
54
62
|
removeReactSubviewInternal(subview)
|
|
55
63
|
super.removeReactSubview(subview)
|
|
56
64
|
}
|
|
57
|
-
|
|
65
|
+
|
|
58
66
|
@objc public func removeReactSubviewInternal(_ subview: UIView!) {
|
|
59
67
|
if let layer : RNMBXSourceConsumer = subview as? RNMBXSourceConsumer {
|
|
60
|
-
if let map = map {
|
|
61
|
-
layer.removeFromMap(map, style:
|
|
68
|
+
if let map = map, let mapView = mapView {
|
|
69
|
+
layer.removeFromMap(map, style: mapView.mapboxMap.style)
|
|
62
70
|
}
|
|
63
71
|
layers.removeAll { $0 as AnyObject === layer }
|
|
64
|
-
}
|
|
72
|
+
}
|
|
73
|
+
// Check for more specific protocol first (RNMBXMapAndMapViewComponent is a subtype of RNMBXMapComponent)
|
|
74
|
+
else if let mapAndMapViewComponent = subview as? RNMBXMapAndMapViewComponent {
|
|
75
|
+
if let map = map, let mapView = mapView {
|
|
76
|
+
mapAndMapViewComponent.removeFromMap(map, mapView: mapView, reason: .ViewRemoval)
|
|
77
|
+
}
|
|
78
|
+
components.removeAll { $0 as AnyObject === mapAndMapViewComponent }
|
|
79
|
+
}
|
|
80
|
+
else if let component = subview as? RNMBXMapComponent {
|
|
65
81
|
if let map = map {
|
|
66
82
|
component.removeFromMap(map, reason: .ViewRemoval)
|
|
67
83
|
}
|
|
68
|
-
|
|
84
|
+
components.removeAll { $0 as AnyObject === component }
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
87
|
|
|
@@ -75,9 +91,9 @@ public class RNMBXSource : RNMBXInteractiveElement {
|
|
|
75
91
|
}
|
|
76
92
|
|
|
77
93
|
// MARK: - RNMBXInteractiveElement
|
|
78
|
-
|
|
79
|
-
public override func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
80
|
-
|
|
94
|
+
|
|
95
|
+
public override func addToMap(_ map: RNMBXMapView, mapView: MapView, style: Style) {
|
|
96
|
+
super.addToMap(map, mapView: mapView, style: style)
|
|
81
97
|
|
|
82
98
|
if style.sourceExists(withId: self.id) {
|
|
83
99
|
if (!existing) {
|
|
@@ -101,22 +117,36 @@ public class RNMBXSource : RNMBXInteractiveElement {
|
|
|
101
117
|
}
|
|
102
118
|
|
|
103
119
|
for layer in self.layers {
|
|
104
|
-
layer.addToMap(map, style:
|
|
120
|
+
layer.addToMap(map, style: style)
|
|
105
121
|
}
|
|
106
122
|
for component in self.components {
|
|
107
|
-
|
|
123
|
+
// Check for more specific protocol first
|
|
124
|
+
if let mapAndMapViewComponent = component as? RNMBXMapAndMapViewComponent {
|
|
125
|
+
mapAndMapViewComponent.addToMap(map, mapView: mapView, style: style)
|
|
126
|
+
} else if let mapComponent = component as? RNMBXMapComponent {
|
|
127
|
+
mapComponent.addToMap(map, style: style)
|
|
128
|
+
}
|
|
108
129
|
}
|
|
109
130
|
}
|
|
110
131
|
|
|
111
|
-
public override func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
|
|
112
|
-
|
|
132
|
+
public override func removeFromMap(_ map: RNMBXMapView, mapView: MapView, reason: RemovalReason) -> Bool {
|
|
133
|
+
super.removeFromMap(map, mapView: mapView, reason: reason)
|
|
113
134
|
|
|
114
135
|
for layer in self.layers {
|
|
115
|
-
layer.removeFromMap(map, style:
|
|
136
|
+
layer.removeFromMap(map, style: mapView.mapboxMap.style)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for component in self.components {
|
|
140
|
+
// Check for more specific protocol first
|
|
141
|
+
if let mapAndMapViewComponent = component as? RNMBXMapAndMapViewComponent {
|
|
142
|
+
mapAndMapViewComponent.removeFromMap(map, mapView: mapView, reason: reason)
|
|
143
|
+
} else if let mapComponent = component as? RNMBXMapComponent {
|
|
144
|
+
mapComponent.removeFromMap(map, reason: reason)
|
|
145
|
+
}
|
|
116
146
|
}
|
|
117
147
|
|
|
118
148
|
if self.ownsSource {
|
|
119
|
-
let style =
|
|
149
|
+
let style = mapView.mapboxMap.style
|
|
120
150
|
logged("StyleSource.removeFromMap", info: { "id: \(optional: self.id)"}) {
|
|
121
151
|
try style.removeSource(withId: id)
|
|
122
152
|
}
|