@lugg/maps 0.2.0-alpha.0 → 0.2.0-alpha.10

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/README.md +17 -4
  2. package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt} +111 -36
  3. package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapViewManager.kt → LuggGoogleMapViewManager.kt} +66 -39
  4. package/android/src/main/java/com/luggmaps/{LuggMapsWrapperView.kt → LuggMapWrapperView.kt} +1 -1
  5. package/android/src/main/java/com/luggmaps/LuggMapWrapperViewManager.kt +25 -0
  6. package/android/src/main/java/com/luggmaps/{LuggMapsMarkerView.kt → LuggMarkerView.kt} +13 -7
  7. package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt} +23 -17
  8. package/android/src/main/java/com/luggmaps/{LuggMapsPackage.kt → LuggPackage.kt} +2 -2
  9. package/android/src/main/java/com/luggmaps/{LuggMapsPolylineView.kt → LuggPolylineView.kt} +11 -4
  10. package/android/src/main/java/com/luggmaps/{LuggMapsPolylineViewManager.kt → LuggPolylineViewManager.kt} +22 -16
  11. package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -43
  12. package/android/src/main/java/com/luggmaps/events/CameraIdleEvent.kt +10 -2
  13. package/android/src/main/java/com/luggmaps/events/CameraMoveEvent.kt +6 -5
  14. package/android/src/main/java/com/luggmaps/events/ReadyEvent.kt +12 -0
  15. package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +14 -0
  16. package/ios/{LuggMapsAppleMapView.h → LuggAppleMapView.h} +2 -2
  17. package/ios/{LuggMapsAppleMapView.mm → LuggAppleMapView.mm} +140 -71
  18. package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
  19. package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +82 -64
  20. package/ios/{LuggMapsWrapperView.h → LuggMapWrapperView.h} +1 -1
  21. package/ios/{LuggMapsWrapperView.mm → LuggMapWrapperView.mm} +7 -7
  22. package/ios/{LuggMapsMarkerView.h → LuggMarkerView.h} +8 -6
  23. package/ios/{LuggMapsMarkerView.mm → LuggMarkerView.mm} +21 -8
  24. package/ios/{LuggMapsPolylineView.h → LuggPolylineView.h} +6 -5
  25. package/ios/{LuggMapsPolylineView.mm → LuggPolylineView.mm} +14 -9
  26. package/ios/core/GMSPolylineAnimator.m +85 -36
  27. package/ios/core/MKPolylineAnimator.m +63 -32
  28. package/ios/events/CameraIdleEvent.h +6 -1
  29. package/ios/events/CameraMoveEvent.h +6 -3
  30. package/ios/events/ReadyEvent.h +20 -0
  31. package/lib/module/MapProvider.js +13 -0
  32. package/lib/module/MapProvider.js.map +1 -0
  33. package/lib/module/MapProvider.types.js +4 -0
  34. package/lib/module/MapProvider.types.js.map +1 -0
  35. package/lib/module/MapProvider.web.js +14 -0
  36. package/lib/module/MapProvider.web.js.map +1 -0
  37. package/lib/module/MapView.js +21 -7
  38. package/lib/module/MapView.js.map +1 -1
  39. package/lib/module/MapView.web.js +266 -0
  40. package/lib/module/MapView.web.js.map +1 -0
  41. package/lib/module/{Marker.js → components/Marker.js} +6 -3
  42. package/lib/module/components/Marker.js.map +1 -0
  43. package/lib/module/components/Marker.web.js +34 -0
  44. package/lib/module/components/Marker.web.js.map +1 -0
  45. package/lib/module/{Polyline.js → components/Polyline.js} +7 -4
  46. package/lib/module/components/Polyline.js.map +1 -0
  47. package/lib/module/components/Polyline.web.js +177 -0
  48. package/lib/module/components/Polyline.web.js.map +1 -0
  49. package/lib/module/components/index.js +5 -0
  50. package/lib/module/components/index.js.map +1 -0
  51. package/lib/module/components/index.web.js +5 -0
  52. package/lib/module/components/index.web.js.map +1 -0
  53. package/{src/fabric/LuggMapsAppleMapViewNativeComponent.ts → lib/module/fabric/LuggAppleMapViewNativeComponent.ts} +13 -3
  54. package/lib/module/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +13 -3
  55. package/{src/fabric/LuggMapsWrapperViewNativeComponent.ts → lib/module/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
  56. package/lib/module/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
  57. package/{src/fabric/LuggMapsPolylineViewNativeComponent.ts → lib/module/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
  58. package/lib/module/index.js +3 -3
  59. package/lib/module/index.js.map +1 -1
  60. package/lib/module/index.web.js +6 -0
  61. package/lib/module/index.web.js.map +1 -0
  62. package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts +6 -0
  63. package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts.map +1 -0
  64. package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts +6 -0
  65. package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts.map +1 -0
  66. package/lib/typescript/src/MapProvider.d.ts +8 -0
  67. package/lib/typescript/src/MapProvider.d.ts.map +1 -0
  68. package/lib/typescript/src/MapProvider.types.d.ts +16 -0
  69. package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
  70. package/lib/typescript/src/MapProvider.web.d.ts +3 -0
  71. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -0
  72. package/lib/typescript/src/MapView.d.ts.map +1 -1
  73. package/lib/typescript/src/MapView.types.d.ts +24 -14
  74. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  75. package/lib/typescript/src/MapView.web.d.ts +12 -0
  76. package/lib/typescript/src/MapView.web.d.ts.map +1 -0
  77. package/lib/typescript/src/{Marker.types.d.ts → components/Marker.d.ts} +10 -5
  78. package/lib/typescript/src/components/Marker.d.ts.map +1 -0
  79. package/lib/typescript/src/{Marker.d.ts → components/Marker.web.d.ts} +2 -2
  80. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
  81. package/lib/typescript/src/{Polyline.types.d.ts → components/Polyline.d.ts} +10 -5
  82. package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
  83. package/lib/typescript/src/components/Polyline.web.d.ts +6 -0
  84. package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -0
  85. package/lib/typescript/src/components/index.d.ts +3 -0
  86. package/lib/typescript/src/components/index.d.ts.map +1 -0
  87. package/lib/typescript/src/components/index.web.d.ts +5 -0
  88. package/lib/typescript/src/components/index.web.d.ts.map +1 -0
  89. package/lib/typescript/src/fabric/{LuggMapsAppleMapViewNativeComponent.d.ts → LuggAppleMapViewNativeComponent.d.ts} +10 -3
  90. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -0
  91. package/lib/typescript/src/fabric/{LuggMapsGoogleMapViewNativeComponent.d.ts → LuggGoogleMapViewNativeComponent.d.ts} +10 -3
  92. package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +1 -0
  93. package/lib/typescript/src/fabric/{LuggMapsWrapperViewNativeComponent.d.ts → LuggMapWrapperViewNativeComponent.d.ts} +1 -1
  94. package/lib/typescript/src/fabric/LuggMapWrapperViewNativeComponent.d.ts.map +1 -0
  95. package/lib/typescript/src/fabric/{LuggMapsMarkerViewNativeComponent.d.ts → LuggMarkerViewNativeComponent.d.ts} +1 -1
  96. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -0
  97. package/lib/typescript/src/fabric/{LuggMapsPolylineViewNativeComponent.d.ts → LuggPolylineViewNativeComponent.d.ts} +1 -1
  98. package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -0
  99. package/lib/typescript/src/index.d.ts +5 -6
  100. package/lib/typescript/src/index.d.ts.map +1 -1
  101. package/lib/typescript/src/index.web.d.ts +7 -0
  102. package/lib/typescript/src/index.web.d.ts.map +1 -0
  103. package/package.json +20 -7
  104. package/plugin/build/index.js +4 -4
  105. package/{lib/typescript/plugin/src/withMapsAndroid.d.ts → plugin/build/withLuggMapsAndroid.d.ts} +0 -1
  106. package/plugin/build/withLuggMapsAndroid.js +15 -0
  107. package/{lib/typescript/plugin/src/withMapsIOS.d.ts → plugin/build/withLuggMapsIOS.d.ts} +0 -1
  108. package/plugin/build/withLuggMapsIOS.js +27 -0
  109. package/plugin/build/withMapsAndroid.d.ts +1 -1
  110. package/plugin/build/withMapsIOS.d.ts +1 -1
  111. package/src/MapProvider.tsx +10 -0
  112. package/src/MapProvider.types.ts +16 -0
  113. package/src/MapProvider.web.tsx +6 -0
  114. package/src/MapView.tsx +27 -10
  115. package/src/MapView.types.ts +24 -15
  116. package/src/MapView.web.tsx +319 -0
  117. package/src/components/Marker.tsx +63 -0
  118. package/src/components/Marker.web.tsx +32 -0
  119. package/src/components/Polyline.tsx +57 -0
  120. package/src/components/Polyline.web.tsx +222 -0
  121. package/src/components/index.ts +2 -0
  122. package/src/components/index.web.ts +4 -0
  123. package/{lib/module/fabric/LuggMapsAppleMapViewNativeComponent.ts → src/fabric/LuggAppleMapViewNativeComponent.ts} +13 -3
  124. package/src/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +13 -3
  125. package/{lib/module/fabric/LuggMapsWrapperViewNativeComponent.ts → src/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
  126. package/src/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
  127. package/{lib/module/fabric/LuggMapsPolylineViewNativeComponent.ts → src/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
  128. package/src/index.ts +11 -7
  129. package/src/index.web.ts +17 -0
  130. package/android/src/main/java/com/luggmaps/LuggMapsWrapperViewManager.kt +0 -25
  131. package/lib/module/Marker.js.map +0 -1
  132. package/lib/module/Marker.types.js +0 -4
  133. package/lib/module/Marker.types.js.map +0 -1
  134. package/lib/module/Polyline.js.map +0 -1
  135. package/lib/module/Polyline.types.js +0 -4
  136. package/lib/module/Polyline.types.js.map +0 -1
  137. package/lib/typescript/plugin/src/withMapsAndroid.d.ts.map +0 -1
  138. package/lib/typescript/plugin/src/withMapsIOS.d.ts.map +0 -1
  139. package/lib/typescript/src/Marker.d.ts.map +0 -1
  140. package/lib/typescript/src/Marker.types.d.ts.map +0 -1
  141. package/lib/typescript/src/Polyline.d.ts +0 -6
  142. package/lib/typescript/src/Polyline.d.ts.map +0 -1
  143. package/lib/typescript/src/Polyline.types.d.ts.map +0 -1
  144. package/lib/typescript/src/fabric/LuggMapsAppleMapViewNativeComponent.d.ts.map +0 -1
  145. package/lib/typescript/src/fabric/LuggMapsGoogleMapViewNativeComponent.d.ts.map +0 -1
  146. package/lib/typescript/src/fabric/LuggMapsMarkerViewNativeComponent.d.ts.map +0 -1
  147. package/lib/typescript/src/fabric/LuggMapsPolylineViewNativeComponent.d.ts.map +0 -1
  148. package/lib/typescript/src/fabric/LuggMapsWrapperViewNativeComponent.d.ts.map +0 -1
  149. package/src/Marker.tsx +0 -31
  150. package/src/Marker.types.ts +0 -32
  151. package/src/Polyline.tsx +0 -32
  152. package/src/Polyline.types.ts +0 -24
@@ -1,10 +1,11 @@
1
- #import "LuggMapsAppleMapView.h"
2
- #import "LuggMapsMarkerView.h"
3
- #import "LuggMapsPolylineView.h"
4
- #import "LuggMapsWrapperView.h"
1
+ #import "LuggAppleMapView.h"
2
+ #import "LuggMapWrapperView.h"
3
+ #import "LuggMarkerView.h"
4
+ #import "LuggPolylineView.h"
5
5
  #import "core/MKPolylineAnimator.h"
6
6
  #import "events/CameraIdleEvent.h"
7
7
  #import "events/CameraMoveEvent.h"
8
+ #import "events/ReadyEvent.h"
8
9
  #import "extensions/MKMapView+Zoom.h"
9
10
 
10
11
  #import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
@@ -21,36 +22,39 @@ using namespace luggmaps::events;
21
22
  @property(nonatomic, assign) CLLocationCoordinate2D coordinate;
22
23
  @property(nonatomic, copy, nullable) NSString *title;
23
24
  @property(nonatomic, copy, nullable) NSString *subtitle;
24
- @property(nonatomic, strong) LuggMapsMarkerView *markerView;
25
+ @property(nonatomic, strong) LuggMarkerView *markerView;
25
26
  @property(nonatomic, weak) MKAnnotationView *annotationView;
26
27
  @end
27
28
 
28
29
  @implementation AppleMarkerAnnotation
29
30
  @end
30
31
 
31
- @implementation LuggMapsAppleMapViewContent
32
+ @implementation LuggAppleMapViewContent
32
33
  @end
33
34
 
34
- @interface LuggMapsAppleMapView () <
35
- RCTLuggMapsAppleMapViewViewProtocol, MKMapViewDelegate,
36
- LuggMapsMarkerViewDelegate, LuggMapsPolylineViewDelegate>
35
+ @interface LuggAppleMapView () <RCTLuggAppleMapViewViewProtocol,
36
+ MKMapViewDelegate, LuggMarkerViewDelegate,
37
+ LuggPolylineViewDelegate>
37
38
  @end
38
39
 
39
- @implementation LuggMapsAppleMapView {
40
- LuggMapsAppleMapViewContent *_mapView;
41
- LuggMapsWrapperView *_mapWrapperView;
40
+ @implementation LuggAppleMapView {
41
+ LuggAppleMapViewContent *_mapView;
42
+ LuggMapWrapperView *_mapWrapperView;
43
+ BOOL _isMapReady;
42
44
  BOOL _isDragging;
45
+ double _minZoom;
46
+ double _maxZoom;
43
47
  }
44
48
 
45
49
  + (ComponentDescriptorProvider)componentDescriptorProvider {
46
50
  return concreteComponentDescriptorProvider<
47
- LuggMapsAppleMapViewComponentDescriptor>();
51
+ LuggAppleMapViewComponentDescriptor>();
48
52
  }
49
53
 
50
54
  - (instancetype)initWithFrame:(CGRect)frame {
51
55
  if (self = [super initWithFrame:frame]) {
52
56
  static const auto defaultProps =
53
- std::make_shared<const LuggMapsAppleMapViewProps>();
57
+ std::make_shared<const LuggAppleMapViewProps>();
54
58
  _props = defaultProps;
55
59
  }
56
60
 
@@ -64,10 +68,10 @@ using namespace luggmaps::events;
64
68
  index:(NSInteger)index {
65
69
  [super mountChildComponentView:childComponentView index:index];
66
70
 
67
- if ([childComponentView isKindOfClass:[LuggMapsWrapperView class]]) {
68
- _mapWrapperView = (LuggMapsWrapperView *)childComponentView;
69
- } else if ([childComponentView isKindOfClass:[LuggMapsMarkerView class]]) {
70
- LuggMapsMarkerView *markerView = (LuggMapsMarkerView *)childComponentView;
71
+ if ([childComponentView isKindOfClass:[LuggMapWrapperView class]]) {
72
+ _mapWrapperView = (LuggMapWrapperView *)childComponentView;
73
+ } else if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
74
+ LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
71
75
  markerView.delegate = self;
72
76
 
73
77
  AppleMarkerAnnotation *annotation = [[AppleMarkerAnnotation alloc] init];
@@ -79,9 +83,8 @@ using namespace luggmaps::events;
79
83
  }
80
84
 
81
85
  [self markerViewDidUpdate:markerView];
82
- } else if ([childComponentView isKindOfClass:[LuggMapsPolylineView class]]) {
83
- LuggMapsPolylineView *polylineView =
84
- (LuggMapsPolylineView *)childComponentView;
86
+ } else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
87
+ LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
85
88
  polylineView.delegate = self;
86
89
  [self addPolylineViewToMap:polylineView];
87
90
  }
@@ -90,8 +93,8 @@ using namespace luggmaps::events;
90
93
  - (void)unmountChildComponentView:
91
94
  (UIView<RCTComponentViewProtocol> *)childComponentView
92
95
  index:(NSInteger)index {
93
- if ([childComponentView isKindOfClass:[LuggMapsMarkerView class]]) {
94
- LuggMapsMarkerView *markerView = (LuggMapsMarkerView *)childComponentView;
96
+ if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
97
+ LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
95
98
  markerView.delegate = nil;
96
99
 
97
100
  AppleMarkerAnnotation *annotation =
@@ -103,9 +106,8 @@ using namespace luggmaps::events;
103
106
  [_mapView removeAnnotation:annotation];
104
107
  markerView.marker = nil;
105
108
  }
106
- } else if ([childComponentView isKindOfClass:[LuggMapsPolylineView class]]) {
107
- LuggMapsPolylineView *polylineView =
108
- (LuggMapsPolylineView *)childComponentView;
109
+ } else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
110
+ LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
109
111
  polylineView.delegate = nil;
110
112
  MKPolyline *polyline = (MKPolyline *)polylineView.polyline;
111
113
  if (polyline) {
@@ -130,6 +132,7 @@ using namespace luggmaps::events;
130
132
  [_mapView removeFromSuperview];
131
133
  _mapView = nil;
132
134
  _mapWrapperView = nil;
135
+ _isMapReady = NO;
133
136
  }
134
137
 
135
138
  #pragma mark - Map Initialization
@@ -140,10 +143,10 @@ using namespace luggmaps::events;
140
143
  }
141
144
 
142
145
  const auto &viewProps =
143
- *std::static_pointer_cast<LuggMapsAppleMapViewProps const>(_props);
146
+ *std::static_pointer_cast<LuggAppleMapViewProps const>(_props);
144
147
 
145
- _mapView = [[LuggMapsAppleMapViewContent alloc]
146
- initWithFrame:_mapWrapperView.bounds];
148
+ _mapView =
149
+ [[LuggAppleMapViewContent alloc] initWithFrame:_mapWrapperView.bounds];
147
150
  _mapView.autoresizingMask =
148
151
  UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
149
152
  _mapView.delegate = self;
@@ -152,6 +155,15 @@ using namespace luggmaps::events;
152
155
  _mapView.scrollEnabled = viewProps.scrollEnabled;
153
156
  _mapView.rotateEnabled = viewProps.rotateEnabled;
154
157
  _mapView.pitchEnabled = viewProps.pitchEnabled;
158
+ _mapView.showsUserLocation = viewProps.userLocationEnabled;
159
+
160
+ _minZoom = viewProps.minZoom;
161
+ _maxZoom = viewProps.maxZoom;
162
+ [self applyZoomRange];
163
+
164
+ _mapView.layoutMargins =
165
+ UIEdgeInsetsMake(viewProps.padding.top, viewProps.padding.left,
166
+ viewProps.padding.bottom, viewProps.padding.right);
155
167
 
156
168
  [_mapWrapperView addSubview:_mapView];
157
169
 
@@ -162,18 +174,22 @@ using namespace luggmaps::events;
162
174
 
163
175
  // Add annotations for any markers that were mounted before map was ready
164
176
  for (UIView *subview in self.subviews) {
165
- if ([subview isKindOfClass:[LuggMapsMarkerView class]]) {
166
- LuggMapsMarkerView *markerView = (LuggMapsMarkerView *)subview;
177
+ if ([subview isKindOfClass:[LuggMarkerView class]]) {
178
+ LuggMarkerView *markerView = (LuggMarkerView *)subview;
167
179
  AppleMarkerAnnotation *annotation =
168
180
  (AppleMarkerAnnotation *)markerView.marker;
169
181
  if (annotation) {
170
182
  [_mapView addAnnotation:annotation];
171
183
  }
172
- } else if ([subview isKindOfClass:[LuggMapsPolylineView class]]) {
173
- LuggMapsPolylineView *polylineView = (LuggMapsPolylineView *)subview;
184
+ } else if ([subview isKindOfClass:[LuggPolylineView class]]) {
185
+ LuggPolylineView *polylineView = (LuggPolylineView *)subview;
174
186
  [self addPolylineViewToMap:polylineView];
175
187
  }
176
188
  }
189
+
190
+ _isMapReady = YES;
191
+
192
+ ReadyEvent::emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
177
193
  }
178
194
 
179
195
  - (void)setCameraWithLatitude:(double)latitude
@@ -185,6 +201,27 @@ using namespace luggmaps::events;
185
201
  [_mapView setCenterCoordinate:center zoomLevel:zoom animated:animated];
186
202
  }
187
203
 
204
+ - (CLLocationDistance)cameraDistanceForZoomLevel:(double)zoomLevel {
205
+ // Approximate conversion: at zoom 0, altitude ~128M km
206
+ // Each zoom level halves the altitude
207
+ return 128000000.0 / pow(2, zoomLevel);
208
+ }
209
+
210
+ - (void)applyZoomRange {
211
+ if (!_mapView)
212
+ return;
213
+
214
+ CLLocationDistance minDistance =
215
+ _maxZoom > 0 ? [self cameraDistanceForZoomLevel:_maxZoom] : 0;
216
+ CLLocationDistance maxDistance =
217
+ _minZoom > 0 ? [self cameraDistanceForZoomLevel:_minZoom] : -1;
218
+
219
+ MKMapCameraZoomRange *zoomRange = [[MKMapCameraZoomRange alloc]
220
+ initWithMinCenterCoordinateDistance:minDistance
221
+ maxCenterCoordinateDistance:maxDistance];
222
+ _mapView.cameraZoomRange = zoomRange;
223
+ }
224
+
188
225
  - (MKMapView *)mapView {
189
226
  return _mapView;
190
227
  }
@@ -194,16 +231,21 @@ using namespace luggmaps::events;
194
231
  - (void)updateProps:(Props::Shared const &)props
195
232
  oldProps:(Props::Shared const &)oldProps {
196
233
  const auto &newViewProps =
197
- *std::static_pointer_cast<LuggMapsAppleMapViewProps const>(props);
234
+ *std::static_pointer_cast<LuggAppleMapViewProps const>(props);
198
235
 
199
236
  if (_mapView) {
200
237
  _mapView.zoomEnabled = newViewProps.zoomEnabled;
201
238
  _mapView.scrollEnabled = newViewProps.scrollEnabled;
202
239
  _mapView.rotateEnabled = newViewProps.rotateEnabled;
203
240
  _mapView.pitchEnabled = newViewProps.pitchEnabled;
241
+ _mapView.showsUserLocation = newViewProps.userLocationEnabled;
204
242
  _mapView.layoutMargins = UIEdgeInsetsMake(
205
243
  newViewProps.padding.top, newViewProps.padding.left,
206
244
  newViewProps.padding.bottom, newViewProps.padding.right);
245
+
246
+ _minZoom = newViewProps.minZoom;
247
+ _maxZoom = newViewProps.maxZoom;
248
+ [self applyZoomRange];
207
249
  }
208
250
 
209
251
  [super updateProps:props oldProps:oldProps];
@@ -213,7 +255,7 @@ using namespace luggmaps::events;
213
255
 
214
256
  - (void)updateAnnotationViewFrame:(AppleMarkerAnnotation *)annotation {
215
257
  MKAnnotationView *annotationView = annotation.annotationView;
216
- LuggMapsMarkerView *markerView = annotation.markerView;
258
+ LuggMarkerView *markerView = annotation.markerView;
217
259
 
218
260
  if (!annotationView || !markerView) {
219
261
  return;
@@ -233,13 +275,13 @@ using namespace luggmaps::events;
233
275
 
234
276
  #pragma mark - PolylineViewDelegate
235
277
 
236
- - (void)polylineViewDidUpdate:(LuggMapsPolylineView *)polylineView {
278
+ - (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
237
279
  [self syncPolylineView:polylineView];
238
280
  }
239
281
 
240
282
  #pragma mark - Polyline Management
241
283
 
242
- - (void)addPolylineViewToMap:(LuggMapsPolylineView *)polylineView {
284
+ - (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
243
285
  if (!_mapView) {
244
286
  return;
245
287
  }
@@ -260,10 +302,10 @@ using namespace luggmaps::events;
260
302
  free(coords);
261
303
 
262
304
  polylineView.polyline = polyline;
263
- [_mapView addOverlay:polyline];
305
+ [self insertOverlay:polyline withZIndex:polylineView.zIndex];
264
306
  }
265
307
 
266
- - (void)syncPolylineView:(LuggMapsPolylineView *)polylineView {
308
+ - (void)syncPolylineView:(LuggPolylineView *)polylineView {
267
309
  if (!_mapView) {
268
310
  return;
269
311
  }
@@ -274,6 +316,9 @@ using namespace luggmaps::events;
274
316
  // Build new polyline from coordinates
275
317
  NSArray<CLLocation *> *coordinates = polylineView.coordinates;
276
318
  if (coordinates.count == 0) {
319
+ if (renderer) {
320
+ renderer.animated = NO;
321
+ }
277
322
  if (oldPolyline) {
278
323
  [_mapView removeOverlay:oldPolyline];
279
324
  polylineView.polyline = nil;
@@ -295,6 +340,8 @@ using namespace luggmaps::events;
295
340
 
296
341
  // If we have an existing renderer, update it in place
297
342
  if (renderer && oldPolyline) {
343
+ [_mapView removeOverlay:oldPolyline];
344
+ [self insertOverlay:newPolyline withZIndex:polylineView.zIndex];
298
345
  [renderer updatePolyline:newPolyline];
299
346
  renderer.lineWidth = polylineView.strokeWidth;
300
347
  renderer.strokeColor = polylineView.strokeColors.firstObject;
@@ -308,13 +355,34 @@ using namespace luggmaps::events;
308
355
  if (oldPolyline) {
309
356
  [_mapView removeOverlay:oldPolyline];
310
357
  }
311
- [_mapView addOverlay:newPolyline];
358
+ [self insertOverlay:newPolyline withZIndex:polylineView.zIndex];
312
359
  }
313
360
 
314
- - (LuggMapsPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
361
+ - (void)insertOverlay:(id<MKOverlay>)overlay withZIndex:(NSInteger)zIndex {
362
+ if (zIndex == 0) {
363
+ [_mapView addOverlay:overlay];
364
+ return;
365
+ }
366
+
367
+ NSArray<id<MKOverlay>> *overlays = _mapView.overlays;
368
+ NSInteger insertIndex = overlays.count;
369
+
370
+ for (NSInteger i = 0; i < overlays.count; i++) {
371
+ LuggPolylineView *existingPolylineView =
372
+ [self findPolylineViewForOverlay:overlays[i]];
373
+ if (existingPolylineView && existingPolylineView.zIndex > zIndex) {
374
+ insertIndex = i;
375
+ break;
376
+ }
377
+ }
378
+
379
+ [_mapView insertOverlay:overlay atIndex:insertIndex];
380
+ }
381
+
382
+ - (LuggPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
315
383
  for (UIView *subview in self.subviews) {
316
- if ([subview isKindOfClass:[LuggMapsPolylineView class]]) {
317
- LuggMapsPolylineView *polylineView = (LuggMapsPolylineView *)subview;
384
+ if ([subview isKindOfClass:[LuggPolylineView class]]) {
385
+ LuggPolylineView *polylineView = (LuggPolylineView *)subview;
318
386
  if (polylineView.polyline == overlay) {
319
387
  return polylineView;
320
388
  }
@@ -325,7 +393,7 @@ using namespace luggmaps::events;
325
393
 
326
394
  #pragma mark - MarkerViewDelegate
327
395
 
328
- - (void)markerViewDidLayout:(LuggMapsMarkerView *)markerView {
396
+ - (void)markerViewDidLayout:(LuggMarkerView *)markerView {
329
397
  AppleMarkerAnnotation *annotation =
330
398
  (AppleMarkerAnnotation *)markerView.marker;
331
399
  if (annotation) {
@@ -333,7 +401,7 @@ using namespace luggmaps::events;
333
401
  }
334
402
  }
335
403
 
336
- - (void)markerViewDidUpdate:(LuggMapsMarkerView *)markerView {
404
+ - (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
337
405
  AppleMarkerAnnotation *annotation =
338
406
  (AppleMarkerAnnotation *)markerView.marker;
339
407
 
@@ -346,6 +414,12 @@ using namespace luggmaps::events;
346
414
  annotation.title = markerView.title;
347
415
  annotation.subtitle = markerView.markerDescription;
348
416
 
417
+ MKAnnotationView *annotationView = annotation.annotationView;
418
+ if (annotationView) {
419
+ annotationView.layer.zPosition = markerView.zIndex;
420
+ annotationView.zPriority = markerView.zIndex;
421
+ }
422
+
349
423
  [self updateAnnotationViewFrame:annotation];
350
424
  }
351
425
 
@@ -367,27 +441,19 @@ using namespace luggmaps::events;
367
441
  }
368
442
 
369
443
  - (void)mapViewDidChangeVisibleRegion:(MKMapView *)mapView {
370
- if (_eventEmitter) {
371
- auto emitter =
372
- std::static_pointer_cast<LuggMapsAppleMapViewEventEmitter const>(
373
- _eventEmitter);
374
- CameraMoveEvent{mapView.centerCoordinate.latitude,
375
- mapView.centerCoordinate.longitude, mapView.zoomLevel,
376
- _isDragging}
377
- .emit(emitter);
378
- }
444
+ CameraMoveEvent{mapView.centerCoordinate.latitude,
445
+ mapView.centerCoordinate.longitude, mapView.zoomLevel,
446
+ _isDragging}
447
+ .emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
379
448
  }
380
449
 
381
450
  - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
451
+ BOOL wasDragging = _isDragging;
382
452
  _isDragging = NO;
383
- if (_eventEmitter) {
384
- auto emitter =
385
- std::static_pointer_cast<LuggMapsAppleMapViewEventEmitter const>(
386
- _eventEmitter);
387
- CameraIdleEvent{mapView.centerCoordinate.latitude,
388
- mapView.centerCoordinate.longitude, mapView.zoomLevel}
389
- .emit(emitter);
390
- }
453
+ CameraIdleEvent{mapView.centerCoordinate.latitude,
454
+ mapView.centerCoordinate.longitude, mapView.zoomLevel,
455
+ static_cast<bool>(wasDragging)}
456
+ .emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
391
457
  }
392
458
 
393
459
  - (MKAnnotationView *)mapView:(MKMapView *)mapView
@@ -397,7 +463,7 @@ using namespace luggmaps::events;
397
463
  }
398
464
 
399
465
  AppleMarkerAnnotation *markerAnnotation = (AppleMarkerAnnotation *)annotation;
400
- LuggMapsMarkerView *markerView = markerAnnotation.markerView;
466
+ LuggMarkerView *markerView = markerAnnotation.markerView;
401
467
 
402
468
  if (!markerView || !markerView.hasCustomView) {
403
469
  return nil;
@@ -408,7 +474,8 @@ using namespace luggmaps::events;
408
474
  reuseIdentifier:nil];
409
475
  annotationView.canShowCallout = YES;
410
476
  annotationView.displayPriority = MKFeatureDisplayPriorityRequired;
411
- annotationView.collisionMode = MKAnnotationViewCollisionModeNone;
477
+ annotationView.layer.zPosition = markerView.zIndex;
478
+ annotationView.zPriority = markerView.zIndex;
412
479
 
413
480
  UIView *iconView = markerView.iconView;
414
481
  [iconView removeFromSuperview];
@@ -435,8 +502,7 @@ using namespace luggmaps::events;
435
502
  - (MKOverlayRenderer *)mapView:(MKMapView *)mapView
436
503
  rendererForOverlay:(id<MKOverlay>)overlay {
437
504
  if ([overlay isKindOfClass:[MKPolyline class]]) {
438
- LuggMapsPolylineView *polylineView =
439
- [self findPolylineViewForOverlay:overlay];
505
+ LuggPolylineView *polylineView = [self findPolylineViewForOverlay:overlay];
440
506
  MKPolyline *polyline = (MKPolyline *)overlay;
441
507
 
442
508
  if (polylineView) {
@@ -494,7 +560,10 @@ using namespace luggmaps::events;
494
560
  }
495
561
 
496
562
  - (void)fitCoordinates:(NSArray *)coordinates
497
- padding:(double)padding
563
+ paddingTop:(double)paddingTop
564
+ paddingLeft:(double)paddingLeft
565
+ paddingBottom:(double)paddingBottom
566
+ paddingRight:(double)paddingRight
498
567
  duration:(double)duration {
499
568
  if (!_mapView || coordinates.count == 0) {
500
569
  return;
@@ -517,7 +586,7 @@ using namespace luggmaps::events;
517
586
  free(coords);
518
587
 
519
588
  UIEdgeInsets edgePadding =
520
- UIEdgeInsetsMake(padding, padding, padding, padding);
589
+ UIEdgeInsetsMake(paddingTop, paddingLeft, paddingBottom, paddingRight);
521
590
 
522
591
  if (duration < 0) {
523
592
  [_mapView setVisibleMapRect:mapRect edgePadding:edgePadding animated:YES];
@@ -534,11 +603,11 @@ using namespace luggmaps::events;
534
603
  }
535
604
 
536
605
  - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
537
- RCTLuggMapsAppleMapViewHandleCommand(self, commandName, args);
606
+ RCTLuggAppleMapViewHandleCommand(self, commandName, args);
538
607
  }
539
608
 
540
- Class<RCTComponentViewProtocol> LuggMapsAppleMapViewCls(void) {
541
- return LuggMapsAppleMapView.class;
609
+ Class<RCTComponentViewProtocol> LuggAppleMapViewCls(void) {
610
+ return LuggAppleMapView.class;
542
611
  }
543
612
 
544
613
  @end
@@ -4,7 +4,7 @@
4
4
 
5
5
  NS_ASSUME_NONNULL_BEGIN
6
6
 
7
- @interface LuggMapsGoogleMapView : RCTViewComponentView
7
+ @interface LuggGoogleMapView : RCTViewComponentView
8
8
 
9
9
  @property(nonatomic, readonly, nullable) GMSMapView *mapView;
10
10