@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.
Files changed (185) 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/ShapeSource.js +2 -1
  99. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  100. package/lib/commonjs/components/UserLocation.js +8 -38
  101. package/lib/commonjs/components/UserLocation.js.map +1 -1
  102. package/lib/commonjs/components/UserLocationPuck.js +52 -0
  103. package/lib/commonjs/components/UserLocationPuck.js.map +1 -0
  104. package/lib/commonjs/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +12 -9
  105. package/lib/commonjs/components/UserLocationPuckHeading.js.map +1 -0
  106. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +8 -7
  107. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  108. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -2
  109. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  110. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js +28 -38
  111. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  112. package/lib/commonjs/utils/animated/AnimatedShape.js +11 -7
  113. package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
  114. package/lib/module/components/MarkerView.js +1 -1
  115. package/lib/module/components/ShapeSource.js +2 -1
  116. package/lib/module/components/ShapeSource.js.map +1 -1
  117. package/lib/module/components/UserLocation.js +7 -36
  118. package/lib/module/components/UserLocation.js.map +1 -1
  119. package/lib/module/components/UserLocationPuck.js +48 -0
  120. package/lib/module/components/UserLocationPuck.js.map +1 -0
  121. package/lib/module/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +11 -7
  122. package/lib/module/components/UserLocationPuckHeading.js.map +1 -0
  123. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +8 -7
  124. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  125. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -3
  126. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  127. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js +29 -39
  128. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  129. package/lib/module/utils/animated/AnimatedShape.js +11 -7
  130. package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
  131. package/lib/typescript/commonjs/src/components/MarkerView.d.ts +1 -1
  132. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +1 -1
  133. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/components/UserLocation.d.ts +0 -1
  135. package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts +9 -0
  137. package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts +9 -0
  139. package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
  141. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
  143. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts +0 -1
  145. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
  147. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +8 -5
  149. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  150. package/lib/typescript/module/src/components/MarkerView.d.ts +1 -1
  151. package/lib/typescript/module/src/components/ShapeSource.d.ts +1 -1
  152. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  153. package/lib/typescript/module/src/components/UserLocation.d.ts +0 -1
  154. package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
  155. package/lib/typescript/module/src/components/UserLocationPuck.d.ts +9 -0
  156. package/lib/typescript/module/src/components/UserLocationPuck.d.ts.map +1 -0
  157. package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts +9 -0
  158. package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts.map +1 -0
  159. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
  160. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  161. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
  162. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  163. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts +0 -1
  164. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  165. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
  166. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  167. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +8 -5
  168. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  169. package/package.json +8 -8
  170. package/src/components/MarkerView.tsx +1 -1
  171. package/src/components/ShapeSource.tsx +58 -53
  172. package/src/components/UserLocation.tsx +13 -51
  173. package/src/components/UserLocationPuck.tsx +62 -0
  174. package/src/components/UserLocationPuckHeading.tsx +33 -0
  175. package/src/utils/animated/AbstractAnimatedCoordinates.ts +26 -15
  176. package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +10 -6
  177. package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +63 -51
  178. package/src/utils/animated/AnimatedShape.ts +22 -13
  179. package/lib/commonjs/components/HeadingIndicator.js.map +0 -1
  180. package/lib/module/components/HeadingIndicator.js.map +0 -1
  181. package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts +0 -7
  182. package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts.map +0 -1
  183. package/lib/typescript/module/src/components/HeadingIndicator.d.ts +0 -7
  184. package/lib/typescript/module/src/components/HeadingIndicator.d.ts.map +0 -1
  185. package/src/components/HeadingIndicator.tsx +0 -26
@@ -12,27 +12,25 @@
12
12
 
13
13
  @implementation HiddenUserLocationAnnotationView
14
14
 
15
-
16
15
  - (void)update {
17
- self.frame = CGRectNull;
16
+ self.frame = CGRectNull;
18
17
  }
19
18
 
20
19
  @end
21
20
 
22
-
23
21
  @implementation MLRNUserLocation : NSObject
