@rnmapbox/maps 10.2.7 → 10.2.9
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 +10 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProvider.kt +7 -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/events/MapSteadyEvent.kt +50 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/events/RNMBXCameraGestureObserver.kt +296 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/events/RNMBXCameraGestureObserverManager.kt +74 -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/RNMBXCameraGestureObserverManagerDelegate.java +39 -0
- package/android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXCameraGestureObserverManagerInterface.java +18 -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/RNMBXCameraGestureObserver.swift +218 -0
- package/ios/RNMBX/RNMBXCameraGestureObserverComponentView.h +15 -0
- package/ios/RNMBX/RNMBXCameraGestureObserverComponentView.mm +119 -0
- package/ios/RNMBX/RNMBXCameraModule.h +3 -2
- package/ios/RNMBX/RNMBXCameraModule.mm +8 -16
- package/ios/RNMBX/RNMBXCustomLocationProvider.swift +22 -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 +118 -12
- 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 +161 -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 +110 -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 +4 -0
- package/lib/module/Mapbox.native.js.map +1 -1
- package/lib/module/RNMBXModule.js.map +1 -1
- package/lib/module/components/CameraGestureObserver.js +17 -0
- package/lib/module/components/CameraGestureObserver.js.map +1 -0
- 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/RNMBXCameraGestureObserverNativeComponent.ts +28 -0
- 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 +5 -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/CameraGestureObserver.d.ts +27 -0
- package/lib/typescript/src/components/CameraGestureObserver.d.ts.map +1 -0
- 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/RNMBXCameraGestureObserverNativeComponent.d.ts +20 -0
- package/lib/typescript/src/specs/RNMBXCameraGestureObserverNativeComponent.d.ts.map +1 -0
- 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 +19 -2
- 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 +5 -0
- package/src/RNMBXModule.ts +1 -4
- package/src/components/CameraGestureObserver.tsx +37 -0
- 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/RNMBXCameraGestureObserverNativeComponent.ts +28 -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,119 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "RNMBXCameraGestureObserverComponentView.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
|
+
#import "RNMBXFabricPropConvert.h"
|
|
16
|
+
|
|
17
|
+
using namespace facebook::react;
|
|
18
|
+
|
|
19
|
+
@interface RNMBXCameraGestureObserverComponentView () <RCTRNMBXCameraGestureObserverViewProtocol>
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
@implementation RNMBXCameraGestureObserverComponentView {
|
|
23
|
+
RNMBXCameraGestureObserver *_view;
|
|
24
|
+
}
|
|
25
|
+
|
|
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 RNMBXCameraGestureObserverProps>();
|
|
35
|
+
_props = defaultProps;
|
|
36
|
+
[self prepareView];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return self;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)prepareView
|
|
43
|
+
{
|
|
44
|
+
_view = [[RNMBXCameraGestureObserver alloc] init];
|
|
45
|
+
self.contentView = _view;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)setHasOnMapSteady:(BOOL)hasOnMapSteady {
|
|
49
|
+
if (hasOnMapSteady) {
|
|
50
|
+
#if DEBUG
|
|
51
|
+
NSLog(@"[RNMBXCameraGestureObserver] setHasOnMapSteady=YES");
|
|
52
|
+
#endif
|
|
53
|
+
__weak __typeof__(self) weakSelf = self;
|
|
54
|
+
[_view setOnMapSteady:^(NSString* reason, NSNumber* _Nullable idleDurationMs, NSString* _Nullable lastGestureType, NSNumber* timestamp){
|
|
55
|
+
__typeof__(self) strongSelf = weakSelf;
|
|
56
|
+
if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
|
|
57
|
+
using EventEmitterT = facebook::react::RNMBXCameraGestureObserverEventEmitter;
|
|
58
|
+
EventEmitterT::OnMapSteadyReason reasonEnum = EventEmitterT::OnMapSteadyReason::Steady;
|
|
59
|
+
if ([reason isEqualToString:@"timeout"]) {
|
|
60
|
+
reasonEnum = EventEmitterT::OnMapSteadyReason::Timeout;
|
|
61
|
+
} else {
|
|
62
|
+
reasonEnum = EventEmitterT::OnMapSteadyReason::Steady;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
double ts = [timestamp doubleValue];
|
|
66
|
+
double idle = idleDurationMs != nil ? [idleDurationMs doubleValue] : 0.0;
|
|
67
|
+
std::string lastGesture = lastGestureType != nil ? std::string([lastGestureType UTF8String]) : std::string("");
|
|
68
|
+
#if DEBUG
|
|
69
|
+
NSLog(@"[RNMBXCameraGestureObserver] emitting onMapSteady reason=%s idle=%.2f lastGesture=%s ts=%.0f",
|
|
70
|
+
EventEmitterT::toString(reasonEnum), idle, lastGesture.c_str(), ts);
|
|
71
|
+
#endif
|
|
72
|
+
std::dynamic_pointer_cast<const EventEmitterT>(strongSelf->_eventEmitter)->onMapSteady({reasonEnum, idle, lastGesture, ts});
|
|
73
|
+
}
|
|
74
|
+
}];
|
|
75
|
+
} else {
|
|
76
|
+
#if DEBUG
|
|
77
|
+
NSLog(@"[RNMBXCameraGestureObserver] setHasOnMapSteady=NO");
|
|
78
|
+
#endif
|
|
79
|
+
[_view setHasOnMapSteady:NO];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#pragma mark - RCTComponentViewProtocol
|
|
84
|
+
|
|
85
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
86
|
+
{
|
|
87
|
+
return concreteComponentDescriptorProvider<RNMBXCameraGestureObserverComponentDescriptor>();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
91
|
+
{
|
|
92
|
+
const auto &oldViewProps = static_cast<const RNMBXCameraGestureObserverProps &>(*oldProps);
|
|
93
|
+
const auto &newViewProps = static_cast<const RNMBXCameraGestureObserverProps &>(*props);
|
|
94
|
+
|
|
95
|
+
RNMBX_OPTIONAL_PROP_NSNumber(quietPeriodMs);
|
|
96
|
+
RNMBX_OPTIONAL_PROP_NSNumber(maxIntervalMs);
|
|
97
|
+
RNMBX_OPTIONAL_PROP_BOOL(hasOnMapSteady);
|
|
98
|
+
|
|
99
|
+
if (!oldProps.get() || oldViewProps.hasOnMapSteady != newViewProps.hasOnMapSteady) {
|
|
100
|
+
[self setHasOnMapSteady:newViewProps.hasOnMapSteady.asBool()];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
[super updateProps:props oldProps:oldProps];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
- (void)prepareForRecycle
|
|
107
|
+
{
|
|
108
|
+
[super prepareForRecycle];
|
|
109
|
+
[self prepareView];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@end
|
|
113
|
+
|
|
114
|
+
Class<RCTComponentViewProtocol> RNMBXCameraGestureObserverCls(void)
|
|
115
|
+
{
|
|
116
|
+
return RNMBXCameraGestureObserverComponentView.class;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -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 RNMBXCameraModule : NSObject
|
|
11
12
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
12
|
-
<NativeRNMBXCameraModuleSpec>
|
|
13
|
+
<NativeRNMBXCameraModuleSpec, RNMBXViewResolverDelegate>
|
|
13
14
|
#else
|
|
14
|
-
<RCTBridgeModule>
|
|
15
|
+
<RCTBridgeModule, RNMBXViewResolverDelegate>
|
|
15
16
|
#endif
|
|
16
17
|
|
|
17
18
|
@end
|
|
@@ -36,22 +36,14 @@ RCT_EXPORT_MODULE();
|
|
|
36
36
|
|
|
37
37
|
- (void)withCamera:(nonnull NSNumber*)viewRef block:(void (^)(RNMBXCamera *))block reject:(RCTPromiseRejectBlock)reject methodName:(NSString *)methodName
|
|
38
38
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
RNMBXCamera *view = [uiManager viewForReactTag:viewRef];
|
|
48
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
49
|
-
if (view != nil) {
|
|
50
|
-
block(view);
|
|
51
|
-
} else {
|
|
52
|
-
reject(methodName, [NSString stringWithFormat:@"Unknown reactTag: %@", viewRef], nil);
|
|
53
|
-
}
|
|
54
|
-
}];
|
|
39
|
+
[RNMBXViewResolver withViewRef:viewRef
|
|
40
|
+
delegate:self
|
|
41
|
+
expectedClass:[RNMBXCamera class]
|
|
42
|
+
block:^(UIView *view) {
|
|
43
|
+
block((RNMBXCamera *)view);
|
|
44
|
+
}
|
|
45
|
+
reject:reject
|
|
46
|
+
methodName:methodName];
|
|
55
47
|
}
|
|
56
48
|
|
|
57
49
|
RCT_EXPORT_METHOD(updateCameraStop:(nonnull NSNumber *)viewRef
|
|
@@ -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
|
|
@@ -83,6 +77,10 @@ extension RNMBXCustomLocationProvider {
|
|
|
83
77
|
if (customLocationProvider == nil) {
|
|
84
78
|
let customLocationProvider = CustomLocationProvider()
|
|
85
79
|
self.customLocationProvider = customLocationProvider
|
|
80
|
+
applyHeading()
|
|
81
|
+
if (!coordinate.isEmpty) {
|
|
82
|
+
applyCoordinate()
|
|
83
|
+
}
|
|
86
84
|
|
|
87
85
|
if let locationModule = RNMBXLocationModule.shared {
|
|
88
86
|
locationModule.locationProvider = customLocationProvider
|
|
@@ -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
|
|
@@ -155,7 +155,33 @@ class RNMBXCameraChanged : RNMBXEvent, RCTEvent {
|
|
|
155
155
|
|
|
156
156
|
@objc(RNMBXMapView)
|
|
157
157
|
open class RNMBXMapView: UIView, RCTInvalidating {
|
|
158
|
-
|
|
158
|
+
|
|
159
|
+
// Backward compatibility single-delegate property; internally we maintain a weak set.
|
|
160
|
+
public weak var rnmbxGestures: GestureManagerDelegate? {
|
|
161
|
+
didSet {
|
|
162
|
+
if let old = oldValue { _gestureDelegates.remove(old as AnyObject) }
|
|
163
|
+
if let d = rnmbxGestures { _gestureDelegates.add(d as AnyObject) }
|
|
164
|
+
#if DEBUG
|
|
165
|
+
print("[RNMBXMapView] rnmbxGestures didSet; delegates=\(_gestureDelegates.allObjects.count)")
|
|
166
|
+
#endif
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
private var _gestureDelegates: NSHashTable<AnyObject> = NSHashTable.weakObjects()
|
|
170
|
+
|
|
171
|
+
public func addGestureDelegate(_ delegate: GestureManagerDelegate) {
|
|
172
|
+
_gestureDelegates.add(delegate as AnyObject)
|
|
173
|
+
#if DEBUG
|
|
174
|
+
print("[RNMBXMapView] addGestureDelegate; delegates=\(_gestureDelegates.allObjects.count)")
|
|
175
|
+
#endif
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
public func removeGestureDelegate(_ delegate: GestureManagerDelegate) {
|
|
179
|
+
_gestureDelegates.remove(delegate as AnyObject)
|
|
180
|
+
#if DEBUG
|
|
181
|
+
print("[RNMBXMapView] removeGestureDelegate; delegates=\(_gestureDelegates.allObjects.count)")
|
|
182
|
+
#endif
|
|
183
|
+
}
|
|
184
|
+
|
|
159
185
|
public func invalidate() {
|
|
160
186
|
self.removeAllFeaturesFromMap(reason: .ViewRemoval)
|
|
161
187
|
|
|
@@ -163,14 +189,14 @@ open class RNMBXMapView: UIView, RCTInvalidating {
|
|
|
163
189
|
cancelables.forEach { $0.cancel() }
|
|
164
190
|
cancelables.removeAll()
|
|
165
191
|
#endif
|
|
166
|
-
|
|
192
|
+
|
|
167
193
|
_mapView.gestures.delegate = nil
|
|
168
194
|
_mapView.removeFromSuperview()
|
|
169
195
|
_mapView = nil
|
|
170
|
-
|
|
196
|
+
|
|
171
197
|
self.removeFromSuperview()
|
|
172
198
|
}
|
|
173
|
-
|
|
199
|
+
|
|
174
200
|
var imageManager: ImageManager = ImageManager()
|
|
175
201
|
|
|
176
202
|
var tapDelegate: IgnoreRNMBXMakerViewGestureDelegate? = nil
|
|
@@ -269,7 +295,27 @@ open class RNMBXMapView: UIView, RCTInvalidating {
|
|
|
269
295
|
|
|
270
296
|
@objc public func addToMap(_ subview: UIView) {
|
|
271
297
|
withMapView { mapView in
|
|
272
|
-
|
|
298
|
+
// Check for RNMBXMapAndMapViewComponent first (requires MapView)
|
|
299
|
+
if let mapAndMapViewComponent = subview as? RNMBXMapAndMapViewComponent {
|
|
300
|
+
let style = mapView.mapboxMap.style
|
|
301
|
+
var addToMap = false
|
|
302
|
+
if mapAndMapViewComponent.waitForStyleLoad() {
|
|
303
|
+
if (self.styleLoadWaiters.hasInited()) {
|
|
304
|
+
addToMap = true
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
addToMap = true
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
let entry = FeatureEntry(feature: mapAndMapViewComponent, view: subview, addedToMap: false)
|
|
311
|
+
if (addToMap) {
|
|
312
|
+
mapAndMapViewComponent.addToMap(self, mapView: mapView, style: style)
|
|
313
|
+
entry.addedToMap = true
|
|
314
|
+
}
|
|
315
|
+
self.features.append(entry)
|
|
316
|
+
}
|
|
317
|
+
// Fallback to RNMBXMapComponent (doesn't require MapView)
|
|
318
|
+
else if let mapComponent = subview as? RNMBXMapComponent {
|
|
273
319
|
let style = mapView.mapboxMap.style
|
|
274
320
|
var addToMap = false
|
|
275
321
|
if mapComponent.waitForStyleLoad() {
|
|
@@ -296,7 +342,26 @@ open class RNMBXMapView: UIView, RCTInvalidating {
|
|
|
296
342
|
}
|
|
297
343
|
|
|
298
344
|
@objc public func removeFromMap(_ subview: UIView) {
|
|
299
|
-
|
|
345
|
+
// Check for RNMBXMapAndMapViewComponent first (requires MapView)
|
|
346
|
+
if let mapAndMapViewComponent = subview as? RNMBXMapAndMapViewComponent {
|
|
347
|
+
var entryIndex = features.firstIndex { $0.view == subview }
|
|
348
|
+
if let entryIndex = entryIndex {
|
|
349
|
+
var entry = features[entryIndex]
|
|
350
|
+
if (entry.addedToMap) {
|
|
351
|
+
// mapView should always be non-nil here if our invariants hold
|
|
352
|
+
guard let mapView = _mapView else {
|
|
353
|
+
Logger.error("RNMBXMapView.removeFromMap: CRITICAL - mapView is nil for component that requires it: \(type(of: subview))")
|
|
354
|
+
features.remove(at: entryIndex)
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
mapAndMapViewComponent.removeFromMap(self, mapView: mapView, reason: .OnDestroy)
|
|
358
|
+
entry.addedToMap = false
|
|
359
|
+
}
|
|
360
|
+
features.remove(at: entryIndex)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// Fallback to RNMBXMapComponent (doesn't require MapView)
|
|
364
|
+
else if let mapComponent = subview as? RNMBXMapComponent {
|
|
300
365
|
var entryIndex = features.firstIndex { $0.view == subview }
|
|
301
366
|
if let entryIndex = entryIndex {
|
|
302
367
|
var entry = features[entryIndex]
|
|
@@ -842,16 +907,39 @@ open class RNMBXMapView: UIView, RCTInvalidating {
|
|
|
842
907
|
private func removeAllFeaturesFromMap(reason: RemovalReason) {
|
|
843
908
|
features.forEach { entry in
|
|
844
909
|
if (entry.addedToMap) {
|
|
845
|
-
|
|
910
|
+
// Handle RNMBXMapAndMapViewComponent
|
|
911
|
+
if let mapAndMapViewComponent = entry.feature as? RNMBXMapAndMapViewComponent {
|
|
912
|
+
guard let mapView = _mapView else {
|
|
913
|
+
Logger.error("RNMBXMapView.removeAllFeaturesFromMap: mapView is nil")
|
|
914
|
+
return
|
|
915
|
+
}
|
|
916
|
+
mapAndMapViewComponent.removeFromMap(self, mapView: mapView, reason: reason)
|
|
917
|
+
}
|
|
918
|
+
// Handle RNMBXMapComponent
|
|
919
|
+
else if let mapComponent = entry.feature as? RNMBXMapComponent {
|
|
920
|
+
mapComponent.removeFromMap(self, reason: reason)
|
|
921
|
+
}
|
|
846
922
|
entry.addedToMap = false
|
|
847
923
|
}
|
|
848
924
|
}
|
|
849
925
|
}
|
|
850
926
|
|
|
851
927
|
private func addFeaturesToMap(style: Style) {
|
|
928
|
+
guard let mapView = _mapView else {
|
|
929
|
+
Logger.error("RNMBXMapView.addFeaturesToMap: mapView is nil")
|
|
930
|
+
return
|
|
931
|
+
}
|
|
932
|
+
|
|
852
933
|
features.forEach { entry in
|
|
853
934
|
if (!entry.addedToMap) {
|
|
854
|
-
|
|
935
|
+
// Handle RNMBXMapAndMapViewComponent
|
|
936
|
+
if let mapAndMapViewComponent = entry.feature as? RNMBXMapAndMapViewComponent {
|
|
937
|
+
mapAndMapViewComponent.addToMap(self, mapView: mapView, style: style)
|
|
938
|
+
}
|
|
939
|
+
// Handle RNMBXMapComponent
|
|
940
|
+
else if let mapComponent = entry.feature as? RNMBXMapComponent {
|
|
941
|
+
mapComponent.addToMap(self, style: style)
|
|
942
|
+
}
|
|
855
943
|
entry.addedToMap = true
|
|
856
944
|
}
|
|
857
945
|
}
|
|
@@ -1407,17 +1495,35 @@ extension RNMBXMapView: GestureManagerDelegate {
|
|
|
1407
1495
|
}
|
|
1408
1496
|
|
|
1409
1497
|
public func gestureManager(_ gestureManager: GestureManager, didBegin gestureType: GestureType) {
|
|
1498
|
+
#if DEBUG
|
|
1499
|
+
print("[RNMBXMapView] gesture didBegin type=\(gestureType) delegates=\(_gestureDelegates.allObjects.count)")
|
|
1500
|
+
#endif
|
|
1501
|
+
for case let d as GestureManagerDelegate in _gestureDelegates.allObjects {
|
|
1502
|
+
d.gestureManager(gestureManager, didBegin: gestureType)
|
|
1503
|
+
}
|
|
1410
1504
|
isGestureActive = true
|
|
1411
1505
|
}
|
|
1412
1506
|
|
|
1413
1507
|
public func gestureManager(_ gestureManager: GestureManager, didEnd gestureType: GestureType, willAnimate: Bool) {
|
|
1508
|
+
#if DEBUG
|
|
1509
|
+
print("[RNMBXMapView] gesture didEnd type=\(gestureType) willAnimate=\(willAnimate) delegates=\(_gestureDelegates.allObjects.count)")
|
|
1510
|
+
#endif
|
|
1511
|
+
for case let d as GestureManagerDelegate in _gestureDelegates.allObjects {
|
|
1512
|
+
d.gestureManager(gestureManager, didEnd: gestureType, willAnimate: willAnimate)
|
|
1513
|
+
}
|
|
1414
1514
|
if !willAnimate {
|
|
1415
|
-
isGestureActive = false
|
|
1515
|
+
isGestureActive = false
|
|
1416
1516
|
}
|
|
1417
1517
|
}
|
|
1418
1518
|
|
|
1419
1519
|
public func gestureManager(_ gestureManager: GestureManager, didEndAnimatingFor gestureType: GestureType) {
|
|
1420
|
-
|
|
1520
|
+
#if DEBUG
|
|
1521
|
+
print("[RNMBXMapView] gesture didEndAnimatingFor type=\(gestureType) delegates=\(_gestureDelegates.allObjects.count)")
|
|
1522
|
+
#endif
|
|
1523
|
+
for case let d as GestureManagerDelegate in _gestureDelegates.allObjects {
|
|
1524
|
+
d.gestureManager(gestureManager, didEndAnimatingFor: gestureType)
|
|
1525
|
+
}
|
|
1526
|
+
isGestureActive = false
|
|
1421
1527
|
}
|
|
1422
1528
|
}
|
|
1423
1529
|
|
|
@@ -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
|