@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
|
@@ -1,130 +1,131 @@
|
|
|
1
1
|
#import "MLRNImageQueueOperation.h"
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
typedef NS_ENUM(NSInteger, MLRNImageQueueOperationState) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
IOState_Initial,
|
|
5
|
+
IOState_CancelledDoNotExecute,
|
|
6
|
+
IOState_Executing, // cancellationBlock is set
|
|
7
|
+
IOState_Finished,
|
|
8
|
+
|
|
9
|
+
/* Not sates, just selectors for only and except params */
|
|
10
|
+
IOState_Filter_None,
|
|
11
|
+
IOState_Filter_All,
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
@interface MLRNImageQueueOperation()
|
|
14
|
+
@interface MLRNImageQueueOperation ()
|
|
16
15
|
@property (nonatomic) MLRNImageQueueOperationState state;
|
|
17
16
|
@end
|
|
18
17
|
|
|
19
|
-
@implementation MLRNImageQueueOperation
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
BOOL _cancelled;
|
|
18
|
+
@implementation MLRNImageQueueOperation {
|
|
19
|
+
RCTImageLoaderCancellationBlock _cancellationBlock;
|
|
20
|
+
BOOL _cancelled;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
- (instancetype)init {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
self = [super init];
|
|
25
|
+
if (self) {
|
|
26
|
+
_state = IOState_Initial;
|
|
27
|
+
_cancelled = false;
|
|
28
|
+
}
|
|
29
|
+
return self;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
- (BOOL)isExecuting {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
@synchronized(self) {
|
|
34
|
+
return self.state == IOState_Executing;
|
|
35
|
+
}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
- (BOOL)isFinished {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
@synchronized(self) {
|
|
40
|
+
return (self.state == IOState_Finished || self.state == IOState_CancelledDoNotExecute);
|
|
41
|
+
}
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
- (BOOL)isCancelled {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
@synchronized(self) {
|
|
46
|
+
return self.state == IOState_CancelledDoNotExecute;
|
|
47
|
+
}
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
- (void)setCancellationBlock:(dispatch_block_t)
|
|
53
|
-
|
|
50
|
+
- (void)setCancellationBlock:(dispatch_block_t)block {
|
|
51
|
+
_cancellationBlock = block;
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
-(void)callCancellationBlock {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
- (void)callCancellationBlock {
|
|
55
|
+
if (_cancellationBlock) {
|
|
56
|
+
_cancellationBlock();
|
|
57
|
+
}
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
- (MLRNImageQueueOperationState)setState:(MLRNImageQueueOperationState)newState
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (allowed) {
|
|
79
|
-
self.state = newState;
|
|
80
|
-
}
|
|
60
|
+
- (MLRNImageQueueOperationState)setState:(MLRNImageQueueOperationState)newState
|
|
61
|
+
only:(MLRNImageQueueOperationState)only
|
|
62
|
+
except:(MLRNImageQueueOperationState)except {
|
|
63
|
+
MLRNImageQueueOperationState prevState = IOState_Filter_None;
|
|
64
|
+
[self willChangeValueForKey:@"isExecuting"];
|
|
65
|
+
[self willChangeValueForKey:@"isFinished"];
|
|
66
|
+
[self willChangeValueForKey:@"isCancelled"];
|
|
67
|
+
|
|
68
|
+
@synchronized(self) {
|
|
69
|
+
BOOL allowed = YES;
|
|
70
|
+
prevState = self.state;
|
|
71
|
+
if (!(only == IOState_Filter_All || prevState == only)) {
|
|
72
|
+
allowed = NO;
|
|
73
|
+
}
|
|
74
|
+
if (prevState == except) {
|
|
75
|
+
allowed = NO;
|
|
81
76
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
if (allowed) {
|
|
78
|
+
self.state = newState;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
[self didChangeValueForKey:@"isExecuting"];
|
|
82
|
+
[self didChangeValueForKey:@"isFinished"];
|
|
83
|
+
[self didChangeValueForKey:@"isCancelled"];
|
|
84
|
+
return prevState;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
- (MLRNImageQueueOperationState)setState:(MLRNImageQueueOperationState)newState
|
|
89
|
-
{
|
|
90
|
-
|
|
87
|
+
- (MLRNImageQueueOperationState)setState:(MLRNImageQueueOperationState)newState
|
|
88
|
+
only:(MLRNImageQueueOperationState)only {
|
|
89
|
+
return [self setState:newState only:only except:IOState_Filter_None];
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
- (MLRNImageQueueOperationState)setState:(MLRNImageQueueOperationState)newState
|
|
94
|
-
{
|
|
95
|
-
|
|
92
|
+
- (MLRNImageQueueOperationState)setState:(MLRNImageQueueOperationState)newState
|
|
93
|
+
except:(MLRNImageQueueOperationState)except {
|
|
94
|
+
return [self setState:newState only:IOState_Filter_All except:except];
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
- (void)start
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
- (void)start {
|
|
98
|
+
if (self.state == IOState_CancelledDoNotExecute) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
__weak MLRNImageQueueOperation *weakSelf = self;
|
|
102
|
+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
103
|
+
[weakSelf
|
|
104
|
+
setCancellationBlock:[[weakSelf.bridge moduleForName:@"ImageLoader"
|
|
105
|
+
lazilyLoadIfNecessary:YES]
|
|
106
|
+
loadImageWithURLRequest:weakSelf.urlRequest
|
|
107
|
+
size:CGSizeZero
|
|
108
|
+
scale:weakSelf.scale
|
|
109
|
+
clipped:YES
|
|
110
|
+
resizeMode:RCTResizeModeStretch
|
|
111
|
+
progressBlock:nil
|
|
112
|
+
partialLoadBlock:nil
|
|
113
|
+
completionBlock:^void(NSError *error, UIImage *image) {
|
|
114
|
+
weakSelf.completionHandler(error, image);
|
|
115
|
+
[weakSelf setState:IOState_Finished
|
|
116
|
+
except:IOState_Finished];
|
|
117
|
+
}]];
|
|
118
|
+
if ([weakSelf setState:IOState_Executing
|
|
119
|
+
only:IOState_Initial] == IOState_CancelledDoNotExecute) {
|
|
120
|
+
[weakSelf callCancellationBlock];
|
|
102
121
|
}
|
|
103
|
-
|
|
104
|
-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
105
|
-
[weakSelf setCancellationBlock: [[weakSelf.bridge moduleForName:@"ImageLoader" lazilyLoadIfNecessary:YES]
|
|
106
|
-
loadImageWithURLRequest:weakSelf.urlRequest
|
|
107
|
-
size:CGSizeZero
|
|
108
|
-
scale:weakSelf.scale
|
|
109
|
-
clipped:YES
|
|
110
|
-
resizeMode:RCTResizeModeStretch
|
|
111
|
-
progressBlock:nil
|
|
112
|
-
partialLoadBlock:nil
|
|
113
|
-
completionBlock:^void (NSError *error, UIImage *image){
|
|
114
|
-
weakSelf.completionHandler(error, image);
|
|
115
|
-
[weakSelf setState:IOState_Finished except:IOState_Finished];
|
|
116
|
-
}]];
|
|
117
|
-
if ([weakSelf setState:IOState_Executing only:IOState_Initial] == IOState_CancelledDoNotExecute) {
|
|
118
|
-
[weakSelf callCancellationBlock];
|
|
119
|
-
}
|
|
120
|
-
});
|
|
122
|
+
});
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
- (void)cancel
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
125
|
+
- (void)cancel {
|
|
126
|
+
if ([self setState:IOState_CancelledDoNotExecute except:IOState_Finished] == IOState_Executing) {
|
|
127
|
+
[self callCancellationBlock];
|
|
128
|
+
}
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
@end
|
|
@@ -3,50 +3,48 @@
|
|
|
3
3
|
|
|
4
4
|
@implementation MLRNImageSource
|
|
5
5
|
|
|
6
|
-
- (void)setUrl:(NSString *)url
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
6
|
+
- (void)setUrl:(NSString *)url {
|
|
7
|
+
_url = url;
|
|
8
|
+
|
|
9
|
+
if (self.source != nil) {
|
|
10
|
+
MLNImageSource *source = (MLNImageSource *)self.source;
|
|
11
|
+
source.URL = [NSURL URLWithString:_url];
|
|
12
|
+
}
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
- (void)setCoordinates:(NSArray<NSArray<NSNumber *> *> *)coordinates
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
15
|
+
- (void)setCoordinates:(NSArray<NSArray<NSNumber *> *> *)coordinates {
|
|
16
|
+
_coordinates = coordinates;
|
|
17
|
+
if (self.source != nil) {
|
|
18
|
+
MLNImageSource *source = (MLNImageSource *)self.source;
|
|
19
|
+
source.coordinates = [self _makeCoordQuad];
|
|
20
|
+
}
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
- (nullable MLNSource *)makeSource
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return [[MLNImageSource alloc] initWithIdentifier:self.id
|
|
39
|
-
coordinateQuad:[self _makeCoordQuad]
|
|
40
|
-
URL:myURL];
|
|
23
|
+
- (nullable MLNSource *)makeSource {
|
|
24
|
+
NSURL *myURL;
|
|
25
|
+
|
|
26
|
+
if ([[_url substringToIndex:4] isEqualToString:@"http"]) {
|
|
27
|
+
myURL = [NSURL URLWithString:_url];
|
|
28
|
+
} else {
|
|
29
|
+
// Default consider it file url path
|
|
30
|
+
myURL = [NSURL fileURLWithPath:_url];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return [[MLNImageSource alloc] initWithIdentifier:self.id
|
|
34
|
+
coordinateQuad:[self _makeCoordQuad]
|
|
35
|
+
URL:myURL];
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
- (MLNCoordinateQuad)_makeCoordQuad
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
- (MLNCoordinateQuad)_makeCoordQuad {
|
|
39
|
+
CLLocationCoordinate2D topLeft = CLLocationCoordinate2DMake([self.coordinates[0][1] floatValue],
|
|
40
|
+
[self.coordinates[0][0] floatValue]);
|
|
41
|
+
CLLocationCoordinate2D topRight = CLLocationCoordinate2DMake([self.coordinates[1][1] floatValue],
|
|
42
|
+
[self.coordinates[1][0] floatValue]);
|
|
43
|
+
CLLocationCoordinate2D bottomRight = CLLocationCoordinate2DMake(
|
|
44
|
+
[self.coordinates[2][1] floatValue], [self.coordinates[2][0] floatValue]);
|
|
45
|
+
CLLocationCoordinate2D bottomLeft = CLLocationCoordinate2DMake(
|
|
46
|
+
[self.coordinates[3][1] floatValue], [self.coordinates[3][0] floatValue]);
|
|
47
|
+
return MLNCoordinateQuadMake(topLeft, bottomLeft, bottomRight, topRight);
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
@end
|
|
@@ -9,9 +9,8 @@ RCT_EXPORT_VIEW_PROPERTY(id, NSString)
|
|
|
9
9
|
RCT_EXPORT_VIEW_PROPERTY(url, NSString)
|
|
10
10
|
RCT_EXPORT_VIEW_PROPERTY(coordinates, NSArray)
|
|
11
11
|
|
|
12
|
-
- (UIView*)view
|
|
13
|
-
|
|
14
|
-
return [MLRNImageSource new];
|
|
12
|
+
- (UIView*)view {
|
|
13
|
+
return [MLRNImageSource new];
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
@end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
1
|
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
3
|
|
|
4
4
|
@interface MLRNImageUtils : NSObject
|
|
5
5
|
|
|
6
|
-
+(NSString *)createTempFile:(UIImage *)image;
|
|
7
|
-
+(NSString *)createBase64:(UIImage *)image;
|
|
6
|
+
+ (NSString *)createTempFile:(UIImage *)image;
|
|
7
|
+
+ (NSString *)createBase64:(UIImage *)image;
|
|
8
8
|
|
|
9
9
|
@end
|
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation MLRNImageUtils
|
|
4
4
|
|
|
5
|
-
+ (NSString *)createTempFile:(UIImage *)image
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
+ (NSString *)createTempFile:(UIImage *)image {
|
|
6
|
+
NSString *fileID = [[NSUUID UUID] UUIDString];
|
|
7
|
+
NSString *pathComponent =
|
|
8
|
+
[NSString stringWithFormat:@"Documents/mlrn-snapshot-%@.%@", fileID, @"png"];
|
|
9
|
+
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:pathComponent];
|
|
10
|
+
|
|
11
|
+
NSData *data = UIImagePNGRepresentation(image);
|
|
12
|
+
[data writeToFile:filePath atomically:YES];
|
|
13
|
+
|
|
14
|
+
return filePath;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
+ (NSString *)createBase64:(UIImage *)image
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
+ (NSString *)createBase64:(UIImage *)image {
|
|
18
|
+
NSData *data = UIImagePNGRepresentation(image);
|
|
19
|
+
return [NSString stringWithFormat:@"%@%@", @"data:image/png;base64,",
|
|
20
|
+
[data base64EncodedStringWithOptions:
|
|
21
|
+
NSDataBase64EncodingEndLineWithCarriageReturn]];
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
@end
|
package/ios/MLRN/MLRNImages.h
CHANGED
package/ios/MLRN/MLRNImages.m
CHANGED
|
@@ -1,126 +1,124 @@
|
|
|
1
1
|
#import "MLRNImages.h"
|
|
2
2
|
#import <React/UIView+React.h>
|
|
3
|
-
#import "MLRNMapView.h"
|
|
4
|
-
#import "MLRNUtils.h"
|
|
5
3
|
#import "MLRNEvent.h"
|
|
6
4
|
#import "MLRNEventTypes.h"
|
|
7
|
-
|
|
5
|
+
#import "MLRNMapView.h"
|
|
6
|
+
#import "MLRNUtils.h"
|
|
8
7
|
|
|
9
8
|
@implementation MLRNImages : UIView
|
|
10
9
|
|
|
11
|
-
static UIImage *
|
|
10
|
+
static UIImage *_placeHolderImage;
|
|
12
11
|
|
|
13
|
-
- (void)addToMap
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[self _addRemoteImages:_images];
|
|
12
|
+
- (void)addToMap {
|
|
13
|
+
if (self.map.style == nil) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
[self _addNativeImages:_nativeImages];
|
|
17
|
+
[self _addRemoteImages:_images];
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
- (void)removeFromMap
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
[self _removeImages];
|
|
20
|
+
- (void)removeFromMap {
|
|
21
|
+
if (self.map.style == nil) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[self _removeImages];
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
- (void)_removeImages
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[self.map.style removeImageForName:imageName];
|
|
38
|
-
}
|
|
28
|
+
- (void)_removeImages {
|
|
29
|
+
if ([self _hasImages]) {
|
|
30
|
+
NSArray<NSString *> *imageNames = _images.allKeys;
|
|
31
|
+
|
|
32
|
+
for (NSString *imageName in imageNames) {
|
|
33
|
+
[self.map.style removeImageForName:imageName];
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if ([self _hasNativeImages]) {
|
|
38
|
+
for (NSString *imageName in _nativeImages) {
|
|
39
|
+
[self.map.style removeImageForName:imageName];
|
|
45
40
|
}
|
|
41
|
+
}
|
|
46
42
|
}
|
|
47
43
|
|
|
48
|
-
-(BOOL)addMissingImageToStyle:(NSString *)imageName {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
- (BOOL)addMissingImageToStyle:(NSString *)imageName {
|
|
45
|
+
if (_nativeImages && [_nativeImages containsObject:imageName]) {
|
|
46
|
+
[self _addNativeImages:@[ imageName ]];
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
NSString *remoteImage = _images != nil ? [_images objectForKey:imageName] : nil;
|
|
51
|
+
if (remoteImage) {
|
|
52
|
+
[self _addRemoteImages:@{imageName : remoteImage}];
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
- (void)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
- (void)sendImageMissingEvent:(NSString *)imageName {
|
|
59
|
+
NSDictionary *payload = @{@"imageKey" : imageName};
|
|
60
|
+
MLRNEvent *event = [MLRNEvent makeEvent:RCT_MAPBOX_IMAGES_MISSING_IMAGE withPayload:payload];
|
|
61
|
+
if (_onImageMissing) {
|
|
62
|
+
_onImageMissing([event toJSON]);
|
|
63
|
+
}
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
- (void)_addNativeImages:(NSArray<NSString
|
|
71
|
-
|
|
72
|
-
if (!nativeImages) return;
|
|
66
|
+
- (void)_addNativeImages:(NSArray<NSString *> *)nativeImages {
|
|
67
|
+
if (!nativeImages) return;
|
|
73
68
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
for (NSString *imageName in nativeImages) {
|
|
70
|
+
// only add native images if they are not in the style yet (similar to [MLRNUtils fetchImages:
|
|
71
|
+
// style:])
|
|
72
|
+
if (![self.map.style imageForName:imageName]) {
|
|
73
|
+
UIImage *image = [UIImage imageNamed:imageName];
|
|
74
|
+
[self.map.style setImage:image forName:imageName];
|
|
80
75
|
}
|
|
76
|
+
}
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
- (void)_addRemoteImages:(NSDictionary<NSString *, NSString
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
[missingImages setValue:_images[imageName] forKey:imageName];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (missingImages.count > 0) {
|
|
103
|
-
// forceUpdate to ensure the placeholder images are updated
|
|
104
|
-
[MLRNUtils fetchImages:_bridge style:self.map.style objects:_images forceUpdate:true callback:^{ }];
|
|
79
|
+
- (void)_addRemoteImages:(NSDictionary<NSString *, NSString *> *)remoteImages {
|
|
80
|
+
if (!remoteImages) return;
|
|
81
|
+
NSDictionary<NSString *, NSString *> *missingImages = [NSMutableDictionary new];
|
|
82
|
+
|
|
83
|
+
// Add image placeholder for images that are not yet available in the style. This way
|
|
84
|
+
// we can load the images asynchronously and add the ShapeSource to the map without delay.
|
|
85
|
+
// The same is required when this ShapeSource is updated with new/added images and the
|
|
86
|
+
// data references them. In which case addMissingImageToStyle will take care of loading
|
|
87
|
+
// them in a similar way.
|
|
88
|
+
//
|
|
89
|
+
// See also: https://github.com/mapbox/mapbox-gl-native/pull/14253#issuecomment-478827792
|
|
90
|
+
for (NSString *imageName in remoteImages.allKeys) {
|
|
91
|
+
if (![self.map.style imageForName:imageName]) {
|
|
92
|
+
[self.map.style setImage:[MLRNImages placeholderImage] forName:imageName];
|
|
93
|
+
[missingImages setValue:_images[imageName] forKey:imageName];
|
|
105
94
|
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (missingImages.count > 0) {
|
|
98
|
+
// forceUpdate to ensure the placeholder images are updated
|
|
99
|
+
[MLRNUtils fetchImages:_bridge
|
|
100
|
+
style:self.map.style
|
|
101
|
+
objects:_images
|
|
102
|
+
forceUpdate:true
|
|
103
|
+
callback:^{
|
|
104
|
+
}];
|
|
105
|
+
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
- (BOOL)_hasImages
|
|
109
|
-
|
|
110
|
-
return _images != nil && _images.count > 0;
|
|
108
|
+
- (BOOL)_hasImages {
|
|
109
|
+
return _images != nil && _images.count > 0;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
- (BOOL)_hasNativeImages
|
|
114
|
-
|
|
115
|
-
return _nativeImages != nil && _nativeImages.count > 0;
|
|
112
|
+
- (BOOL)_hasNativeImages {
|
|
113
|
+
return _nativeImages != nil && _nativeImages.count > 0;
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
+ (UIImage *)placeholderImage {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
if (_placeHolderImage) return _placeHolderImage;
|
|
118
|
+
UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 0.0);
|
|
119
|
+
_placeHolderImage = UIGraphicsGetImageFromCurrentImageContext();
|
|
120
|
+
UIGraphicsEndImageContext();
|
|
121
|
+
return _placeHolderImage;
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
@end
|
|
@@ -11,11 +11,10 @@ RCT_EXPORT_VIEW_PROPERTY(nativeImages, NSArray)
|
|
|
11
11
|
|
|
12
12
|
RCT_REMAP_VIEW_PROPERTY(onImageMissing, onImageMissing, RCTBubblingEventBlock)
|
|
13
13
|
|
|
14
|
-
- (UIView*)view
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return images;
|
|
14
|
+
- (UIView *)view {
|
|
15
|
+
MLRNImages *images = [MLRNImages new];
|
|
16
|
+
images.bridge = self.bridge;
|
|
17
|
+
return images;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
@end
|