@maplibre/maplibre-react-native 10.1.0 → 10.1.1

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.
Files changed (152) hide show
  1. package/ios/MLRN/CameraStop.h +1 -1
  2. package/ios/MLRN/CameraStop.m +58 -60
  3. package/ios/MLRN/CameraUpdateItem.h +2 -1
  4. package/ios/MLRN/CameraUpdateItem.m +132 -132
  5. package/ios/MLRN/CameraUpdateQueue.m +43 -47
  6. package/ios/MLRN/FilterParser.h +1 -1
  7. package/ios/MLRN/FilterParser.m +5 -6
  8. package/ios/MLRN/MLRNBackgroundLayer.m +10 -9
  9. package/ios/MLRN/MLRNBackgroundLayerManager.m +4 -5
  10. package/ios/MLRN/MLRNCallout.h +1 -1
  11. package/ios/MLRN/MLRNCallout.m +37 -36
  12. package/ios/MLRN/MLRNCalloutManager.m +2 -3
  13. package/ios/MLRN/MLRNCamera.h +1 -1
  14. package/ios/MLRN/MLRNCamera.m +169 -182
  15. package/ios/MLRN/MLRNCameraManager.m +4 -6
  16. package/ios/MLRN/MLRNCircleLayer.m +17 -14
  17. package/ios/MLRN/MLRNCircleLayerManager.m +4 -5
  18. package/ios/MLRN/MLRNCustomHeaders.h +2 -2
  19. package/ios/MLRN/MLRNCustomHeaders.m +63 -63
  20. package/ios/MLRN/MLRNEvent.h +3 -3
  21. package/ios/MLRN/MLRNEvent.m +19 -24
  22. package/ios/MLRN/MLRNEventProtocol.h +1 -1
  23. package/ios/MLRN/MLRNFillExtrusionLayer.m +18 -14
  24. package/ios/MLRN/MLRNFillExtrusionLayerManager.m +4 -5
  25. package/ios/MLRN/MLRNFillLayer.m +16 -14
  26. package/ios/MLRN/MLRNFillLayerManager.m +4 -5
  27. package/ios/MLRN/MLRNHeatmapLayer.m +17 -14
  28. package/ios/MLRN/MLRNHeatmapLayerManager.m +4 -5
  29. package/ios/MLRN/MLRNImageQueue.h +4 -1
  30. package/ios/MLRN/MLRNImageQueue.m +29 -32
  31. package/ios/MLRN/MLRNImageQueueOperation.h +1 -1
  32. package/ios/MLRN/MLRNImageQueueOperation.m +92 -91
  33. package/ios/MLRN/MLRNImageSource.m +36 -38
  34. package/ios/MLRN/MLRNImageSourceManager.m +2 -3
  35. package/ios/MLRN/MLRNImageUtils.h +3 -3
  36. package/ios/MLRN/MLRNImageUtils.m +15 -14
  37. package/ios/MLRN/MLRNImages.h +0 -1
  38. package/ios/MLRN/MLRNImages.m +89 -91
  39. package/ios/MLRN/MLRNImagesManager.m +4 -5
  40. package/ios/MLRN/MLRNLayer.h +9 -11
  41. package/ios/MLRN/MLRNLayer.m +170 -182
  42. package/ios/MLRN/MLRNLight.m +21 -23
  43. package/ios/MLRN/MLRNLightManager.m +2 -3
  44. package/ios/MLRN/MLRNLineLayer.m +17 -15
  45. package/ios/MLRN/MLRNLineLayerManager.m +4 -6
  46. package/ios/MLRN/MLRNLocation.h +1 -1
  47. package/ios/MLRN/MLRNLocation.m +16 -17
  48. package/ios/MLRN/MLRNLocationManager.m +109 -124
  49. package/ios/MLRN/MLRNLocationManagerDelegate.h +3 -3
  50. package/ios/MLRN/MLRNLocationModule.h +1 -1
  51. package/ios/MLRN/MLRNLocationModule.m +40 -55
  52. package/ios/MLRN/MLRNLogging.h +1 -4
  53. package/ios/MLRN/MLRNLogging.m +84 -89
  54. package/ios/MLRN/MLRNMapTouchEvent.h +2 -2
  55. package/ios/MLRN/MLRNMapTouchEvent.m +50 -49
  56. package/ios/MLRN/MLRNMapView.h +43 -36
  57. package/ios/MLRN/MLRNMapView.m +409 -440
  58. package/ios/MLRN/MLRNMapViewManager.m +489 -502
  59. package/ios/MLRN/MLRNModule.h +1 -1
  60. package/ios/MLRN/MLRNModule.m +111 -105
  61. package/ios/MLRN/MLRNNativeUserLocation.m +24 -27
  62. package/ios/MLRN/MLRNNativeUserLocationManager.m +4 -8
  63. package/ios/MLRN/MLRNOfflineModule.h +1 -1
  64. package/ios/MLRN/MLRNOfflineModule.m +416 -421
  65. package/ios/MLRN/MLRNPointAnnotation.h +2 -2
  66. package/ios/MLRN/MLRNPointAnnotation.m +154 -175
  67. package/ios/MLRN/MLRNPointAnnotationManager.m +2 -3
  68. package/ios/MLRN/MLRNRasterLayer.m +16 -12
  69. package/ios/MLRN/MLRNRasterLayerManager.m +4 -5
  70. package/ios/MLRN/MLRNRasterSource.m +21 -17
  71. package/ios/MLRN/MLRNRasterSourceManager.m +2 -3
  72. package/ios/MLRN/MLRNShapeSource.h +17 -16
  73. package/ios/MLRN/MLRNShapeSource.m +94 -102
  74. package/ios/MLRN/MLRNShapeSourceManager.h +2 -2
  75. package/ios/MLRN/MLRNShapeSourceManager.m +86 -90
  76. package/ios/MLRN/MLRNSnapshotModule.h +1 -1
  77. package/ios/MLRN/MLRNSnapshotModule.m +51 -53
  78. package/ios/MLRN/MLRNSource.h +12 -12
  79. package/ios/MLRN/MLRNSource.m +82 -88
  80. package/ios/MLRN/MLRNStyleValue.h +1 -1
  81. package/ios/MLRN/MLRNStyleValue.m +128 -128
  82. package/ios/MLRN/MLRNSymbolLayer.m +17 -13
  83. package/ios/MLRN/MLRNSymbolLayerManager.m +4 -5
  84. package/ios/MLRN/MLRNTileSource.h +1 -1
  85. package/ios/MLRN/MLRNTileSource.m +21 -20
  86. package/ios/MLRN/MLRNUserLocation.h +1 -1
  87. package/ios/MLRN/MLRNUserLocation.m +10 -12
  88. package/ios/MLRN/MLRNUtils.h +18 -11
  89. package/ios/MLRN/MLRNUtils.m +168 -160
  90. package/ios/MLRN/MLRNVectorLayer.m +28 -34
  91. package/ios/MLRN/MLRNVectorSource.h +3 -1
  92. package/ios/MLRN/MLRNVectorSource.m +14 -11
  93. package/ios/MLRN/MLRNVectorSourceManager.h +2 -2
  94. package/ios/MLRN/MLRNVectorSourceManager.m +36 -39
  95. package/ios/MLRN/ViewManager.h +1 -1
  96. package/ios/MLRN/ViewManager.m +29 -35
  97. package/lib/commonjs/components/MarkerView.js +1 -1
  98. package/lib/commonjs/components/UserLocation.js +8 -38
  99. package/lib/commonjs/components/UserLocation.js.map +1 -1
  100. package/lib/commonjs/components/UserLocationPuck.js +52 -0
  101. package/lib/commonjs/components/UserLocationPuck.js.map +1 -0
  102. package/lib/commonjs/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +12 -9
  103. package/lib/commonjs/components/UserLocationPuckHeading.js.map +1 -0
  104. package/lib/module/components/MarkerView.js +1 -1
  105. package/lib/module/components/UserLocation.js +7 -36
  106. package/lib/module/components/UserLocation.js.map +1 -1
  107. package/lib/module/components/UserLocationPuck.js +48 -0
  108. package/lib/module/components/UserLocationPuck.js.map +1 -0
  109. package/lib/module/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +11 -7
  110. package/lib/module/components/UserLocationPuckHeading.js.map +1 -0
  111. package/lib/typescript/commonjs/src/components/MarkerView.d.ts +1 -1
  112. package/lib/typescript/commonjs/src/components/UserLocation.d.ts +0 -1
  113. package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts +9 -0
  115. package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts +9 -0
  117. package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +0 -1
  119. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +0 -1
  121. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts +0 -1
  123. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +0 -1
  125. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  126. package/lib/typescript/module/src/components/MarkerView.d.ts +1 -1
  127. package/lib/typescript/module/src/components/UserLocation.d.ts +0 -1
  128. package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
  129. package/lib/typescript/module/src/components/UserLocationPuck.d.ts +9 -0
  130. package/lib/typescript/module/src/components/UserLocationPuck.d.ts.map +1 -0
  131. package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts +9 -0
  132. package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts.map +1 -0
  133. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +0 -1
  134. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  135. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +0 -1
  136. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  137. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts +0 -1
  138. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  139. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +0 -1
  140. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  141. package/package.json +8 -8
  142. package/src/components/MarkerView.tsx +1 -1
  143. package/src/components/UserLocation.tsx +13 -51
  144. package/src/components/UserLocationPuck.tsx +62 -0
  145. package/src/components/UserLocationPuckHeading.tsx +33 -0
  146. package/lib/commonjs/components/HeadingIndicator.js.map +0 -1
  147. package/lib/module/components/HeadingIndicator.js.map +0 -1
  148. package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts +0 -7
  149. package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts.map +0 -1
  150. package/lib/typescript/module/src/components/HeadingIndicator.d.ts +0 -7
  151. package/lib/typescript/module/src/components/HeadingIndicator.d.ts.map +0 -1
  152. 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
