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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt} +81 -28
  2. package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapViewManager.kt → LuggGoogleMapViewManager.kt} +57 -38
  3. package/android/src/main/java/com/luggmaps/{LuggMapsWrapperView.kt → LuggMapWrapperView.kt} +1 -1
  4. package/android/src/main/java/com/luggmaps/LuggMapWrapperViewManager.kt +25 -0
  5. package/android/src/main/java/com/luggmaps/{LuggMapsMarkerView.kt → LuggMarkerView.kt} +6 -6
  6. package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt} +17 -17
  7. package/android/src/main/java/com/luggmaps/{LuggMapsPackage.kt → LuggPackage.kt} +2 -2
  8. package/android/src/main/java/com/luggmaps/{LuggMapsPolylineView.kt → LuggPolylineView.kt} +4 -4
  9. package/android/src/main/java/com/luggmaps/{LuggMapsPolylineViewManager.kt → LuggPolylineViewManager.kt} +16 -16
  10. package/android/src/main/java/com/luggmaps/events/CameraIdleEvent.kt +10 -2
  11. package/android/src/main/java/com/luggmaps/events/CameraMoveEvent.kt +6 -5
  12. package/android/src/main/java/com/luggmaps/events/ReadyEvent.kt +12 -0
  13. package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +14 -0
  14. package/ios/{LuggMapsAppleMapView.h → LuggAppleMapView.h} +2 -2
  15. package/ios/{LuggMapsAppleMapView.mm → LuggAppleMapView.mm} +95 -66
  16. package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
  17. package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +64 -58
  18. package/ios/{LuggMapsWrapperView.h → LuggMapWrapperView.h} +1 -1
  19. package/ios/{LuggMapsWrapperView.mm → LuggMapWrapperView.mm} +7 -7
  20. package/ios/{LuggMapsMarkerView.h → LuggMarkerView.h} +6 -6
  21. package/ios/{LuggMapsMarkerView.mm → LuggMarkerView.mm} +8 -8
  22. package/ios/{LuggMapsPolylineView.h → LuggPolylineView.h} +5 -5
  23. package/ios/{LuggMapsPolylineView.mm → LuggPolylineView.mm} +8 -8
  24. package/ios/events/CameraIdleEvent.h +6 -1
  25. package/ios/events/CameraMoveEvent.h +6 -3
  26. package/ios/events/ReadyEvent.h +20 -0
  27. package/lib/module/MapView.js +13 -5
  28. package/lib/module/MapView.js.map +1 -1
  29. package/lib/module/{Marker.js → components/Marker.js} +2 -2
  30. package/lib/module/components/Marker.js.map +1 -0
  31. package/lib/module/{Polyline.js → components/Polyline.js} +2 -2
  32. package/lib/module/components/Polyline.js.map +1 -0
  33. package/lib/module/components/index.js +5 -0
  34. package/lib/module/components/index.js.map +1 -0
  35. package/{src/fabric/LuggMapsAppleMapViewNativeComponent.ts → lib/module/fabric/LuggAppleMapViewNativeComponent.ts} +9 -2
  36. package/lib/module/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +9 -2
  37. package/{src/fabric/LuggMapsWrapperViewNativeComponent.ts → lib/module/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
  38. package/lib/module/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
  39. package/{src/fabric/LuggMapsPolylineViewNativeComponent.ts → lib/module/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
  40. package/lib/module/index.js +1 -2
  41. package/lib/module/index.js.map +1 -1
  42. package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts +6 -0
  43. package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts.map +1 -0
  44. package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts +6 -0
  45. package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts.map +1 -0
  46. package/lib/typescript/src/MapView.d.ts.map +1 -1
  47. package/lib/typescript/src/MapView.types.d.ts +23 -12
  48. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  49. package/lib/typescript/src/{Marker.types.d.ts → components/Marker.d.ts} +6 -5
  50. package/lib/typescript/src/components/Marker.d.ts.map +1 -0
  51. package/lib/typescript/src/{Polyline.types.d.ts → components/Polyline.d.ts} +6 -5
  52. package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
  53. package/lib/typescript/src/components/index.d.ts +3 -0
  54. package/lib/typescript/src/components/index.d.ts.map +1 -0
  55. package/lib/typescript/src/fabric/{LuggMapsAppleMapViewNativeComponent.d.ts → LuggAppleMapViewNativeComponent.d.ts} +9 -2
  56. package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -0
  57. package/lib/typescript/src/fabric/{LuggMapsGoogleMapViewNativeComponent.d.ts → LuggGoogleMapViewNativeComponent.d.ts} +9 -2
  58. package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +1 -0
  59. package/lib/typescript/src/fabric/{LuggMapsWrapperViewNativeComponent.d.ts → LuggMapWrapperViewNativeComponent.d.ts} +1 -1
  60. package/lib/typescript/src/fabric/LuggMapWrapperViewNativeComponent.d.ts.map +1 -0
  61. package/lib/typescript/src/fabric/{LuggMapsMarkerViewNativeComponent.d.ts → LuggMarkerViewNativeComponent.d.ts} +1 -1
  62. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -0
  63. package/lib/typescript/src/fabric/{LuggMapsPolylineViewNativeComponent.d.ts → LuggPolylineViewNativeComponent.d.ts} +1 -1
  64. package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -0
  65. package/lib/typescript/src/index.d.ts +2 -5
  66. package/lib/typescript/src/index.d.ts.map +1 -1
  67. package/package.json +6 -6
  68. package/plugin/build/index.js +4 -4
  69. package/{lib/typescript/plugin/src/withMapsAndroid.d.ts → plugin/build/withLuggMapsAndroid.d.ts} +0 -1
  70. package/plugin/build/withLuggMapsAndroid.js +15 -0
  71. package/{lib/typescript/plugin/src/withMapsIOS.d.ts → plugin/build/withLuggMapsIOS.d.ts} +0 -1
  72. package/plugin/build/withLuggMapsIOS.js +27 -0
  73. package/plugin/build/withMapsAndroid.d.ts +1 -1
  74. package/plugin/build/withMapsIOS.d.ts +1 -1
  75. package/src/MapView.tsx +16 -8
  76. package/src/MapView.types.ts +23 -13
  77. package/src/components/Marker.tsx +59 -0
  78. package/src/{Polyline.tsx → components/Polyline.tsx} +23 -3
  79. package/src/components/index.ts +2 -0
  80. package/{lib/module/fabric/LuggMapsAppleMapViewNativeComponent.ts → src/fabric/LuggAppleMapViewNativeComponent.ts} +9 -2
  81. package/src/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +9 -2
  82. package/{lib/module/fabric/LuggMapsWrapperViewNativeComponent.ts → src/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
  83. package/src/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
  84. package/{lib/module/fabric/LuggMapsPolylineViewNativeComponent.ts → src/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
  85. package/src/index.ts +3 -6
  86. package/android/src/main/java/com/luggmaps/LuggMapsWrapperViewManager.kt +0 -25
  87. package/lib/module/Marker.js.map +0 -1
  88. package/lib/module/Marker.types.js +0 -4
  89. package/lib/module/Marker.types.js.map +0 -1
  90. package/lib/module/Polyline.js.map +0 -1
  91. package/lib/module/Polyline.types.js +0 -4
  92. package/lib/module/Polyline.types.js.map +0 -1
  93. package/lib/typescript/plugin/src/withMapsAndroid.d.ts.map +0 -1
  94. package/lib/typescript/plugin/src/withMapsIOS.d.ts.map +0 -1
  95. package/lib/typescript/src/Marker.d.ts +0 -6
  96. package/lib/typescript/src/Marker.d.ts.map +0 -1
  97. package/lib/typescript/src/Marker.types.d.ts.map +0 -1
  98. package/lib/typescript/src/Polyline.d.ts +0 -6
  99. package/lib/typescript/src/Polyline.d.ts.map +0 -1
  100. package/lib/typescript/src/Polyline.types.d.ts.map +0 -1
  101. package/lib/typescript/src/fabric/LuggMapsAppleMapViewNativeComponent.d.ts.map +0 -1
  102. package/lib/typescript/src/fabric/LuggMapsGoogleMapViewNativeComponent.d.ts.map +0 -1
  103. package/lib/typescript/src/fabric/LuggMapsMarkerViewNativeComponent.d.ts.map +0 -1
  104. package/lib/typescript/src/fabric/LuggMapsPolylineViewNativeComponent.d.ts.map +0 -1
  105. package/lib/typescript/src/fabric/LuggMapsWrapperViewNativeComponent.d.ts.map +0 -1
  106. package/src/Marker.tsx +0 -31
  107. package/src/Marker.types.ts +0 -32
  108. package/src/Polyline.types.ts +0 -24
@@ -6,32 +6,32 @@ import com.facebook.react.uimanager.ThemedReactContext
6
6
  import com.facebook.react.uimanager.ViewGroupManager
7
7
  import com.facebook.react.uimanager.ViewManagerDelegate
8
8
  import com.facebook.react.uimanager.annotations.ReactProp
9
- import com.facebook.react.viewmanagers.LuggMapsPolylineViewManagerDelegate
10
- import com.facebook.react.viewmanagers.LuggMapsPolylineViewManagerInterface
9
+ import com.facebook.react.viewmanagers.LuggPolylineViewManagerDelegate
10
+ import com.facebook.react.viewmanagers.LuggPolylineViewManagerInterface
11
11
  import com.google.android.gms.maps.model.LatLng
12
12
 
13
- @ReactModule(name = LuggMapsPolylineViewManager.NAME)
14
- class LuggMapsPolylineViewManager :
15
- ViewGroupManager<LuggMapsPolylineView>(),
16
- LuggMapsPolylineViewManagerInterface<LuggMapsPolylineView> {
17
- private val delegate: ViewManagerDelegate<LuggMapsPolylineView> = LuggMapsPolylineViewManagerDelegate(this)
13
+ @ReactModule(name = LuggPolylineViewManager.NAME)
14
+ class LuggPolylineViewManager :
15
+ ViewGroupManager<LuggPolylineView>(),
16
+ LuggPolylineViewManagerInterface<LuggPolylineView> {
17
+ private val delegate: ViewManagerDelegate<LuggPolylineView> = LuggPolylineViewManagerDelegate(this)
18
18
 
19
- override fun getDelegate(): ViewManagerDelegate<LuggMapsPolylineView> = delegate
19
+ override fun getDelegate(): ViewManagerDelegate<LuggPolylineView> = delegate
20
20
  override fun getName(): String = NAME
21
- override fun createViewInstance(context: ThemedReactContext): LuggMapsPolylineView = LuggMapsPolylineView(context)
21
+ override fun createViewInstance(context: ThemedReactContext): LuggPolylineView = LuggPolylineView(context)
22
22
 
23
- override fun onDropViewInstance(view: LuggMapsPolylineView) {
23
+ override fun onDropViewInstance(view: LuggPolylineView) {
24
24
  super.onDropViewInstance(view)
25
25
  view.onDropViewInstance()
26
26
  }
27
27
 
28
- override fun onAfterUpdateTransaction(view: LuggMapsPolylineView) {
28
+ override fun onAfterUpdateTransaction(view: LuggPolylineView) {
29
29
  super.onAfterUpdateTransaction(view)
30
30
  view.onAfterUpdateTransaction()
31
31
  }
32
32
 
33
33
  @ReactProp(name = "coordinates")
34
- override fun setCoordinates(view: LuggMapsPolylineView, value: ReadableArray?) {
34
+ override fun setCoordinates(view: LuggPolylineView, value: ReadableArray?) {
35
35
  value?.let { array ->
36
36
  val coords = mutableListOf<LatLng>()
37
37
  for (i in 0 until array.size()) {
@@ -45,7 +45,7 @@ class LuggMapsPolylineViewManager :
45
45
  }
46
46
 
47
47
  @ReactProp(name = "strokeColors")
48
- override fun setStrokeColors(view: LuggMapsPolylineView, value: ReadableArray?) {
48
+ override fun setStrokeColors(view: LuggPolylineView, value: ReadableArray?) {
49
49
  val colors = mutableListOf<Int>()
50
50
  value?.let { array ->
51
51
  for (i in 0 until array.size()) {
@@ -56,16 +56,16 @@ class LuggMapsPolylineViewManager :
56
56
  }
57
57
 
58
58
  @ReactProp(name = "strokeWidth", defaultDouble = 1.0)
59
- override fun setStrokeWidth(view: LuggMapsPolylineView, value: Double) {
59
+ override fun setStrokeWidth(view: LuggPolylineView, value: Double) {
60
60
  view.setStrokeWidth(value.toFloat())
61
61
  }
62
62
 
63
63
  @ReactProp(name = "animated", defaultBoolean = false)
64
- override fun setAnimated(view: LuggMapsPolylineView, value: Boolean) {
64
+ override fun setAnimated(view: LuggPolylineView, value: Boolean) {
65
65
  view.setAnimated(value)
66
66
  }
67
67
 
68
68
  companion object {
69
- const val NAME = "LuggMapsPolylineView"
69
+ const val NAME = "LuggPolylineView"
70
70
  }
71
71
  }
@@ -1,10 +1,17 @@
1
1
  package com.luggmaps.events
2
2
 
3
+ import android.view.View
3
4
  import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.uimanager.UIManagerHelper
4
6
  import com.facebook.react.uimanager.events.Event
5
7
 
6
- class CameraIdleEvent(surfaceId: Int, viewId: Int, private val latitude: Double, private val longitude: Double, private val zoom: Float) :
7
- Event<CameraIdleEvent>(surfaceId, viewId) {
8
+ class CameraIdleEvent(
9
+ view: View,
10
+ private val latitude: Double,
11
+ private val longitude: Double,
12
+ private val zoom: Float,
13
+ private val gesture: Boolean
14
+ ) : Event<CameraIdleEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
8
15
  override fun getEventName() = "topCameraIdle"
9
16
 
10
17
  override fun getEventData() =
@@ -17,5 +24,6 @@ class CameraIdleEvent(surfaceId: Int, viewId: Int, private val latitude: Double,
17
24
  }
18
25
  )
19
26
  putDouble("zoom", zoom.toDouble())
27
+ putBoolean("gesture", gesture)
20
28
  }
21
29
  }
@@ -1,16 +1,17 @@
1
1
  package com.luggmaps.events
2
2
 
3
+ import android.view.View
3
4
  import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.uimanager.UIManagerHelper
4
6
  import com.facebook.react.uimanager.events.Event
5
7
 
6
8
  class CameraMoveEvent(
7
- surfaceId: Int,
8
- viewId: Int,
9
+ view: View,
9
10
  private val latitude: Double,
10
11
  private val longitude: Double,
11
12
  private val zoom: Float,
12
- private val dragging: Boolean
13
- ) : Event<CameraMoveEvent>(surfaceId, viewId) {
13
+ private val gesture: Boolean
14
+ ) : Event<CameraMoveEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
14
15
  override fun getEventName() = "topCameraMove"
15
16
 
16
17
  override fun getEventData() =
@@ -23,6 +24,6 @@ class CameraMoveEvent(
23
24
  }
24
25
  )
25
26
  putDouble("zoom", zoom.toDouble())
26
- putBoolean("dragging", dragging)
27
+ putBoolean("gesture", gesture)
27
28
  }
28
29
  }
@@ -0,0 +1,12 @@
1
+ package com.luggmaps.events
2
+
3
+ import android.view.View
4
+ import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.uimanager.UIManagerHelper
6
+ import com.facebook.react.uimanager.events.Event
7
+
8
+ class ReadyEvent(view: View) : Event<ReadyEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
9
+ override fun getEventName() = "topReady"
10
+
11
+ override fun getEventData() = Arguments.createMap()
12
+ }
@@ -0,0 +1,14 @@
1
+ package com.luggmaps.extensions
2
+
3
+ import android.view.View
4
+ import com.facebook.react.uimanager.ThemedReactContext
5
+ import com.facebook.react.uimanager.UIManagerHelper
6
+ import com.facebook.react.uimanager.events.Event
7
+
8
+ fun View.dispatchEvent(event: Event<*>) {
9
+ val eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(
10
+ context as ThemedReactContext,
11
+ id
12
+ )
13
+ eventDispatcher?.dispatchEvent(event)
14
+ }
@@ -4,10 +4,10 @@
4
4
 
5
5
  NS_ASSUME_NONNULL_BEGIN
6
6
 
7
- @interface LuggMapsAppleMapViewContent : MKMapView
7
+ @interface LuggAppleMapViewContent : MKMapView
8
8
  @end
9
9
 
10
- @interface LuggMapsAppleMapView : RCTViewComponentView
10
+ @interface LuggAppleMapView : RCTViewComponentView
11
11
 
12
12
  - (MKMapView *)mapView;
13
13
 
@@ -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,11 @@ 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];
155
163
 
156
164
  [_mapWrapperView addSubview:_mapView];
157
165
 
@@ -162,18 +170,22 @@ using namespace luggmaps::events;
162
170
 
163
171
  // Add annotations for any markers that were mounted before map was ready
164
172
  for (UIView *subview in self.subviews) {
165
- if ([subview isKindOfClass:[LuggMapsMarkerView class]]) {
166
- LuggMapsMarkerView *markerView = (LuggMapsMarkerView *)subview;
173
+ if ([subview isKindOfClass:[LuggMarkerView class]]) {
174
+ LuggMarkerView *markerView = (LuggMarkerView *)subview;
167
175
  AppleMarkerAnnotation *annotation =
168
176
  (AppleMarkerAnnotation *)markerView.marker;
169
177
  if (annotation) {
170
178
  [_mapView addAnnotation:annotation];
171
179
  }
172
- } else if ([subview isKindOfClass:[LuggMapsPolylineView class]]) {
173
- LuggMapsPolylineView *polylineView = (LuggMapsPolylineView *)subview;
180
+ } else if ([subview isKindOfClass:[LuggPolylineView class]]) {
181
+ LuggPolylineView *polylineView = (LuggPolylineView *)subview;
174
182
  [self addPolylineViewToMap:polylineView];
175
183
  }
176
184
  }
185
+
186
+ _isMapReady = YES;
187
+
188
+ ReadyEvent::emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
177
189
  }
178
190
 
179
191
  - (void)setCameraWithLatitude:(double)latitude
@@ -185,6 +197,27 @@ using namespace luggmaps::events;
185
197
  [_mapView setCenterCoordinate:center zoomLevel:zoom animated:animated];
186
198
  }
187
199
 
200
+ - (CLLocationDistance)cameraDistanceForZoomLevel:(double)zoomLevel {
201
+ // Approximate conversion: at zoom 0, altitude ~128M km
202
+ // Each zoom level halves the altitude
203
+ return 128000000.0 / pow(2, zoomLevel);
204
+ }
205
+
206
+ - (void)applyZoomRange {
207
+ if (!_mapView)
208
+ return;
209
+
210
+ CLLocationDistance minDistance =
211
+ _maxZoom > 0 ? [self cameraDistanceForZoomLevel:_maxZoom] : 0;
212
+ CLLocationDistance maxDistance =
213
+ _minZoom > 0 ? [self cameraDistanceForZoomLevel:_minZoom] : -1;
214
+
215
+ MKMapCameraZoomRange *zoomRange = [[MKMapCameraZoomRange alloc]
216
+ initWithMinCenterCoordinateDistance:minDistance
217
+ maxCenterCoordinateDistance:maxDistance];
218
+ _mapView.cameraZoomRange = zoomRange;
219
+ }
220
+
188
221
  - (MKMapView *)mapView {
189
222
  return _mapView;
190
223
  }
@@ -194,16 +227,21 @@ using namespace luggmaps::events;
194
227
  - (void)updateProps:(Props::Shared const &)props
195
228
  oldProps:(Props::Shared const &)oldProps {
196
229
  const auto &newViewProps =
197
- *std::static_pointer_cast<LuggMapsAppleMapViewProps const>(props);
230
+ *std::static_pointer_cast<LuggAppleMapViewProps const>(props);
198
231
 
199
232
  if (_mapView) {
200
233
  _mapView.zoomEnabled = newViewProps.zoomEnabled;
201
234
  _mapView.scrollEnabled = newViewProps.scrollEnabled;
202
235
  _mapView.rotateEnabled = newViewProps.rotateEnabled;
203
236
  _mapView.pitchEnabled = newViewProps.pitchEnabled;
237
+ _mapView.showsUserLocation = newViewProps.userLocationEnabled;
204
238
  _mapView.layoutMargins = UIEdgeInsetsMake(
205
239
  newViewProps.padding.top, newViewProps.padding.left,
206
240
  newViewProps.padding.bottom, newViewProps.padding.right);
241
+
242
+ _minZoom = newViewProps.minZoom;
243
+ _maxZoom = newViewProps.maxZoom;
244
+ [self applyZoomRange];
207
245
  }
208
246
 
209
247
  [super updateProps:props oldProps:oldProps];
@@ -213,7 +251,7 @@ using namespace luggmaps::events;
213
251
 
214
252
  - (void)updateAnnotationViewFrame:(AppleMarkerAnnotation *)annotation {
215
253
  MKAnnotationView *annotationView = annotation.annotationView;
216
- LuggMapsMarkerView *markerView = annotation.markerView;
254
+ LuggMarkerView *markerView = annotation.markerView;
217
255
 
218
256
  if (!annotationView || !markerView) {
219
257
  return;
@@ -233,13 +271,13 @@ using namespace luggmaps::events;
233
271
 
234
272
  #pragma mark - PolylineViewDelegate
235
273
 
236
- - (void)polylineViewDidUpdate:(LuggMapsPolylineView *)polylineView {
274
+ - (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
237
275
  [self syncPolylineView:polylineView];
238
276
  }
239
277
 
240
278
  #pragma mark - Polyline Management
241
279
 
242
- - (void)addPolylineViewToMap:(LuggMapsPolylineView *)polylineView {
280
+ - (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
243
281
  if (!_mapView) {
244
282
  return;
245
283
  }
@@ -263,7 +301,7 @@ using namespace luggmaps::events;
263
301
  [_mapView addOverlay:polyline];
264
302
  }
265
303
 
266
- - (void)syncPolylineView:(LuggMapsPolylineView *)polylineView {
304
+ - (void)syncPolylineView:(LuggPolylineView *)polylineView {
267
305
  if (!_mapView) {
268
306
  return;
269
307
  }
@@ -311,10 +349,10 @@ using namespace luggmaps::events;
311
349
  [_mapView addOverlay:newPolyline];
312
350
  }
313
351
 
314
- - (LuggMapsPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
352
+ - (LuggPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
315
353
  for (UIView *subview in self.subviews) {
316
- if ([subview isKindOfClass:[LuggMapsPolylineView class]]) {
317
- LuggMapsPolylineView *polylineView = (LuggMapsPolylineView *)subview;
354
+ if ([subview isKindOfClass:[LuggPolylineView class]]) {
355
+ LuggPolylineView *polylineView = (LuggPolylineView *)subview;
318
356
  if (polylineView.polyline == overlay) {
319
357
  return polylineView;
320
358
  }
@@ -325,7 +363,7 @@ using namespace luggmaps::events;
325
363
 
326
364
  #pragma mark - MarkerViewDelegate
327
365
 
328
- - (void)markerViewDidLayout:(LuggMapsMarkerView *)markerView {
366
+ - (void)markerViewDidLayout:(LuggMarkerView *)markerView {
329
367
  AppleMarkerAnnotation *annotation =
330
368
  (AppleMarkerAnnotation *)markerView.marker;
331
369
  if (annotation) {
@@ -333,7 +371,7 @@ using namespace luggmaps::events;
333
371
  }
334
372
  }
335
373
 
336
- - (void)markerViewDidUpdate:(LuggMapsMarkerView *)markerView {
374
+ - (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
337
375
  AppleMarkerAnnotation *annotation =
338
376
  (AppleMarkerAnnotation *)markerView.marker;
339
377
 
@@ -367,27 +405,19 @@ using namespace luggmaps::events;
367
405
  }
368
406
 
369
407
  - (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
- }
408
+ CameraMoveEvent{mapView.centerCoordinate.latitude,
409
+ mapView.centerCoordinate.longitude, mapView.zoomLevel,
410
+ _isDragging}
411
+ .emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
379
412
  }
380
413
 
381
414
  - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
415
+ BOOL wasDragging = _isDragging;
382
416
  _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
- }
417
+ CameraIdleEvent{mapView.centerCoordinate.latitude,
418
+ mapView.centerCoordinate.longitude, mapView.zoomLevel,
419
+ static_cast<bool>(wasDragging)}
420
+ .emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
391
421
  }
392
422
 
393
423
  - (MKAnnotationView *)mapView:(MKMapView *)mapView
@@ -397,7 +427,7 @@ using namespace luggmaps::events;
397
427
  }
398
428
 
399
429
  AppleMarkerAnnotation *markerAnnotation = (AppleMarkerAnnotation *)annotation;
400
- LuggMapsMarkerView *markerView = markerAnnotation.markerView;
430
+ LuggMarkerView *markerView = markerAnnotation.markerView;
401
431
 
402
432
  if (!markerView || !markerView.hasCustomView) {
403
433
  return nil;
@@ -435,8 +465,7 @@ using namespace luggmaps::events;
435
465
  - (MKOverlayRenderer *)mapView:(MKMapView *)mapView
436
466
  rendererForOverlay:(id<MKOverlay>)overlay {
437
467
  if ([overlay isKindOfClass:[MKPolyline class]]) {
438
- LuggMapsPolylineView *polylineView =
439
- [self findPolylineViewForOverlay:overlay];
468
+ LuggPolylineView *polylineView = [self findPolylineViewForOverlay:overlay];
440
469
  MKPolyline *polyline = (MKPolyline *)overlay;
441
470
 
442
471
  if (polylineView) {
@@ -534,11 +563,11 @@ using namespace luggmaps::events;
534
563
  }
535
564
 
536
565
  - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
537
- RCTLuggMapsAppleMapViewHandleCommand(self, commandName, args);
566
+ RCTLuggAppleMapViewHandleCommand(self, commandName, args);
538
567
  }
539
568
 
540
- Class<RCTComponentViewProtocol> LuggMapsAppleMapViewCls(void) {
541
- return LuggMapsAppleMapView.class;
569
+ Class<RCTComponentViewProtocol> LuggAppleMapViewCls(void) {
570
+ return LuggAppleMapView.class;
542
571
  }
543
572
 
544
573
  @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