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