- IOState_Initial,
6
- IOState_CancelledDoNotExecute,
7
- IOState_Executing, // cancellationBlock is set
8
- IOState_Finished,
9
-
10
- /* Not sates, just selectors for only and except params */
11
- IOState_Filter_None,
12
- IOState_Filter_All,
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
- RCTImageLoaderCancellationBlock _cancellationBlock;
22
- BOOL _cancelled;
18
+ @implementation MLRNImageQueueOperation {
19
+ RCTImageLoaderCancellationBlock _cancellationBlock;
20
+ BOOL _cancelled;
23
21
  }
24
22
 
25
23
  - (instancetype)init {
26
- self = [super init];
27
- if (self) {
28
- _state = IOState_Initial;
29
- _cancelled = false;
30
- }
31
- return self;
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
- @synchronized (self) {
36
- return self.state == IOState_Executing;
37
- }
33
+ @synchronized(self) {
34
+ return self.state == IOState_Executing;
35
+ }
38
36
  }
39
37
 
40
38
  - (BOOL)isFinished {
41
- @synchronized (self) {
42
- return (self.state == IOState_Finished || self.state == IOState_CancelledDoNotExecute);
43
- }
39
+ @synchronized(self) {
40
+ return (self.state == IOState_Finished || self.state == IOState_CancelledDoNotExecute);
41
+ }
44
42
  }
