@maplibre/maplibre-react-native 10.1.0 → 10.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/MLRN/CameraStop.h +1 -1
- package/ios/MLRN/CameraStop.m +58 -60
- package/ios/MLRN/CameraUpdateItem.h +2 -1
- package/ios/MLRN/CameraUpdateItem.m +132 -132
- package/ios/MLRN/CameraUpdateQueue.m +43 -47
- package/ios/MLRN/FilterParser.h +1 -1
- package/ios/MLRN/FilterParser.m +5 -6
- package/ios/MLRN/MLRNBackgroundLayer.m +10 -9
- package/ios/MLRN/MLRNBackgroundLayerManager.m +4 -5
- package/ios/MLRN/MLRNCallout.h +1 -1
- package/ios/MLRN/MLRNCallout.m +37 -36
- package/ios/MLRN/MLRNCalloutManager.m +2 -3
- package/ios/MLRN/MLRNCamera.h +1 -1
- package/ios/MLRN/MLRNCamera.m +169 -182
- package/ios/MLRN/MLRNCameraManager.m +4 -6
- package/ios/MLRN/MLRNCircleLayer.m +17 -14
- package/ios/MLRN/MLRNCircleLayerManager.m +4 -5
- package/ios/MLRN/MLRNCustomHeaders.h +2 -2
- package/ios/MLRN/MLRNCustomHeaders.m +63 -63
- package/ios/MLRN/MLRNEvent.h +3 -3
- package/ios/MLRN/MLRNEvent.m +19 -24
- package/ios/MLRN/MLRNEventProtocol.h +1 -1
- package/ios/MLRN/MLRNFillExtrusionLayer.m +18 -14
- package/ios/MLRN/MLRNFillExtrusionLayerManager.m +4 -5
- package/ios/MLRN/MLRNFillLayer.m +16 -14
- package/ios/MLRN/MLRNFillLayerManager.m +4 -5
- package/ios/MLRN/MLRNHeatmapLayer.m +17 -14
- package/ios/MLRN/MLRNHeatmapLayerManager.m +4 -5
- package/ios/MLRN/MLRNImageQueue.h +4 -1
- package/ios/MLRN/MLRNImageQueue.m +29 -32
- package/ios/MLRN/MLRNImageQueueOperation.h +1 -1
- package/ios/MLRN/MLRNImageQueueOperation.m +92 -91
- package/ios/MLRN/MLRNImageSource.m +36 -38
- package/ios/MLRN/MLRNImageSourceManager.m +2 -3
- package/ios/MLRN/MLRNImageUtils.h +3 -3
- package/ios/MLRN/MLRNImageUtils.m +15 -14
- package/ios/MLRN/MLRNImages.h +0 -1
- package/ios/MLRN/MLRNImages.m +89 -91
- package/ios/MLRN/MLRNImagesManager.m +4 -5
- package/ios/MLRN/MLRNLayer.h +9 -11
- package/ios/MLRN/MLRNLayer.m +170 -182
- package/ios/MLRN/MLRNLight.m +21 -23
- package/ios/MLRN/MLRNLightManager.m +2 -3
- package/ios/MLRN/MLRNLineLayer.m +17 -15
- package/ios/MLRN/MLRNLineLayerManager.m +4 -6
- package/ios/MLRN/MLRNLocation.h +1 -1
- package/ios/MLRN/MLRNLocation.m +16 -17
- package/ios/MLRN/MLRNLocationManager.m +109 -124
- package/ios/MLRN/MLRNLocationManagerDelegate.h +3 -3
- package/ios/MLRN/MLRNLocationModule.h +1 -1
- package/ios/MLRN/MLRNLocationModule.m +40 -55
- package/ios/MLRN/MLRNLogging.h +1 -4
- package/ios/MLRN/MLRNLogging.m +84 -89
- package/ios/MLRN/MLRNMapTouchEvent.h +2 -2
- package/ios/MLRN/MLRNMapTouchEvent.m +50 -49
- package/ios/MLRN/MLRNMapView.h +43 -36
- package/ios/MLRN/MLRNMapView.m +409 -440
- package/ios/MLRN/MLRNMapViewManager.m +489 -502
- package/ios/MLRN/MLRNModule.h +1 -1
- package/ios/MLRN/MLRNModule.m +111 -105
- package/ios/MLRN/MLRNNativeUserLocation.m +24 -27
- package/ios/MLRN/MLRNNativeUserLocationManager.m +4 -8
- package/ios/MLRN/MLRNOfflineModule.h +1 -1
- package/ios/MLRN/MLRNOfflineModule.m +416 -421
- package/ios/MLRN/MLRNPointAnnotation.h +2 -2
- package/ios/MLRN/MLRNPointAnnotation.m +154 -175
- package/ios/MLRN/MLRNPointAnnotationManager.m +2 -3
- package/ios/MLRN/MLRNRasterLayer.m +16 -12
- package/ios/MLRN/MLRNRasterLayerManager.m +4 -5
- package/ios/MLRN/MLRNRasterSource.m +21 -17
- package/ios/MLRN/MLRNRasterSourceManager.m +2 -3
- package/ios/MLRN/MLRNShapeSource.h +17 -16
- package/ios/MLRN/MLRNShapeSource.m +94 -102
- package/ios/MLRN/MLRNShapeSourceManager.h +2 -2
- package/ios/MLRN/MLRNShapeSourceManager.m +86 -90
- package/ios/MLRN/MLRNSnapshotModule.h +1 -1
- package/ios/MLRN/MLRNSnapshotModule.m +51 -53
- package/ios/MLRN/MLRNSource.h +12 -12
- package/ios/MLRN/MLRNSource.m +82 -88
- package/ios/MLRN/MLRNStyleValue.h +1 -1
- package/ios/MLRN/MLRNStyleValue.m +128 -128
- package/ios/MLRN/MLRNSymbolLayer.m +17 -13
- package/ios/MLRN/MLRNSymbolLayerManager.m +4 -5
- package/ios/MLRN/MLRNTileSource.h +1 -1
- package/ios/MLRN/MLRNTileSource.m +21 -20
- package/ios/MLRN/MLRNUserLocation.h +1 -1
- package/ios/MLRN/MLRNUserLocation.m +10 -12
- package/ios/MLRN/MLRNUtils.h +18 -11
- package/ios/MLRN/MLRNUtils.m +168 -160
- package/ios/MLRN/MLRNVectorLayer.m +28 -34
- package/ios/MLRN/MLRNVectorSource.h +3 -1
- package/ios/MLRN/MLRNVectorSource.m +14 -11
- package/ios/MLRN/MLRNVectorSourceManager.h +2 -2
- package/ios/MLRN/MLRNVectorSourceManager.m +36 -39
- package/ios/MLRN/ViewManager.h +1 -1
- package/ios/MLRN/ViewManager.m +29 -35
- package/lib/commonjs/components/MarkerView.js +1 -1
- package/lib/commonjs/components/ShapeSource.js +2 -1
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/UserLocation.js +8 -38
- package/lib/commonjs/components/UserLocation.js.map +1 -1
- package/lib/commonjs/components/UserLocationPuck.js +52 -0
- package/lib/commonjs/components/UserLocationPuck.js.map +1 -0
- package/lib/commonjs/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +12 -9
- package/lib/commonjs/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +8 -7
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -2
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js +28 -38
- package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedShape.js +11 -7
- package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/module/components/MarkerView.js +1 -1
- package/lib/module/components/ShapeSource.js +2 -1
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/UserLocation.js +7 -36
- package/lib/module/components/UserLocation.js.map +1 -1
- package/lib/module/components/UserLocationPuck.js +48 -0
- package/lib/module/components/UserLocationPuck.js.map +1 -0
- package/lib/module/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +11 -7
- package/lib/module/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +8 -7
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -3
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js +29 -39
- package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
- package/lib/module/utils/animated/AnimatedShape.js +11 -7
- package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/typescript/commonjs/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
- package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +8 -5
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
- package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +8 -5
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/MarkerView.tsx +1 -1
- package/src/components/ShapeSource.tsx +58 -53
- package/src/components/UserLocation.tsx +13 -51
- package/src/components/UserLocationPuck.tsx +62 -0
- package/src/components/UserLocationPuckHeading.tsx +33 -0
- package/src/utils/animated/AbstractAnimatedCoordinates.ts +26 -15
- package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +10 -6
- package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +63 -51
- package/src/utils/animated/AnimatedShape.ts +22 -13
- package/lib/commonjs/components/HeadingIndicator.js.map +0 -1
- package/lib/module/components/HeadingIndicator.js.map +0 -1
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts.map +0 -1
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts.map +0 -1
- package/src/components/HeadingIndicator.tsx +0 -26
package/ios/MLRN/MLRNMapView.m
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
#import "MLRNMapView.h"
|
|
2
|
+
#import <React/UIView+React.h>
|
|
2
3
|
#import "CameraUpdateQueue.h"
|
|
3
|
-
#import "MLRNUtils.h"
|
|
4
4
|
#import "MLRNImageUtils.h"
|
|
5
5
|
#import "MLRNImages.h"
|
|
6
|
-
#import <React/UIView+React.h>
|
|
7
|
-
#import "MLRNNativeUserLocation.h"
|
|
8
6
|
#import "MLRNLogging.h"
|
|
7
|
+
#import "MLRNNativeUserLocation.h"
|
|
8
|
+
#import "MLRNUtils.h"
|
|
9
9
|
|
|
10
|
-
@implementation MLRNMapView
|
|
11
|
-
|
|
12
|
-
BOOL _pendingInitialLayout;
|
|
10
|
+
@implementation MLRNMapView {
|
|
11
|
+
BOOL _pendingInitialLayout;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
static double const DEG2RAD = M_PI / 180;
|
|
@@ -18,511 +17,481 @@ static double const TILE_SIZE = 256;
|
|
|
18
17
|
static double const EARTH_RADIUS_M = 6378137;
|
|
19
18
|
static double const M2PI = M_PI * 2;
|
|
20
19
|
|
|
21
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
NSMutableArray* waiters = [_layerWaiters valueForKey:layerID];
|
|
62
|
-
if (waiters) {
|
|
63
|
-
for (FoundLayerBlock foundLayerBlock in waiters) {
|
|
64
|
-
foundLayerBlock(layer);
|
|
65
|
-
}
|
|
66
|
-
[_layerWaiters removeObjectForKey:layerID];
|
|
20
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
21
|
+
if (self = [super initWithFrame:frame]) {
|
|
22
|
+
_pendingInitialLayout = YES;
|
|
23
|
+
_cameraUpdateQueue = [[CameraUpdateQueue alloc] init];
|
|
24
|
+
_sources = [[NSMutableArray alloc] init];
|
|
25
|
+
_images = [[NSMutableArray alloc] init];
|
|
26
|
+
_layers = [[NSMutableArray alloc] init];
|
|
27
|
+
_pointAnnotations = [[NSMutableArray alloc] init];
|
|
28
|
+
_reactSubviews = [[NSMutableArray alloc] init];
|
|
29
|
+
_layerWaiters = [[NSMutableDictionary alloc] init];
|
|
30
|
+
_styleWaiters = [[NSMutableArray alloc] init];
|
|
31
|
+
_logging = [[MLRNLogging alloc] init];
|
|
32
|
+
}
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)layoutSubviews {
|
|
37
|
+
[super layoutSubviews];
|
|
38
|
+
if (_pendingInitialLayout) {
|
|
39
|
+
_pendingInitialLayout = NO;
|
|
40
|
+
|
|
41
|
+
[_reactCamera initialLayout];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
- (void)invalidate {
|
|
46
|
+
if (_reactSubviews.count == 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
for (int i = 0; i < _reactSubviews.count; i++) {
|
|
50
|
+
[self removeFromMap:_reactSubviews[i]];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)layerAdded:(MLNStyleLayer *)layer {
|
|
55
|
+
NSString *layerID = layer.identifier;
|
|
56
|
+
NSMutableArray *waiters = [_layerWaiters valueForKey:layerID];
|
|
57
|
+
if (waiters) {
|
|
58
|
+
for (FoundLayerBlock foundLayerBlock in waiters) {
|
|
59
|
+
foundLayerBlock(layer);
|
|
67
60
|
}
|
|
61
|
+
[_layerWaiters removeObjectForKey:layerID];
|
|
62
|
+
}
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
- (void)waitForLayerWithID:(nonnull NSString*)layerID
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
NSMutableArray* existingWaiters = [_layerWaiters valueForKey:layerID];
|
|
77
|
-
|
|
78
|
-
NSMutableArray* waiters = existingWaiters;
|
|
79
|
-
if (waiters == nil) {
|
|
80
|
-
waiters = [[NSMutableArray alloc] init];
|
|
81
|
-
}
|
|
82
|
-
[waiters addObject:foundLayer];
|
|
83
|
-
if (! existingWaiters) {
|
|
84
|
-
[_layerWaiters setObject:waiters forKey:layerID];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
65
|
+
- (void)waitForLayerWithID:(nonnull NSString *)layerID
|
|
66
|
+
then:(void (^)(MLNStyleLayer *layer))foundLayer {
|
|
67
|
+
if (self.style) {
|
|
68
|
+
MLNStyleLayer *layer = [self.style layerWithIdentifier:layerID];
|
|
69
|
+
if (layer) {
|
|
70
|
+
foundLayer(layer);
|
|
87
71
|
} else {
|
|
88
|
-
|
|
72
|
+
NSMutableArray *existingWaiters = [_layerWaiters valueForKey:layerID];
|
|
73
|
+
|
|
74
|
+
NSMutableArray *waiters = existingWaiters;
|
|
75
|
+
if (waiters == nil) {
|
|
76
|
+
waiters = [[NSMutableArray alloc] init];
|
|
77
|
+
}
|
|
78
|
+
[waiters addObject:foundLayer];
|
|
79
|
+
if (!existingWaiters) {
|
|
80
|
+
[_layerWaiters setObject:waiters forKey:layerID];
|
|
81
|
+
}
|
|
89
82
|
}
|
|
83
|
+
} else {
|
|
84
|
+
// TODO
|
|
85
|
+
}
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
- (void)getStyle:(void (^)(MLNStyle*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
- (void)getStyle:(void (^)(MLNStyle *style))onStyleLoaded {
|
|
89
|
+
if (self.style) {
|
|
90
|
+
onStyleLoaded(self.style);
|
|
91
|
+
} else {
|
|
92
|
+
[_styleWaiters addObject:onStyleLoaded];
|
|
93
|
+
}
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
- (void)notifyStyleLoaded {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
if (!self.style) return;
|
|
98
|
+
for (StyleLoadedBlock styleLoadedBlock in self.styleWaiters) {
|
|
99
|
+
styleLoadedBlock(self.style);
|
|
100
|
+
}
|
|
101
|
+
[self.styleWaiters removeAllObjects];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
- (void)addToMap:(id<RCTComponent>)subview {
|
|
105
|
+
if ([subview isKindOfClass:[MLRNSource class]]) {
|
|
106
|
+
MLRNSource *source = (MLRNSource *)subview;
|
|
107
|
+
source.map = self;
|
|
108
|
+
[_sources addObject:(MLRNSource *)subview];
|
|
109
|
+
} else if ([subview isKindOfClass:[MLRNLight class]]) {
|
|
110
|
+
MLRNLight *light = (MLRNLight *)subview;
|
|
111
|
+
_light = light;
|
|
112
|
+
_light.map = self;
|
|
113
|
+
} else if ([subview isKindOfClass:[MLRNNativeUserLocation class]]) {
|
|
114
|
+
MLRNNativeUserLocation *nativeUserLocation = (MLRNNativeUserLocation *)subview;
|
|
115
|
+
nativeUserLocation.map = self;
|
|
116
|
+
} else if ([subview isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
117
|
+
MLRNPointAnnotation *pointAnnotation = (MLRNPointAnnotation *)subview;
|
|
118
|
+
pointAnnotation.map = self;
|
|
119
|
+
[_pointAnnotations addObject:pointAnnotation];
|
|
120
|
+
} else if ([subview isKindOfClass:[MLRNCamera class]]) {
|
|
121
|
+
MLRNCamera *camera = (MLRNCamera *)subview;
|
|
122
|
+
camera.map = self;
|
|
123
|
+
} else if ([subview isKindOfClass:[MLRNImages class]]) {
|
|
124
|
+
MLRNImages *images = (MLRNImages *)subview;
|
|
125
|
+
images.map = self;
|
|
126
|
+
[_images addObject:images];
|
|
127
|
+
} else if ([subview isKindOfClass:[MLRNLayer class]]) {
|
|
128
|
+
MLRNLayer *layer = (MLRNLayer *)subview;
|
|
129
|
+
layer.map = self;
|
|
130
|
+
[_layers addObject:layer];
|
|
131
|
+
} else {
|
|
132
|
+
NSArray<id<RCTComponent>> *childSubviews = [subview reactSubviews];
|
|
133
|
+
|
|
134
|
+
for (int i = 0; i < childSubviews.count; i++) {
|
|
135
|
+
[self addToMap:childSubviews[i]];
|
|
104
136
|
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
for (int i = 0; i < childSubviews.count; i++) {
|
|
141
|
-
[self addToMap:childSubviews[i]];
|
|
142
|
-
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (void)removeFromMap:(id<RCTComponent>)subview {
|
|
141
|
+
if ([subview isKindOfClass:[MLRNSource class]]) {
|
|
142
|
+
MLRNSource *source = (MLRNSource *)subview;
|
|
143
|
+
source.map = nil;
|
|
144
|
+
[_sources removeObject:source];
|
|
145
|
+
} else if ([subview isKindOfClass:[MLRNPointAnnotation class]]) {
|
|
146
|
+
MLRNPointAnnotation *pointAnnotation = (MLRNPointAnnotation *)subview;
|
|
147
|
+
pointAnnotation.map = nil;
|
|
148
|
+
[_pointAnnotations removeObject:pointAnnotation];
|
|
149
|
+
} else if ([subview isKindOfClass:[MLRNCamera class]]) {
|
|
150
|
+
MLRNCamera *camera = (MLRNCamera *)subview;
|
|
151
|
+
camera.map = nil;
|
|
152
|
+
} else if ([subview isKindOfClass:[MLRNImages class]]) {
|
|
153
|
+
MLRNImages *images = (MLRNImages *)subview;
|
|
154
|
+
images.map = nil;
|
|
155
|
+
[_images removeObject:images];
|
|
156
|
+
} else if ([subview isKindOfClass:[MLRNLayer class]]) {
|
|
157
|
+
MLRNLayer *layer = (MLRNLayer *)subview;
|
|
158
|
+
layer.map = nil;
|
|
159
|
+
[_layers removeObject:layer];
|
|
160
|
+
} else if ([subview isKindOfClass:[MLRNNativeUserLocation class]]) {
|
|
161
|
+
MLRNNativeUserLocation *nativeUserLocation = (MLRNNativeUserLocation *)subview;
|
|
162
|
+
nativeUserLocation.map = nil;
|
|
163
|
+
} else if ([subview isKindOfClass:[MLRNLight class]]) {
|
|
164
|
+
MLRNLight *light = (MLRNLight *)subview;
|
|
165
|
+
light.map = nil;
|
|
166
|
+
} else {
|
|
167
|
+
NSArray<id<RCTComponent>> *childSubViews = [subview reactSubviews];
|
|
168
|
+
|
|
169
|
+
for (int i = 0; i < childSubViews.count; i++) {
|
|
170
|
+
[self removeFromMap:childSubViews[i]];
|
|
143
171
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
nativeUserLocation.map = nil;
|
|
170
|
-
} else if ([subview isKindOfClass:[MLRNLight class]]) {
|
|
171
|
-
MLRNLight *light = (MLRNLight*)subview;
|
|
172
|
-
light.map = nil;
|
|
173
|
-
} else {
|
|
174
|
-
NSArray<id<RCTComponent>> *childSubViews = [subview reactSubviews];
|
|
175
|
-
|
|
176
|
-
for (int i = 0; i < childSubViews.count; i++) {
|
|
177
|
-
[self removeFromMap:childSubViews[i]];
|
|
172
|
+
}
|
|
173
|
+
if ([_layerWaiters count] > 0) {
|
|
174
|
+
RCTLogWarn(@"The following layers were waited on but never added to the map: %@",
|
|
175
|
+
[_layerWaiters allKeys]);
|
|
176
|
+
[_layerWaiters removeAllObjects];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)setSourceVisibility:(BOOL)visible
|
|
181
|
+
sourceId:(NSString *)sourceId
|
|
182
|
+
sourceLayerId:(NSString *)sourceLayerId {
|
|
183
|
+
__weak typeof(self) weakSelf = self;
|
|
184
|
+
[self getStyle:^(MLNStyle *style) {
|
|
185
|
+
__strong typeof(self) strongSelf = weakSelf;
|
|
186
|
+
for (MLNStyleLayer *layer in strongSelf.style.layers) {
|
|
187
|
+
if ([layer isKindOfClass:[MLNForegroundStyleLayer class]]) {
|
|
188
|
+
MLNForegroundStyleLayer *foregroundLayer = (MLNForegroundStyleLayer *)layer;
|
|
189
|
+
if (![foregroundLayer.sourceIdentifier isEqualToString:sourceId]) continue;
|
|
190
|
+
if (sourceLayerId == nil || sourceLayerId.length == 0) {
|
|
191
|
+
layer.visible = visible;
|
|
192
|
+
} else if ([layer isKindOfClass:[MLNVectorStyleLayer class]]) {
|
|
193
|
+
MLNVectorStyleLayer *vectorLayer = (MLNVectorStyleLayer *)layer;
|
|
194
|
+
if ([vectorLayer.sourceLayerIdentifier isEqualToString:sourceLayerId]) {
|
|
195
|
+
layer.visible = visible;
|
|
196
|
+
}
|
|
178
197
|
}
|
|
198
|
+
}
|
|
179
199
|
}
|
|
180
|
-
|
|
181
|
-
RCTLogWarn(@"The following layers were waited on but never added to the map: %@", [_layerWaiters allKeys]);
|
|
182
|
-
[_layerWaiters removeAllObjects];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
- (void)setSourceVisibility:(BOOL)visible sourceId:(NSString *)sourceId sourceLayerId:(NSString *)sourceLayerId {
|
|
187
|
-
__weak typeof(self) weakSelf = self;
|
|
188
|
-
[self getStyle:^(MLNStyle *style) {
|
|
189
|
-
__strong typeof(self) strongSelf = weakSelf;
|
|
190
|
-
for (MLNStyleLayer *layer in strongSelf.style.layers) {
|
|
191
|
-
if ([layer isKindOfClass:[MLNForegroundStyleLayer class]]) {
|
|
192
|
-
MLNForegroundStyleLayer *foregroundLayer = (MLNForegroundStyleLayer*)layer;
|
|
193
|
-
if (![foregroundLayer.sourceIdentifier isEqualToString:sourceId]) continue;
|
|
194
|
-
if (sourceLayerId == nil || sourceLayerId.length == 0) {
|
|
195
|
-
layer.visible = visible;
|
|
196
|
-
} else if ([layer isKindOfClass:[MLNVectorStyleLayer class]]) {
|
|
197
|
-
MLNVectorStyleLayer *vectorLayer = (MLNVectorStyleLayer*)layer;
|
|
198
|
-
if ([vectorLayer.sourceLayerIdentifier isEqualToString:sourceLayerId]) {
|
|
199
|
-
layer.visible = visible;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}];
|
|
200
|
+
}];
|
|
205
201
|
}
|
|
206
202
|
|
|
207
203
|
#pragma clang diagnostic push
|
|
208
204
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
209
205
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
[self addToMap:subview];
|
|
207
|
+
[_reactSubviews insertObject:(UIView *)subview atIndex:(NSUInteger)atIndex];
|
|
212
208
|
}
|
|
213
209
|
#pragma clang diagnostic pop
|
|
214
210
|
|
|
215
211
|
#pragma clang diagnostic push
|
|
216
212
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
217
213
|
- (void)removeReactSubview:(id<RCTComponent>)subview {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
// similarly, when the children are being removed we have to do the appropriate
|
|
215
|
+
// underlying mapview action here.
|
|
216
|
+
[self removeFromMap:subview];
|
|
217
|
+
[_reactSubviews removeObject:(UIView *)subview];
|
|
218
|
+
[(UIView *)subview removeFromSuperview];
|
|
223
219
|
}
|
|
224
220
|
#pragma clang diagnostic pop
|
|
225
221
|
|
|
226
222
|
#pragma clang diagnostic push
|
|
227
223
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
228
224
|
- (NSArray<id<RCTComponent>> *)reactSubviews {
|
|
229
|
-
|
|
225
|
+
return _reactSubviews;
|
|
230
226
|
}
|
|
231
227
|
#pragma clang diagnostic pop
|
|
232
228
|
|
|
233
|
-
- (void)setReactZoomEnabled:(BOOL)reactZoomEnabled
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
{
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
self
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
229
|
+
- (void)setReactZoomEnabled:(BOOL)reactZoomEnabled {
|
|
230
|
+
_reactZoomEnabled = reactZoomEnabled;
|
|
231
|
+
self.zoomEnabled = _reactZoomEnabled;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
- (void)setReactScrollEnabled:(BOOL)reactScrollEnabled {
|
|
235
|
+
_reactScrollEnabled = reactScrollEnabled;
|
|
236
|
+
self.scrollEnabled = _reactScrollEnabled;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
- (void)setReactPitchEnabled:(BOOL)reactPitchEnabled {
|
|
240
|
+
_reactPitchEnabled = reactPitchEnabled;
|
|
241
|
+
self.pitchEnabled = _reactPitchEnabled;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
- (void)setReactRotateEnabled:(BOOL)reactRotateEnabled {
|
|
245
|
+
_reactRotateEnabled = reactRotateEnabled;
|
|
246
|
+
self.rotateEnabled = _reactRotateEnabled;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
- (void)setReactAttributionEnabled:(BOOL)reactAttributionEnabled {
|
|
250
|
+
_reactAttributionEnabled = reactAttributionEnabled;
|
|
251
|
+
self.attributionButton.hidden = !_reactAttributionEnabled;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
- (void)setReactAttributionPosition:(NSDictionary<NSString *, NSNumber *> *)position {
|
|
255
|
+
NSNumber *left = [position valueForKey:@"left"];
|
|
256
|
+
NSNumber *right = [position valueForKey:@"right"];
|
|
257
|
+
NSNumber *top = [position valueForKey:@"top"];
|
|
258
|
+
NSNumber *bottom = [position valueForKey:@"bottom"];
|
|
259
|
+
if (left != nil && top != nil) {
|
|
260
|
+
[self setAttributionButtonPosition:MLNOrnamentPositionTopLeft];
|
|
261
|
+
[self setAttributionButtonMargins:CGPointMake([left floatValue], [top floatValue])];
|
|
262
|
+
} else if (right != nil && top != nil) {
|
|
263
|
+
[self setAttributionButtonPosition:MLNOrnamentPositionTopRight];
|
|
264
|
+
[self setAttributionButtonMargins:CGPointMake([right floatValue], [top floatValue])];
|
|
265
|
+
} else if (bottom != nil && right != nil) {
|
|
266
|
+
[self setAttributionButtonPosition:MLNOrnamentPositionBottomRight];
|
|
267
|
+
[self setAttributionButtonMargins:CGPointMake([right floatValue], [bottom floatValue])];
|
|
268
|
+
} else if (bottom != nil && left != nil) {
|
|
269
|
+
[self setAttributionButtonPosition:MLNOrnamentPositionBottomLeft];
|
|
270
|
+
[self setAttributionButtonMargins:CGPointMake([left floatValue], [bottom floatValue])];
|
|
271
|
+
} else {
|
|
272
|
+
[self setAttributionButtonPosition:MLNOrnamentPositionBottomRight];
|
|
273
|
+
// same as MLNOrnamentDefaultPositionOffset in MLNMapView.mm
|
|
274
|
+
[self setAttributionButtonMargins:CGPointMake(8, 8)];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
- (void)setReactLogoEnabled:(BOOL)reactLogoEnabled {
|
|
279
|
+
_reactLogoEnabled = reactLogoEnabled;
|
|
280
|
+
self.logoView.hidden = !_reactLogoEnabled;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
- (void)setReactLogoPosition:(NSDictionary<NSString *, NSNumber *> *)logoPosition {
|
|
284
|
+
NSNumber *left = [logoPosition valueForKey:@"left"];
|
|
285
|
+
NSNumber *right = [logoPosition valueForKey:@"right"];
|
|
286
|
+
NSNumber *top = [logoPosition valueForKey:@"top"];
|
|
287
|
+
NSNumber *bottom = [logoPosition valueForKey:@"bottom"];
|
|
288
|
+
if (left != nil && top != nil) {
|
|
289
|
+
[self setLogoViewPosition:MLNOrnamentPositionTopLeft];
|
|
290
|
+
[self setLogoViewMargins:CGPointMake([left floatValue], [top floatValue])];
|
|
291
|
+
} else if (right != nil && top != nil) {
|
|
292
|
+
[self setLogoViewPosition:MLNOrnamentPositionTopRight];
|
|
293
|
+
[self setLogoViewMargins:CGPointMake([right floatValue], [top floatValue])];
|
|
294
|
+
} else if (bottom != nil && right != nil) {
|
|
295
|
+
[self setLogoViewPosition:MLNOrnamentPositionBottomRight];
|
|
296
|
+
[self setLogoViewMargins:CGPointMake([right floatValue], [bottom floatValue])];
|
|
297
|
+
} else if (bottom != nil && left != nil) {
|
|
298
|
+
[self setLogoViewPosition:MLNOrnamentPositionBottomLeft];
|
|
299
|
+
[self setLogoViewMargins:CGPointMake([left floatValue], [bottom floatValue])];
|
|
300
|
+
} else {
|
|
301
|
+
[self setLogoViewPosition:MLNOrnamentPositionBottomRight];
|
|
302
|
+
[self setLogoViewMargins:CGPointMake(8, 8)];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
- (void)setReactCompassEnabled:(BOOL)reactCompassEnabled {
|
|
307
|
+
_reactCompassEnabled = reactCompassEnabled;
|
|
308
|
+
self.compassView.hidden = !_reactCompassEnabled;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
- (void)setReactCompassViewPosition:(NSInteger)reactCompassViewPosition {
|
|
312
|
+
if (!self.compassView.hidden) {
|
|
313
|
+
_reactCompassViewPosition = reactCompassViewPosition;
|
|
314
|
+
self.compassViewPosition = _reactCompassViewPosition;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
- (void)setReactCompassViewMargins:(CGPoint)reactCompassViewMargins {
|
|
319
|
+
if (!self.compassView.hidden) {
|
|
320
|
+
CGPoint point;
|
|
321
|
+
point = reactCompassViewMargins;
|
|
322
|
+
self.compassViewMargins = point;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
- (void)setReactShowUserLocation:(BOOL)reactShowUserLocation {
|
|
327
|
+
// FMTODO
|
|
328
|
+
//_reactShowUserLocation = reactShowUserLocation;
|
|
329
|
+
self.showsUserLocation = reactShowUserLocation; //_reactShowUserLocation;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
- (void)setReactContentInset:(NSArray<NSNumber *> *)reactContentInset {
|
|
333
|
+
CGFloat top = 0.0f, right = 0.0f, left = 0.0f, bottom = 0.0f;
|
|
334
|
+
|
|
335
|
+
if (reactContentInset.count == 4) {
|
|
336
|
+
top = [reactContentInset[0] floatValue];
|
|
337
|
+
right = [reactContentInset[1] floatValue];
|
|
338
|
+
bottom = [reactContentInset[2] floatValue];
|
|
339
|
+
left = [reactContentInset[3] floatValue];
|
|
340
|
+
} else if (reactContentInset.count == 2) {
|
|
341
|
+
top = [reactContentInset[0] floatValue];
|
|
342
|
+
right = [reactContentInset[1] floatValue];
|
|
343
|
+
bottom = [reactContentInset[0] floatValue];
|
|
344
|
+
left = [reactContentInset[1] floatValue];
|
|
345
|
+
} else if (reactContentInset.count == 1) {
|
|
346
|
+
top = [reactContentInset[0] floatValue];
|
|
347
|
+
right = [reactContentInset[0] floatValue];
|
|
348
|
+
bottom = [reactContentInset[0] floatValue];
|
|
349
|
+
left = [reactContentInset[0] floatValue];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
self.contentInset = UIEdgeInsetsMake(top, left, bottom, right);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
- (void)setReactMapStyle:(NSString *)reactMapStyle {
|
|
356
|
+
_reactMapStyle = reactMapStyle;
|
|
357
|
+
[self _removeAllSourcesFromMap];
|
|
358
|
+
self.styleURL = [self _getStyleURLFromKey:_reactMapStyle];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
- (void)setReactPreferredFramesPerSecond:(NSInteger)reactPreferredFramesPerSecond {
|
|
362
|
+
self.preferredFramesPerSecond = reactPreferredFramesPerSecond;
|
|
319
363
|
}
|
|
320
364
|
|
|
321
|
-
-
|
|
322
|
-
{
|
|
323
|
-
_reactCompassEnabled = reactCompassEnabled;
|
|
324
|
-
self.compassView.hidden = !_reactCompassEnabled;
|
|
325
|
-
}
|
|
365
|
+
#pragma mark - methods
|
|
326
366
|
|
|
327
|
-
- (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
367
|
+
- (NSString *)takeSnap:(BOOL)writeToDisk {
|
|
368
|
+
UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0);
|
|
369
|
+
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
|
|
370
|
+
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
|
|
371
|
+
UIGraphicsEndImageContext();
|
|
372
|
+
return writeToDisk ? [MLRNImageUtils createTempFile:snapshot]
|
|
373
|
+
: [MLRNImageUtils createBase64:snapshot];
|
|
334
374
|
}
|
|
335
375
|
|
|
336
|
-
- (
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
point = reactCompassViewMargins;
|
|
342
|
-
self.compassViewMargins = point;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
376
|
+
- (CLLocationDistance)getMetersPerPixelAtLatitude:(double)latitude withZoom:(double)zoomLevel {
|
|
377
|
+
double constrainedZoom =
|
|
378
|
+
[[MLRNUtils clamp:[NSNumber numberWithDouble:zoomLevel]
|
|
379
|
+
min:[NSNumber numberWithDouble:self.minimumZoomLevel]
|
|
380
|
+
max:[NSNumber numberWithDouble:self.maximumZoomLevel]] doubleValue];
|
|
345
381
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
//_reactShowUserLocation = reactShowUserLocation;
|
|
350
|
-
self.showsUserLocation = reactShowUserLocation; //_reactShowUserLocation;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
- (void)setReactContentInset:(NSArray<NSNumber *> *)reactContentInset
|
|
354
|
-
{
|
|
355
|
-
CGFloat top = 0.0f, right = 0.0f, left = 0.0f, bottom = 0.0f;
|
|
356
|
-
|
|
357
|
-
if (reactContentInset.count == 4) {
|
|
358
|
-
top = [reactContentInset[0] floatValue];
|
|
359
|
-
right = [reactContentInset[1] floatValue];
|
|
360
|
-
bottom = [reactContentInset[2] floatValue];
|
|
361
|
-
left = [reactContentInset[3] floatValue];
|
|
362
|
-
} else if (reactContentInset.count == 2) {
|
|
363
|
-
top = [reactContentInset[0] floatValue];
|
|
364
|
-
right = [reactContentInset[1] floatValue];
|
|
365
|
-
bottom = [reactContentInset[0] floatValue];
|
|
366
|
-
left = [reactContentInset[1] floatValue];
|
|
367
|
-
} else if (reactContentInset.count == 1) {
|
|
368
|
-
top = [reactContentInset[0] floatValue];
|
|
369
|
-
right = [reactContentInset[0] floatValue];
|
|
370
|
-
bottom = [reactContentInset[0] floatValue];
|
|
371
|
-
left = [reactContentInset[0] floatValue];
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
self.contentInset = UIEdgeInsetsMake(top, left, bottom, right);
|
|
375
|
-
}
|
|
382
|
+
double constrainedLatitude = [[MLRNUtils clamp:[NSNumber numberWithDouble:latitude]
|
|
383
|
+
min:[NSNumber numberWithDouble:-LAT_MAX]
|
|
384
|
+
max:[NSNumber numberWithDouble:LAT_MAX]] doubleValue];
|
|
376
385
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
[self _removeAllSourcesFromMap];
|
|
381
|
-
self.styleURL = [self _getStyleURLFromKey:_reactMapStyle];
|
|
386
|
+
double constrainedScale = pow(2.0, constrainedZoom);
|
|
387
|
+
return cos(constrainedLatitude * DEG2RAD) * M2PI * EARTH_RADIUS_M /
|
|
388
|
+
(constrainedScale * TILE_SIZE);
|
|
382
389
|
}
|
|
383
390
|
|
|
384
|
-
- (
|
|
385
|
-
|
|
386
|
-
self.preferredFramesPerSecond = reactPreferredFramesPerSecond;
|
|
391
|
+
- (CLLocationDistance)altitudeFromZoom:(double)zoomLevel {
|
|
392
|
+
return [self altitudeFromZoom:zoomLevel atLatitude:self.camera.centerCoordinate.latitude];
|
|
387
393
|
}
|
|
388
394
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
- (NSString *)takeSnap:(BOOL)writeToDisk
|
|
393
|
-
{
|
|
394
|
-
UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0);
|
|
395
|
-
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
|
|
396
|
-
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
|
|
397
|
-
UIGraphicsEndImageContext();
|
|
398
|
-
return writeToDisk ? [MLRNImageUtils createTempFile:snapshot] : [MLRNImageUtils createBase64:snapshot];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
- (CLLocationDistance)getMetersPerPixelAtLatitude:(double)latitude withZoom:(double)zoomLevel
|
|
402
|
-
{
|
|
403
|
-
double constrainedZoom = [[MLRNUtils clamp:[NSNumber numberWithDouble:zoomLevel]
|
|
404
|
-
min:[NSNumber numberWithDouble:self.minimumZoomLevel]
|
|
405
|
-
max:[NSNumber numberWithDouble:self.maximumZoomLevel]] doubleValue];
|
|
406
|
-
|
|
407
|
-
double constrainedLatitude = [[MLRNUtils clamp:[NSNumber numberWithDouble:latitude]
|
|
408
|
-
min:[NSNumber numberWithDouble:-LAT_MAX]
|
|
409
|
-
max:[NSNumber numberWithDouble:LAT_MAX]] doubleValue];
|
|
410
|
-
|
|
411
|
-
double constrainedScale = pow(2.0, constrainedZoom);
|
|
412
|
-
return cos(constrainedLatitude * DEG2RAD) * M2PI * EARTH_RADIUS_M / (constrainedScale * TILE_SIZE);
|
|
395
|
+
- (CLLocationDistance)altitudeFromZoom:(double)zoomLevel atLatitude:(CLLocationDegrees)latitude {
|
|
396
|
+
return [self altitudeFromZoom:zoomLevel atLatitude:latitude atPitch:self.camera.pitch];
|
|
413
397
|
}
|
|
414
398
|
|
|
415
399
|
- (CLLocationDistance)altitudeFromZoom:(double)zoomLevel
|
|
416
|
-
|
|
417
|
-
|
|
400
|
+
atLatitude:(CLLocationDegrees)latitude
|
|
401
|
+
atPitch:(CGFloat)pitch {
|
|
402
|
+
return MLNAltitudeForZoomLevel(zoomLevel, pitch, latitude, self.frame.size);
|
|
418
403
|
}
|
|
419
404
|
|
|
420
|
-
- (
|
|
421
|
-
{
|
|
422
|
-
|
|
405
|
+
- (MLRNPointAnnotation *)getRCTPointAnnotation:(MLNPointAnnotation *)mlnAnnotation {
|
|
406
|
+
for (int i = 0; i < _pointAnnotations.count; i++) {
|
|
407
|
+
MLRNPointAnnotation *rctAnnotation = _pointAnnotations[i];
|
|
408
|
+
if (rctAnnotation.annotation == mlnAnnotation) {
|
|
409
|
+
return rctAnnotation;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return nil;
|
|
423
413
|
}
|
|
424
414
|
|
|
425
|
-
- (
|
|
426
|
-
|
|
427
|
-
return MLNAltitudeForZoomLevel(zoomLevel, pitch, latitude, self.frame.size);
|
|
428
|
-
}
|
|
415
|
+
- (NSArray<MLRNSource *> *)getAllTouchableSources {
|
|
416
|
+
NSMutableArray<MLRNSource *> *touchableSources = [[NSMutableArray alloc] init];
|
|
429
417
|
|
|
430
|
-
|
|
431
|
-
{
|
|
432
|
-
|
|
433
|
-
MLRNPointAnnotation *rctAnnotation = _pointAnnotations[i];
|
|
434
|
-
if (rctAnnotation.annotation == mlnAnnotation) {
|
|
435
|
-
return rctAnnotation;
|
|
436
|
-
}
|
|
418
|
+
for (MLRNSource *source in _sources) {
|
|
419
|
+
if (source.hasPressListener) {
|
|
420
|
+
[touchableSources addObject:source];
|
|
437
421
|
}
|
|
438
|
-
|
|
439
|
-
}
|
|
422
|
+
}
|
|
440
423
|
|
|
441
|
-
|
|
442
|
-
{
|
|
443
|
-
NSMutableArray<MLRNSource *> *touchableSources = [[NSMutableArray alloc] init];
|
|
444
|
-
|
|
445
|
-
for (MLRNSource *source in _sources) {
|
|
446
|
-
if (source.hasPressListener) {
|
|
447
|
-
[touchableSources addObject:source];
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return touchableSources;
|
|
424
|
+
return touchableSources;
|
|
452
425
|
}
|
|
453
426
|
|
|
454
|
-
- (NSArray<MLRNImages
|
|
455
|
-
|
|
456
|
-
return [_images copy];
|
|
427
|
+
- (NSArray<MLRNImages *> *)getAllImages {
|
|
428
|
+
return [_images copy];
|
|
457
429
|
}
|
|
458
430
|
|
|
459
|
-
- (NSArray<MLRNShapeSource *> *)getAllShapeSources
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
[shapeSources addObject:source];
|
|
466
|
-
}
|
|
431
|
+
- (NSArray<MLRNShapeSource *> *)getAllShapeSources {
|
|
432
|
+
NSMutableArray<MLRNSource *> *shapeSources = [[NSMutableArray alloc] init];
|
|
433
|
+
|
|
434
|
+
for (MLRNSource *source in _sources) {
|
|
435
|
+
if ([source isKindOfClass:[MLRNShapeSource class]]) {
|
|
436
|
+
[shapeSources addObject:(MLRNShapeSource *)source];
|
|
467
437
|
}
|
|
468
|
-
|
|
469
|
-
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
return [shapeSources copy];
|
|
470
441
|
}
|
|
471
|
-
- (MLRNSource *)getTouchableSourceWithHighestZIndex:(NSArray<MLRNSource *> *)touchableSources
|
|
472
|
-
{
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
442
|
+
- (MLRNSource *)getTouchableSourceWithHighestZIndex:(NSArray<MLRNSource *> *)touchableSources {
|
|
443
|
+
if (touchableSources == nil || touchableSources.count == 0) {
|
|
444
|
+
return nil;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (touchableSources.count == 1) {
|
|
448
|
+
return touchableSources[0];
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
NSMutableDictionary<NSString *, MLRNSource *> *layerToSoureDict =
|
|
452
|
+
[[NSMutableDictionary alloc] init];
|
|
453
|
+
for (MLRNSource *touchableSource in touchableSources) {
|
|
454
|
+
NSArray<NSString *> *layerIDs = [touchableSource getLayerIDs];
|
|
455
|
+
|
|
456
|
+
for (NSString *layerID in layerIDs) {
|
|
457
|
+
layerToSoureDict[layerID] = touchableSource;
|
|
488
458
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
NSArray<MLNStyleLayer *> *layers = self.style.layers;
|
|
462
|
+
for (int i = (int)layers.count - 1; i >= 0; i--) {
|
|
463
|
+
MLNStyleLayer *layer = layers[i];
|
|
464
|
+
|
|
465
|
+
MLRNSource *source = layerToSoureDict[layer.identifier];
|
|
466
|
+
if (source != nil) {
|
|
467
|
+
return source;
|
|
498
468
|
}
|
|
499
|
-
|
|
500
|
-
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return nil;
|
|
501
472
|
}
|
|
502
473
|
|
|
503
|
-
- (NSURL*)_getStyleURLFromKey:(NSString *)mapStyle
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
if (url) {
|
|
507
|
-
return url;
|
|
508
|
-
} else if (RCTJSONParse(mapStyle, nil)) {
|
|
509
|
-
return [MLRNUtils styleURLFromStyleJSON:mapStyle];
|
|
510
|
-
}
|
|
474
|
+
- (NSURL *)_getStyleURLFromKey:(NSString *)mapStyle {
|
|
475
|
+
NSURL *url = [NSURL URLWithString:mapStyle];
|
|
476
|
+
if (url) {
|
|
511
477
|
return url;
|
|
478
|
+
} else if (RCTJSONParse(mapStyle, nil)) {
|
|
479
|
+
return [MLRNUtils styleURLFromStyleJSON:mapStyle];
|
|
480
|
+
}
|
|
481
|
+
return url;
|
|
512
482
|
}
|
|
513
483
|
|
|
514
|
-
- (void)_removeAllSourcesFromMap
|
|
515
|
-
{
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
484
|
+
- (void)_removeAllSourcesFromMap {
|
|
485
|
+
if (self.style == nil || _sources.count == 0) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
for (MLRNSource *source in _sources) {
|
|
489
|
+
source.map = nil;
|
|
490
|
+
}
|
|
522
491
|
}
|
|
523
492
|
|
|
524
493
|
- (void)didChangeUserTrackingMode:(MLNUserTrackingMode)mode animated:(BOOL)animated {
|
|
525
|
-
|
|
494
|
+
[_reactCamera didChangeUserTrackingMode:mode animated:animated];
|
|
526
495
|
}
|
|
527
496
|
|
|
528
497
|
@end
|