24
22
 
25
- + (id)sharedInstance
26
- {
27
- static MLRNUserLocation *userLocation = nil;
28
- static dispatch_once_t onceToken;
29
- dispatch_once(&onceToken, ^{ userLocation = [[self alloc] init]; });
30
- return userLocation;
23
+ + (id)sharedInstance {
24
+ static MLRNUserLocation *userLocation = nil;
25
+ static dispatch_once_t onceToken;
26
+ dispatch_once(&onceToken, ^{
27
+ userLocation = [[self alloc] init];
28
+ });
29
+ return userLocation;
31
30
  }
32
31
 
33
- - (MLNUserLocationAnnotationView*)hiddenUserAnnotation
34
- {
35
- return [[HiddenUserLocationAnnotationView alloc] init];
32
+ - (MLNUserLocationAnnotationView *)hiddenUserAnnotation {
33
+ return [[HiddenUserLocationAnnotationView alloc] init];
36
34
  }
37
35
 
38
36
  @end
@@ -5,19 +5,26 @@
5
5
 
6
6
  @import MapLibre;
7
7
 
8
- @interface MLRNUtils: NSObject
8
+ @interface MLRNUtils : NSObject
9
9
 
10
- + (CLLocationCoordinate2D)fromFeature:(NSString*)json;
11
- + (MLNShape*)shapeFromGeoJSON:(NSString*)json;
12
- + (MLNCoordinateBounds)fromFeatureCollection:(NSString*)json;
10
+ + (CLLocationCoordinate2D)fromFeature:(NSString *)json;
11
+ + (MLNShape *)shapeFromGeoJSON:(NSString *)json;
12
+ + (MLNCoordinateBounds)fromFeatureCollection:(NSString *)json;
13
13
  + (NSArray<NSNumber *> *)fromCoordinateBounds:(MLNCoordinateBounds)bounds;
14
- + (NSTimeInterval)fromMS:(NSNumber*)number;
15
- + (NSNumber*)clamp:(NSNumber*)value min:(NSNumber*)min max:(NSNumber*)max;
16
- + (UIColor*)toColor:(id)value;
17
- + (void)fetchImage:(RCTBridge*)bridge url:(NSString*)url scale:(double)scale callback:(RCTImageLoaderCompletionBlock)callback;
18
- + (void)fetchImages:(RCTBridge *)bridge style:(MLNStyle *)style objects:(NSDictionary<NSString *, NSString *>*)objects forceUpdate:(BOOL)forceUpdate callback:(void (^)(void))callback;
19
- + (CGVector)toCGVector:(NSArray<NSNumber*>*)arr;
14
+ + (NSTimeInterval)fromMS:(NSNumber *)number;
15
+ + (NSNumber *)clamp:(NSNumber *)value min:(NSNumber *)min max:(NSNumber *)max;
16
+ + (UIColor *)toColor:(id)value;
17
+ + (void)fetchImage:(RCTBridge *)bridge
18
+ url:(NSString *)url
19
+ scale:(double)scale
20
+ callback:(RCTImageLoaderCompletionBlock)callback;
21
+ + (void)fetchImages:(RCTBridge *)bridge
22
+ style:(MLNStyle *)style
23
+ objects:(NSDictionary<NSString *, NSString *> *)objects
24
+ forceUpdate:(BOOL)forceUpdate
25
+ callback:(void (^)(void))callback;
26
+ + (CGVector)toCGVector:(NSArray<NSNumber *> *)arr;
20
27
  + (UIEdgeInsets)toUIEdgeInsets:(NSArray<NSNumber *> *)arr;
21
- + (NSURL*)styleURLFromStyleJSON:(NSString *)styleJSON;
28
+ + (NSURL *)styleURLFromStyleJSON:(NSString *)styleJSON;
22
29
 
23
30
  @end
@@ -7,204 +7,212 @@
7
7
 
8
8
  static double const MS_TO_S = 0.001;
9
9
 
10
- + (CLLocationCoordinate2D)fromFeature:(NSString*)jsonStr
11
- {
12
- NSData* data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
13
- MLNPointFeature *feature = (MLNPointFeature*)[MLNShape shapeWithData:data encoding:NSUTF8StringEncoding error:nil];
14
- return feature.coordinate;
10
+ + (CLLocationCoordinate2D)fromFeature:(NSString *)jsonStr {
11
+ NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
12
+ MLNPointFeature *feature = (MLNPointFeature *)[MLNShape shapeWithData:data
13
+ encoding:NSUTF8StringEncoding
14
+ error:nil];
15
+ return feature.coordinate;
15
16
  }
16
17
 
17
- + (UIEdgeInsets)toUIEdgeInsets:(NSArray<NSNumber *> *)arr
18
- {
19
- return UIEdgeInsetsMake([arr[0] floatValue], [arr[1] floatValue], [arr[2] floatValue], [arr[3] floatValue]);
18
+ + (UIEdgeInsets)toUIEdgeInsets:(NSArray<NSNumber *> *)arr {
19
+ return UIEdgeInsetsMake([arr[0] floatValue], [arr[1] floatValue], [arr[2] floatValue],
20
+ [arr[3] floatValue]);
20
21
  }
21
22
 
22
- + (MLNShape*)shapeFromGeoJSON:(NSString*)jsonStr
23
- {
24
- NSData* data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
25
- NSError* error = nil;
26
- MLNShape* result = [MLNShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
27
- if (error != nil) {
28
- RCTLogWarn(@"Failed to convert data to shape error:%@ src:%@", error, jsonStr);
29
- }
30
- return result;
23
+ + (MLNShape *)shapeFromGeoJSON:(NSString *)jsonStr {
24
+ NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
25
+ NSError *error = nil;
26
+ MLNShape *result = [MLNShape shapeWithData:data encoding:NSUTF8StringEncoding error:&error];
27
+ if (error != nil) {
28
+ RCTLogWarn(@"Failed to convert data to shape error:%@ src:%@", error, jsonStr);
29
+ }
30
+ return result;
31
31
  }
32
32
 
33
- + (NSString *)hashURI:(NSString *)uri
34
- {
35
- if (uri == nil) {
36
- return @"-1";
37
- }
38
- NSUInteger hash = [uri hash];
39
- return [NSString stringWithFormat:@"%lu", (unsigned long)hash];
33
+ + (NSString *)hashURI:(NSString *)uri {
34
+ if (uri == nil) {
35
+ return @"-1";
36
+ }
37
+ NSUInteger hash = [uri hash];
38
+ return [NSString stringWithFormat:@"%lu", (unsigned long)hash];
40
39
  }
41
40
 
42
- + (MLNCoordinateBounds)fromFeatureCollection:(NSString*)jsonStr
43
- {
44
- NSData* data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
45
- MLNShapeCollectionFeature *featureCollection = (MLNShapeCollectionFeature*)[MLNShapeCollectionFeature shapeWithData:data encoding:NSUTF8StringEncoding error:nil];
46
-
47
- CLLocationCoordinate2D ne = featureCollection.shapes[0].coordinate;
48
- CLLocationCoordinate2D sw = featureCollection.shapes[1].coordinate;
49
-
50
- return MLNCoordinateBoundsMake(sw, ne);
41
+ + (MLNCoordinateBounds)fromFeatureCollection:(NSString *)jsonStr {
42
+ NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
43
+ MLNShapeCollectionFeature *featureCollection =
44
+ (MLNShapeCollectionFeature *)[MLNShapeCollectionFeature shapeWithData:data
45
+ encoding:NSUTF8StringEncoding
46
+ error:nil];
47
+
48
+ CLLocationCoordinate2D ne = featureCollection.shapes[0].coordinate;
49
+ CLLocationCoordinate2D sw = featureCollection.shapes[1].coordinate;
50
+
51
+ return MLNCoordinateBoundsMake(sw, ne);
51
52
  }
52
53
 
53
- + (NSArray<NSNumber *> *)fromCoordinateBounds:(MLNCoordinateBounds)bounds
54
- {
55
- return @[
56
- @[@(bounds.ne.longitude), @(bounds.ne.latitude)],
57
- @[@(bounds.sw.longitude), @(bounds.sw.latitude)]
58
- ];
54
+ + (NSArray<NSNumber *> *)fromCoordinateBounds:(MLNCoordinateBounds)bounds {
55
+ return @[
56
+ @[ @(bounds.ne.longitude), @(bounds.ne.latitude) ],
57
+ @[ @(bounds.sw.longitude), @(bounds.sw.latitude) ]
58
+ ];
59
59
  }
60
60
 
61
- + (NSTimeInterval)fromMS:(NSNumber *)number
62
- {
63
- return [number doubleValue] * MS_TO_S;
61
+ + (NSTimeInterval)fromMS:(NSNumber *)number {
62
+ return [number doubleValue] * MS_TO_S;
64
63
  }
65
64
 
66
- + (NSNumber*)clamp:(NSNumber *)value min:(NSNumber *)min max:(NSNumber *)max
67
- {
68
- if ([value doubleValue] < [min doubleValue]) return min;
69
- if ([value doubleValue] > [max doubleValue]) return max;
70
- return value;
65
+ + (NSNumber *)clamp:(NSNumber *)value min:(NSNumber *)min max:(NSNumber *)max {
66
+ if ([value doubleValue] < [min doubleValue]) return min;
67
+ if ([value doubleValue] > [max doubleValue]) return max;
68
+ return value;
71
69
  }
72
70
 
73
- + (UIColor*)toColor:(id)value
74
- {
75
- return [RCTConvert UIColor:value];
71
+ + (UIColor *)toColor:(id)value {
72
+ return [RCTConvert UIColor:value];
76
73
  }
77
74
 
78
- + (CGVector)toCGVector:(NSArray<NSNumber *> *)arr
79
- {
80
- return CGVectorMake([arr[0] floatValue], [arr[1] floatValue]);
75
+ + (CGVector)toCGVector:(NSArray<NSNumber *> *)arr {
76
+ return CGVectorMake([arr[0] floatValue], [arr[1] floatValue]);
81
77
  }
82
78
 
83
- + (void)fetchImage:(RCTBridge*)bridge url:(NSString *)url scale:(double)scale callback:(RCTImageLoaderCompletionBlock)callback
84
- {
85
- [MLRNImageQueue.sharedInstance addImage:url scale:scale bridge:bridge completionHandler:callback];
79
+ + (void)fetchImage:(RCTBridge *)bridge
80
+ url:(NSString *)url
81
+ scale:(double)scale
82
+ callback:(RCTImageLoaderCompletionBlock)callback {
83
+ [MLRNImageQueue.sharedInstance addImage:url scale:scale bridge:bridge completionHandler:callback];
86
84
  }
87
85
 
88
- + (void)fetchImages:(RCTBridge *)bridge style:(MLNStyle *)style objects:(NSDictionary<NSString *, id>*)objects forceUpdate:(BOOL)forceUpdate callback:(void (^)(void))callback
89
- {
90
- if (objects == nil) {
91
- callback();
92
- return;
86
+ + (void)fetchImages:(RCTBridge *)bridge
87
+ style:(MLNStyle *)style
88
+ objects:(NSDictionary<NSString *, id> *)objects
89
+ forceUpdate:(BOOL)forceUpdate
90
+ callback:(void (^)(void))callback {
91
+ if (objects == nil) {
92
+ callback();
93
+ return;
94
+ }
95
+
96
+ NSArray<NSString *> *imageNames = objects.allKeys;
97
+ if (imageNames.count == 0) {
98
+ callback();
99
+ return;
100
+ }
101
+
102
+ __block NSUInteger imagesLeftToLoad = imageNames.count;
103
+ __weak MLNStyle *weakStyle = style;
104
+
105
+ void (^imageLoadedBlock)(void) = ^{
106
+ imagesLeftToLoad--;
107
+
108
+ if (imagesLeftToLoad == 0) {
109
+ callback();
93
110
  }
94
-
95
- NSArray<NSString *> *imageNames = objects.allKeys;
96
- if (imageNames.count == 0) {
97
- callback();
98
- return;
99
- }
100
-
101
- __block NSUInteger imagesLeftToLoad = imageNames.count;
102
- __weak MLNStyle *weakStyle = style;
103
-
104
- void (^imageLoadedBlock)(void) = ^{
105
- imagesLeftToLoad--;
106
-
107
- if (imagesLeftToLoad == 0) {
108
- callback();
109
- }
110
- };
111
-
112
- for (NSString *imageName in imageNames) {
113
- UIImage *foundImage = forceUpdate ? nil : [style imageForName:imageName];
114
-
115
- if (forceUpdate || foundImage == nil) {
116
- NSDictionary* image = objects[imageName];
117
- BOOL hasScale = [image isKindOfClass:[NSDictionary class]] && ([image objectForKey:@"scale"] != nil);
118
- double scale = hasScale ? [[image objectForKey:@"scale"] doubleValue] : 1.0;
119
- [MLRNImageQueue.sharedInstance addImage:objects[imageName] scale:scale bridge:bridge completionHandler:^(NSError *error, UIImage *image) {
120
- if (!image) {
121
- RCTLogWarn(@"Failed to fetch image: %@ error:%@", imageName, error);
122
- }
123
- else {
124
- dispatch_async(dispatch_get_main_queue(), ^{
125
- [weakStyle setImage:image forName:imageName];
126
- imageLoadedBlock();
127
- });
128
- }
129
- }];
130
- } else {
131
- imageLoadedBlock();
132
- }
111
+ };
112
+
113
+ for (NSString *imageName in imageNames) {
114
+ UIImage *foundImage = forceUpdate ? nil : [style imageForName:imageName];
115
+
116
+ if (forceUpdate || foundImage == nil) {
117
+ NSDictionary *image = objects[imageName];
118
+ BOOL hasScale =
119
+ [image isKindOfClass:[NSDictionary class]] && ([image objectForKey:@"scale"] != nil);
120
+ double scale = hasScale ? [[image objectForKey:@"scale"] doubleValue] : 1.0;
121
+ [MLRNImageQueue.sharedInstance addImage:objects[imageName]
122
+ scale:scale
123
+ bridge:bridge
124
+ completionHandler:^(NSError *error, UIImage *image) {
125
+ if (!image) {
126
+ RCTLogWarn(@"Failed to fetch image: %@ error:%@", imageName, error);
127
+ } else {
128
+ dispatch_async(dispatch_get_main_queue(), ^{
129
+ [weakStyle setImage:image forName:imageName];
130
+ imageLoadedBlock();
131
+ });
132
+ }
133
+ }];
134
+ } else {
135
+ imageLoadedBlock();
133
136
  }
137
+ }
134
138
  }
135
139
 
136
- + (NSString*)getStyleJsonTempDirectory
137
- {
138
- static NSString *styleJsonTempDirectory;
139
- if (!styleJsonTempDirectory) {
140
- styleJsonTempDirectory = [NSTemporaryDirectory() stringByAppendingPathComponent:@"MLRNStyleJSON"];
141
- }
142
- return styleJsonTempDirectory;
140
+ + (NSString *)getStyleJsonTempDirectory {
141
+ static NSString *styleJsonTempDirectory;
142
+ if (!styleJsonTempDirectory) {
143
+ styleJsonTempDirectory =
144
+ [NSTemporaryDirectory() stringByAppendingPathComponent:@"MLRNStyleJSON"];
145
+ }
146
+ return styleJsonTempDirectory;
143
147
  }
144
148
 
145
149
  /**
146
- * Clears cached style-json entries from previous app runs. Can be safely called multiple times as it will
147
- * only perform the action once per app run.
150
+ * Clears cached style-json entries from previous app runs. Can be safely called multiple times as
151
+ * it will only perform the action once per app run.
148
152
  *
149
153
  * @see styleURLFromStyleJSON:
150
154
  */
151
- + (void)cleanCustomStyleJSONCacheIfNeeded
152
- {
153
- NSFileManager *fileManager = [NSFileManager defaultManager];
154
- NSString *styleJsonTempDirectory = [MLRNUtils getStyleJsonTempDirectory];
155
-
156
- static dispatch_once_t onceToken;
157
- dispatch_once(&onceToken, ^{
158
- if ([fileManager fileExistsAtPath:styleJsonTempDirectory]) {
159
- [fileManager removeItemAtPath:styleJsonTempDirectory error:NULL];
160
- }
161
- });
155
+ + (void)cleanCustomStyleJSONCacheIfNeeded {
156
+ NSFileManager *fileManager = [NSFileManager defaultManager];
157
+ NSString *styleJsonTempDirectory = [MLRNUtils getStyleJsonTempDirectory];
158
+
159
+ static dispatch_once_t onceToken;
160
+ dispatch_once(&onceToken, ^{
161
+ if ([fileManager fileExistsAtPath:styleJsonTempDirectory]) {
162
+ [fileManager removeItemAtPath:styleJsonTempDirectory error:NULL];
163
+ }
164
+ });
162
165
  }
163
166
 
164
167
  /**
165
- * Provides a way to convert raw style-json into a file so it can be directly referenced / used as styleURL.
166
- * It's a crude / alternative approach to support Android's API: Style.Builder.fromJson().
168
+ * Provides a way to convert raw style-json into a file so it can be directly referenced / used as
169
+ * styleURL. It's a crude / alternative approach to support Android's API: Style.Builder.fromJson().
167
170
  */
168
- + (NSURL*)styleURLFromStyleJSON:(NSString *)styleJSON
169
- {
170
- [MLRNUtils cleanCustomStyleJSONCacheIfNeeded];
171
-
172
- NSFileManager *fileManager = [NSFileManager defaultManager];
173
- NSString *styleJsonTempDirectory = [MLRNUtils getStyleJsonTempDirectory];
174
-
175
- // attempt to create the temporary directory
176
- if (![fileManager fileExistsAtPath:styleJsonTempDirectory]) {
177
- NSError *error;
178
- [fileManager createDirectoryAtPath:styleJsonTempDirectory
179
- withIntermediateDirectories:YES
180
- attributes:nil
181
- error:&error];
182
- if (error) {
183
- RCTLogError(@"Failed to create temporary directory '%@' for storing style-json. Error: %@", styleJsonTempDirectory, error);
184
- return nil;
185
- }
171
+ + (NSURL *)styleURLFromStyleJSON:(NSString *)styleJSON {
172
+ [MLRNUtils cleanCustomStyleJSONCacheIfNeeded];
173
+
174
+ NSFileManager *fileManager = [NSFileManager defaultManager];
175
+ NSString *styleJsonTempDirectory = [MLRNUtils getStyleJsonTempDirectory];
176
+
177
+ // attempt to create the temporary directory
178
+ if (![fileManager fileExistsAtPath:styleJsonTempDirectory]) {
179
+ NSError *error;
180
+ [fileManager createDirectoryAtPath:styleJsonTempDirectory
181
+ withIntermediateDirectories:YES
182
+ attributes:nil
183
+ error:&error];
184
+ if (error) {
185
+ RCTLogError(@"Failed to create temporary directory '%@' for storing style-json. Error: %@",
186
+ styleJsonTempDirectory, error);
187
+ return nil;
186
188
  }
187
-
188
- // Determine filename based on the md5 hash of the style-json.
189
- // This way, the written file can also act as a cached entry in case
190
- // the same style-json is used again.
191
- NSString *hashedFilename = [RCTMD5Hash(styleJSON) stringByAppendingPathExtension:@"json"];
192
-
193
- // Construct temporary file path (tempdir + md5 hash for filename)
194
- NSString *styleJsonTempPath = [styleJsonTempDirectory stringByAppendingPathComponent:hashedFilename];
195
- NSURL* styleJsonTempURL = [NSURL fileURLWithPath:styleJsonTempPath isDirectory:false];
196
-
197
- // Write style-json to temporary file in case it doesn't already exist
198
- if (![fileManager fileExistsAtPath:styleJsonTempPath isDirectory:false]) {
199
- NSError *error;
200
- [styleJSON writeToURL:styleJsonTempURL atomically:YES encoding:NSUTF8StringEncoding error:&error];
201
- if (error) {
202
- RCTLogError(@"Failed to write style-json to temporary file '%@'. Error: %@", styleJsonTempURL, error);
203
- return nil;
204
- }
189
+ }
190
+
191
+ // Determine filename based on the md5 hash of the style-json.
192
+ // This way, the written file can also act as a cached entry in case
193
+ // the same style-json is used again.
194
+ NSString *hashedFilename = [RCTMD5Hash(styleJSON) stringByAppendingPathExtension:@"json"];
195
+
196
+ // Construct temporary file path (tempdir + md5 hash for filename)
197
+ NSString *styleJsonTempPath =
198
+ [styleJsonTempDirectory stringByAppendingPathComponent:hashedFilename];
199
+ NSURL *styleJsonTempURL = [NSURL fileURLWithPath:styleJsonTempPath isDirectory:false];
200
+
201
+ // Write style-json to temporary file in case it doesn't already exist
202
+ if (![fileManager fileExistsAtPath:styleJsonTempPath isDirectory:false]) {
203
+ NSError *error;
204
+ [styleJSON writeToURL:styleJsonTempURL
205
+ atomically:YES
206
+ encoding:NSUTF8StringEncoding
207
+ error:&error];
208
+ if (error) {
209
+ RCTLogError(@"Failed to write style-json to temporary file '%@'. Error: %@", styleJsonTempURL,
210
+ error);
211
+ return nil;
205
212
  }
206
-
207
- return styleJsonTempURL;
213
+ }
214
+
215
+ return styleJsonTempURL;
208
216
  }
209
217
 
210
218
  @end
@@ -1,51 +1,45 @@
1
1
  #import "MLRNVectorLayer.h"
2
- #import "MLRNStyle.h"
3
- #import "FilterParser.h"
4
2
  #import <React/RCTLog.h>
3
+ #import "FilterParser.h"
4
+ #import "MLRNStyle.h"
5
5
 
6
6
  @implementation MLRNVectorLayer
7
7
 
8
-
9
- - (NSPredicate*)buildFilters
10
- {
11
- return self.filter ? [FilterParser parse:self.filter] : nil;
8
+ - (NSPredicate *)buildFilters {
9
+ return self.filter ? [FilterParser parse:self.filter] : nil;
12
10
  }
13
11
 
14
- - (void)updateFilter:(NSPredicate *)predicate
15
- {
16
- @try {
17
- ((MLNVectorStyleLayer *) self.styleLayer).predicate = predicate;
18
- }
19
- @catch (NSException* exception) {
20
- RCTLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self, exception.name, exception.reason);
21
- }
12
+ - (void)updateFilter:(NSPredicate *)predicate {
13
+ @try {
14
+ ((MLNVectorStyleLayer *)self.styleLayer).predicate = predicate;
15
+ } @catch (NSException *exception) {
16
+ RCTLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self,
17
+ exception.name, exception.reason);
18
+ }
22
19
  }
23
20
 
24
- - (void)setSourceLayerID:(NSString *)sourceLayerID
25
- {
26
- _sourceLayerID = sourceLayerID;
27
-
28
- if (self.styleLayer != nil) {
29
- ((MLNVectorStyleLayer*) self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
30
- }
21
+ - (void)setSourceLayerID:(NSString *)sourceLayerID {
22
+ _sourceLayerID = sourceLayerID;
23
+
24
+ if (self.styleLayer != nil) {
25
+ ((MLNVectorStyleLayer *)self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
26
+ }
31
27
  }
32
28
 
33
- - (void)addedToMap
34
- {
35
- NSPredicate *filter = [self buildFilters];
36
- if (filter != nil) {
37
- [self updateFilter:filter];
38
- }
29
+ - (void)addedToMap {
30
+ NSPredicate *filter = [self buildFilters];
31
+ if (filter != nil) {
32
+ [self updateFilter:filter];
33
+ }
39
34
  }
40
35
 
41
- - (void)setFilter:(NSArray*)filter
42
- {
43
- [super setFilter: filter];
36
+ - (void)setFilter:(NSArray *)filter {
37
+ [super setFilter:filter];
44
38
 
45
- if (self.styleLayer != nil) {
46
- NSPredicate *predicate = [self buildFilters];
47
- [self updateFilter:predicate];
48
- }
39
+ if (self.styleLayer != nil) {
40
+ NSPredicate *predicate = [self buildFilters];
41
+ [self updateFilter:predicate];
42
+ }
49
43
  }
50
44
 
51
45
  @end
@@ -3,6 +3,8 @@
3
3
 
4
4
  @interface MLRNVectorSource : MLRNTileSource
5
5
 
6
- - (nonnull NSArray<id <MLNFeature>> *)featuresInSourceLayersWithIdentifiers:(nonnull NSSet<NSString *> *)sourceLayerIdentifiers predicate:(nullable NSPredicate *)predicate;
6
+ - (nonnull NSArray<id<MLNFeature>> *)
7
+ featuresInSourceLayersWithIdentifiers:(nonnull NSSet<NSString *> *)sourceLayerIdentifiers
8
+ predicate:(nullable NSPredicate *)predicate;
7
9
 
8
10
  @end
@@ -2,19 +2,22 @@
2
2
 
3
3
  @implementation MLRNVectorSource
4
4
 
5
- - (nullable MLNSource*)makeSource
6
- {
7
- if (self.url != nil) {
8
- return [[MLNVectorTileSource alloc] initWithIdentifier:self.id configurationURLString:self.url];
9
- }
10
- return [[MLNVectorTileSource alloc] initWithIdentifier:self.id tileURLTemplates:self.tileUrlTemplates options:[self getOptions]];
5
+ - (nullable MLNSource *)makeSource {
6
+ if (self.url != nil) {
7
+ return [[MLNVectorTileSource alloc] initWithIdentifier:self.id configurationURLString:self.url];
8
+ }
9
+ return [[MLNVectorTileSource alloc] initWithIdentifier:self.id
10
+ tileURLTemplates:self.tileUrlTemplates
11
+ options:[self getOptions]];
11
12
  }
12
13
 
13
- - (nonnull NSArray<id <MLNFeature>> *)featuresInSourceLayersWithIdentifiers:(nonnull NSSet<NSString *> *)sourceLayerIdentifiers predicate:(nullable NSPredicate *)predicate
14
- {
15
- MLNVectorTileSource* vectorSource = (MLNVectorTileSource*)self.source;
16
-
17
- return [vectorSource featuresInSourceLayersWithIdentifiers:sourceLayerIdentifiers predicate: predicate];
14
+ - (nonnull NSArray<id<MLNFeature>> *)
15
+ featuresInSourceLayersWithIdentifiers:(nonnull NSSet<NSString *> *)sourceLayerIdentifiers
16
+ predicate:(nullable NSPredicate *)predicate {
17
+ MLNVectorTileSource *vectorSource = (MLNVectorTileSource *)self.source;
18
+
19
+ return [vectorSource featuresInSourceLayersWithIdentifiers:sourceLayerIdentifiers
20
+ predicate:predicate];
18
21
  }
19
22
 
20
23
  @end
@@ -1,6 +1,6 @@
1
- #import "ViewManager.h"
2
1
  #import <React/RCTBridgeModule.h>
2
+ #import "ViewManager.h"
3
3
 
4
- @interface MLRNVectorSourceManager : ViewManager<RCTBridgeModule>
4
+ @interface MLRNVectorSourceManager : ViewManager <RCTBridgeModule>
5
5
 
6
6
  @end