45
43
 
46
44
  - (BOOL)isCancelled {
47
- @synchronized (self) {
48
- return self.state == IOState_CancelledDoNotExecute;
49
- }
45
+ @synchronized(self) {
46
+ return self.state == IOState_CancelledDoNotExecute;
47
+ }
50
48
  }
51
49
 
52
- - (void)setCancellationBlock:(dispatch_block_t) block {
53
- _cancellationBlock = block;
50
+ - (void)setCancellationBlock:(dispatch_block_t)block {
51
+ _cancellationBlock = block;
54
52
  }
55
53
 
56
- -(void)callCancellationBlock {
57
- if (_cancellationBlock) {
58
- _cancellationBlock();
59
- }
54
+ - (void)callCancellationBlock {
55
+ if (_cancellationBlock) {
56
+ _cancellationBlock();
57
+ }
60
58
  }
61
59
 
62
- - (MLRNImageQueueOperationState)setState:(MLRNImageQueueOperationState)newState only:(MLRNImageQueueOperationState)only except:(MLRNImageQueueOperationState) except
63
- {
64
- MLRNImageQueueOperationState prevState = IOState_Filter_None;
65
- [self willChangeValueForKey:@"isExecuting"];
66
- [self willChangeValueForKey:@"isFinished"];
67
- [self willChangeValueForKey:@"isCancelled"];
68
-
69
- @synchronized (self) {
70
- BOOL allowed = YES;
71
- prevState = self.state;
72
- if (! (only == IOState_Filter_All || prevState == only)) {
73
- allowed = NO;
74
- }
75
- if (prevState == except) {
76
- allowed = NO;
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
- [self didChangeValueForKey:@"isExecuting"];
83
- [self didChangeValueForKey:@"isFinished"];
84
- [self didChangeValueForKey:@"isCancelled"];
85
- return prevState;
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 only:(MLRNImageQueueOperationState)only
89
- {
90
- return [self setState: newState only:only except:IOState_Filter_None];
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 except:(MLRNImageQueueOperationState)except
94
- {
95
- return [self setState: newState only:IOState_Filter_All except:except];
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
- if (self.state == IOState_CancelledDoNotExecute) {
101
- return;
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
- __weak MLRNImageQueueOperation *weakSelf = self;
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
- if ([self setState:IOState_CancelledDoNotExecute except:IOState_Finished] == IOState_Executing) {
126
- [self callCancellationBlock];
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
- _url = url;
9
-
10
- if (self.source != nil) {
11
- MLNImageSource *source = (MLNImageSource *)self.source;
12
- source.URL = [NSURL URLWithString:_url];
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
- _coordinates = coordinates;
19
- if (self.source != nil) {
20
- MLNImageSource *source = (MLNImageSource *)self.source;
21
- source.coordinates = [self _makeCoordQuad];
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
- NSURL *myURL;
28
-
29
- if ([[_url substringToIndex:4] isEqualToString:@"http"]) {
30
- myURL = [NSURL URLWithString:_url];
31
- }
32
- else
33
- {
34
- //Default consider it file url path
35
- myURL = [NSURL fileURLWithPath:_url];
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
- CLLocationCoordinate2D topLeft = CLLocationCoordinate2DMake([self.coordinates[0][1] floatValue], [self.coordinates[0][0] floatValue]);
46
- CLLocationCoordinate2D topRight = CLLocationCoordinate2DMake([self.coordinates[1][1] floatValue], [self.coordinates[1][0] floatValue]);
47
- CLLocationCoordinate2D bottomRight = CLLocationCoordinate2DMake([self.coordinates[2][1] floatValue], [self.coordinates[2][0] floatValue]);
48
- CLLocationCoordinate2D bottomLeft = CLLocationCoordinate2DMake([self.coordinates[3][1] floatValue], [self.coordinates[3][0] floatValue]);
49
- return MLNCoordinateQuadMake(topLeft, bottomLeft, bottomRight, topRight);
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
- NSString *fileID = [[NSUUID UUID] UUIDString];
8
- NSString *pathComponent = [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;
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
- NSData *data = UIImagePNGRepresentation(image);
20
- return [NSString stringWithFormat:@"%@%@", @"data:image/png;base64,", [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]];
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
@@ -22,4 +22,3 @@
22
22
  - (void)sendImageMissingEvent:(NSString *)imageName;
23
23
 
24
24
  @end
25
-
@@ -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 * _placeHolderImage;
10
+ static UIImage *_placeHolderImage;
12
11
 
13
- - (void)addToMap
14
- {
15
- if (self.map.style == nil) {
16
- return;
17
- }
18
- [self _addNativeImages:_nativeImages];
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
- if (self.map.style == nil) {
25
- return;
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
- if ([self _hasImages]) {
34
- NSArray<NSString *> *imageNames = _images.allKeys;
35
-
36
- for (NSString *imageName in imageNames) {
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
- if ([self _hasNativeImages]) {
42
- for (NSString *imageName in _nativeImages) {
43
- [self.map.style removeImageForName:imageName];
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
- if (_nativeImages && [_nativeImages containsObject:imageName]) {
50
- [self _addNativeImages:@[imageName]];
51
- return true;
52
- }
53
-
54
- NSString *remoteImage = _images != nil ? [_images objectForKey:imageName] : nil;
55
- if (remoteImage) {
56
- [self _addRemoteImages:@{imageName: remoteImage}];
57
- return true;
58
- }
59
- return false;
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) sendImageMissingEvent:(NSString *)imageName {
63
- NSDictionary *payload = @{ @"imageKey": imageName };
64
- MLRNEvent *event = [MLRNEvent makeEvent:RCT_MAPBOX_IMAGES_MISSING_IMAGE withPayload:payload];
65
- if (_onImageMissing) {
66
- _onImageMissing([event toJSON]);
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 *>*)nativeImages
71
- {
72
- if (!nativeImages) return;
66
+ - (void)_addNativeImages:(NSArray<NSString *> *)nativeImages {
67
+ if (!nativeImages) return;
73
68
 
74
- for (NSString *imageName in nativeImages) {
75
- // only add native images if they are not in the style yet (similar to [MLRNUtils fetchImages: style:])
76
- if (![self.map.style imageForName:imageName]) {
77
- UIImage *image = [UIImage imageNamed:imageName];
78
- [self.map.style setImage:image forName:imageName];
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 *>*)remoteImages
84
- {
85
- if (!remoteImages) return;
86
- NSDictionary<NSString *, NSString *> *missingImages = [NSMutableDictionary new];
87
-
88
- // Add image placeholder for images that are not yet available in the style. This way
89
- // we can load the images asynchronously and add the ShapeSource to the map without delay.
90
- // The same is required when this ShapeSource is updated with new/added images and the
91
- // data references them. In which case addMissingImageToStyle will take care of loading
92
- // them in a similar way.
93
- //
94
- // See also: https://github.com/mapbox/mapbox-gl-native/pull/14253#issuecomment-478827792
95
- for (NSString *imageName in remoteImages.allKeys) {
96
- if (![self.map.style imageForName:imageName]) {
97
- [self.map.style setImage:[MLRNImages placeholderImage] forName:imageName];
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
- if (_placeHolderImage) return _placeHolderImage;
120
- UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 0.0);
121
- _placeHolderImage = UIGraphicsGetImageFromCurrentImageContext();
122
- UIGraphicsEndImageContext();
123
- return _placeHolderImage;
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
- MLRNImages *images = [MLRNImages new];
17
- images.bridge = self.bridge;
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