react-native-maps 1.21.0-alpha.7 → 1.21.0-alpha.71

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 (148) hide show
  1. package/android/build.gradle +38 -13
  2. package/android/generated/RCTAppDependencyProvider.h +25 -0
  3. package/android/generated/RCTAppDependencyProvider.mm +55 -0
  4. package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  5. package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  6. package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
  7. package/android/generated/RCTThirdPartyComponentsProvider.mm +26 -0
  8. package/android/generated/ReactAppDependencyProvider.podspec +34 -0
  9. package/android/generated/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
  10. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerDelegate.java +35 -0
  11. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerInterface.java +17 -0
  12. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +200 -0
  13. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +71 -0
  14. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
  15. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
  16. package/android/generated/jni/CMakeLists.txt +36 -0
  17. package/android/generated/jni/RNMapsSpecs-generated.cpp +68 -0
  18. package/android/generated/jni/RNMapsSpecs.h +31 -0
  19. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
  20. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +28 -0
  21. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +918 -0
  22. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +787 -0
  23. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +154 -0
  24. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1058 -0
  25. package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
  26. package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +268 -0
  27. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +21 -0
  28. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +76 -0
  29. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
  30. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +77 -0
  31. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  32. package/android/src/main/java/com/rnmaps/fabric/CalloutManager.java +77 -0
  33. package/android/src/main/java/com/rnmaps/fabric/JSONUtil.java +86 -0
  34. package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +593 -0
  35. package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +259 -0
  36. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +156 -4
  37. package/android/src/main/java/com/rnmaps/fabric/event/OnCalloutPressEvent.java +25 -0
  38. package/android/src/main/java/com/rnmaps/fabric/event/OnDeselectEvent.java +28 -0
  39. package/android/src/main/java/com/rnmaps/fabric/event/OnDragEndEvent.java +28 -0
  40. package/android/src/main/java/com/rnmaps/fabric/event/OnDragEvent.java +28 -0
  41. package/android/src/main/java/com/rnmaps/fabric/event/OnDragStartEvent.java +28 -0
  42. package/android/src/main/java/com/rnmaps/fabric/event/OnLongPressEvent.java +28 -0
  43. package/android/src/main/java/com/rnmaps/fabric/event/OnMapLoadedEvent.java +29 -0
  44. package/android/src/main/java/com/rnmaps/fabric/event/OnMapReadyEvent.java +29 -0
  45. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDeselectEvent.java +28 -0
  46. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEndEvent.java +28 -0
  47. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEvent.java +28 -0
  48. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragStartEvent.java +28 -0
  49. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerPressEvent.java +28 -0
  50. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerSelectEvent.java +28 -0
  51. package/android/src/main/java/com/rnmaps/fabric/event/OnPoiClickEvent.java +27 -0
  52. package/android/src/main/java/com/rnmaps/fabric/event/OnPressEvent.java +27 -0
  53. package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeCompleteEvent.java +30 -0
  54. package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +48 -0
  55. package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeStartEvent.java +33 -0
  56. package/android/src/main/java/com/rnmaps/fabric/event/OnSelectEvent.java +28 -0
  57. package/android/src/main/java/com/rnmaps/fabric/event/OnUserLocationChangeEvent.java +28 -0
  58. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +22 -2
  59. package/android/src/main/java/com/rnmaps/maps/MapCallout.java +18 -0
  60. package/android/src/main/java/com/rnmaps/maps/MapManager.java +14 -14
  61. package/android/src/main/java/com/rnmaps/maps/MapMarker.java +79 -3
  62. package/android/src/main/java/com/rnmaps/maps/MapModule.java +206 -206
  63. package/android/src/main/java/com/rnmaps/maps/MapView.java +1618 -1346
  64. package/ios/AirGoogleMaps/AIRGoogleMap.h +3 -2
  65. package/ios/AirGoogleMaps/AIRGoogleMap.m +153 -48
  66. package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
  67. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +17 -28
  68. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  69. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
  70. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +2 -1
  71. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +30 -0
  72. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +0 -1
  73. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +0 -7
  74. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
  75. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  76. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  77. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +2 -0
  78. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +3 -3
  79. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +161 -61
  80. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
  81. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
  82. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
  83. package/ios/AirMaps/AIRMap.h +6 -3
  84. package/ios/AirMaps/AIRMap.m +289 -145
  85. package/ios/AirMaps/AIRMapManager.m +8 -17
  86. package/ios/AirMaps/AIRMapMarker.h +1 -0
  87. package/ios/AirMaps/AIRMapMarker.m +165 -103
  88. package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
  89. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  90. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  91. package/ios/AirMaps/RNMapsAirModule.h +1 -1
  92. package/ios/AirMaps/RNMapsAirModule.mm +42 -172
  93. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  94. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  95. package/ios/AirMaps/RNMapsMapView.h +3 -3
  96. package/ios/AirMaps/RNMapsMapView.mm +344 -307
  97. package/ios/AirMaps/RNMapsMarkerView.h +24 -0
  98. package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
  99. package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
  100. package/ios/AirMaps/UIView +AirMap.m +20 -0
  101. package/ios/AirMaps/UIView+AirMap.h +11 -0
  102. package/ios/AirMaps.xcodeproj/project.pbxproj +60 -0
  103. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  104. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  105. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  106. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  107. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  108. package/ios/generated/RCTThirdPartyComponentsProvider.mm +26 -0
  109. package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
  110. package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +28 -0
  111. package/ios/generated/RNMapsSpecs/EventEmitters.cpp +918 -0
  112. package/ios/generated/RNMapsSpecs/EventEmitters.h +787 -0
  113. package/ios/generated/RNMapsSpecs/Props.cpp +154 -0
  114. package/ios/generated/RNMapsSpecs/Props.h +1058 -0
  115. package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +549 -0
  116. package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
  117. package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
  118. package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +21 -0
  119. package/ios/generated/RNMapsSpecs/ShadowNodes.h +76 -0
  120. package/ios/generated/RNMapsSpecs/States.cpp +16 -0
  121. package/ios/generated/RNMapsSpecs/States.h +77 -0
  122. package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
  123. package/ios/generated/RNMapsSpecsJSI.h +268 -0
  124. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  125. package/lib/MapCallout.js +1 -0
  126. package/lib/MapMarker.d.ts +15 -2
  127. package/lib/MapMarker.js +53 -9
  128. package/lib/MapMarkerNativeComponent.js +0 -2
  129. package/lib/MapOverlay.js +2 -8
  130. package/lib/MapPolyline.d.ts +1 -1
  131. package/lib/MapView.d.ts +7 -22
  132. package/lib/MapView.js +83 -94
  133. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -11
  134. package/lib/createFabricMap.js +175 -0
  135. package/lib/decorateMapComponent.js +22 -0
  136. package/lib/specs/NativeAirMapsModule.d.ts +2 -2
  137. package/lib/specs/NativeComponentCallout.d.ts +46 -0
  138. package/lib/specs/NativeComponentCallout.js +9 -0
  139. package/lib/specs/NativeComponentGoogleMapView.d.ts +12 -12
  140. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  141. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  142. package/lib/specs/NativeComponentMapView.d.ts +19 -36
  143. package/lib/specs/NativeComponentMapView.js +1 -3
  144. package/lib/specs/NativeComponentMarker.d.ts +258 -0
  145. package/lib/specs/NativeComponentMarker.js +19 -0
  146. package/package.json +15 -10
  147. package/react-native-maps.podspec +2 -1
  148. package/lib/FabricMapView.js +0 -181
@@ -350,23 +350,8 @@ RCT_EXPORT_METHOD(fitToCoordinates:(nonnull NSNumber *)reactTag
350
350
  RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
351
351
  } else {
352
352
  AIRMap *mapView = (AIRMap *)view;
353
-
354
- // Create Polyline with coordinates
355
- CLLocationCoordinate2D coords[coordinates.count];
356
- for(int i = 0; i < coordinates.count; i++)
357
- {
358
- coords[i] = coordinates[i].coordinate;
359
- }
360
- MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count];
361
-
362
- // Set Map viewport
363
- CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
364
- CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
365
- CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
366
- CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
367
-
368
- [mapView setVisibleMapRect:[polyline boundingMapRect] edgePadding:UIEdgeInsetsMake(top, left, bottom, right) animated:animated];
369
-
353
+ UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
354
+ [mapView fitToCoordinates: coordinates edgePadding:edgeInsets animated:animated];
370
355
  }
371
356
  }];
372
357
  }
@@ -950,6 +935,9 @@ static int kDragCenterContext;
950
935
  {
951
936
  // Don't send region did change events until map has
952
937
  // started rendering, as these won't represent the final location
938
+ if (animated && mapView.ignoreRegionChanges){
939
+ mapView.ignoreRegionChanges = false;
940
+ }
953
941
  if(mapView.hasStartedRendering){
954
942
  [self _regionChanged:mapView];
955
943
  }
@@ -966,6 +954,8 @@ static int kDragCenterContext;
966
954
 
967
955
  mapView.pendingCenter = mapView.region.center;
968
956
  mapView.pendingSpan = mapView.region.span;
957
+ // reset original state (checkout setCamera / region animated)
958
+ mapView.ignoreRegionChanges = NO;
969
959
  }
970
960
 
971
961
  - (void)mapViewWillStartRenderingMap:(AIRMap *)mapView
@@ -980,6 +970,7 @@ static int kDragCenterContext;
980
970
  - (void)mapViewDidFinishRenderingMap:(AIRMap *)mapView fullyRendered:(BOOL)fullyRendered
981
971
  {
982
972
  [mapView finishLoading];
973
+ mapView.ignoreRegionChanges = NO;
983
974
  }
984
975
 
985
976
  #pragma mark Private
@@ -55,6 +55,7 @@
55
55
  - (void)hideCalloutView;
56
56
  - (void)addTapGestureRecognizer;
57
57
  - (void)setUseLegacyPinView:(BOOL)value;
58
+ - (void)animateToCoordinate:(CLLocationCoordinate2D)newCoordinate duration:(NSTimeInterval)duration;
58
59
 
59
60
  @end
60
61
 
@@ -14,6 +14,8 @@
14
14
  #import <React/RCTImageLoaderProtocol.h>
15
15
  #import <React/RCTUtils.h>
16
16
  #import <React/UIView+React.h>
17
+ #import <React/RCTImageLoader.h>
18
+ #import <React/RCTBridge+Private.h>
17
19
 
18
20
  NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
19
21
 
@@ -28,6 +30,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
28
30
  BOOL _calloutIsOpen;
29
31
  NSInteger _zIndexBeforeOpen;
30
32
  BOOL _useLegacyPinView;
33
+
34
+ CADisplayLink *_displayLink;
35
+ CLLocationCoordinate2D _startCoordinate;
36
+ CLLocationCoordinate2D _endCoordinate;
37
+ NSTimeInterval _animationStartTime;
38
+ NSTimeInterval _animationDuration;
39
+ BOOL _isAnimating;
31
40
  }
32
41
 
33
42
  - (instancetype)initWithFrame:(CGRect)frame {
@@ -43,22 +52,22 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
43
52
  // Make sure we use the image size when available
44
53
  CGSize size = self.image ? self.image.size : frame.size;
45
54
  CGRect bounds = {CGPointZero, size};
46
-
55
+
47
56
  // The MapView is basically in charge of figuring out the center position of the marker view. If the view changed in
48
57
  // height though, we need to compensate in such a way that the bottom of the marker stays at the same spot on the
49
58
  // map.
50
59
  CGFloat dy = (bounds.size.height - self.bounds.size.height) / 2;
51
60
  CGPoint center = (CGPoint){ self.center.x, self.center.y - dy };
52
-
61
+
53
62
  // Avoid crashes due to nan coords
54
63
  if (isnan(center.x) || isnan(center.y) ||
55
- isnan(bounds.origin.x) || isnan(bounds.origin.y) ||
56
- isnan(bounds.size.width) || isnan(bounds.size.height)) {
64
+ isnan(bounds.origin.x) || isnan(bounds.origin.y) ||
65
+ isnan(bounds.size.width) || isnan(bounds.size.height)) {
57
66
  RCTLogError(@"Invalid layout for (%@)%@. position: %@. bounds: %@",
58
- self.reactTag, self, NSStringFromCGPoint(center), NSStringFromCGRect(bounds));
67
+ self.reactTag, self, NSStringFromCGPoint(center), NSStringFromCGRect(bounds));
59
68
  return;
60
69
  }
61
-
70
+
62
71
  self.center = center;
63
72
  self.bounds = bounds;
64
73
  }
@@ -68,6 +77,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
68
77
  self.calloutView = (AIRMapCallout *)subview;
69
78
  } else {
70
79
  [super insertReactSubview:(UIView *)subview atIndex:atIndex];
80
+ [self addSubview:subview];
71
81
  }
72
82
  }
73
83
  - (void) setFrame:(CGRect)frame {
@@ -84,6 +94,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
84
94
  self.calloutView = nil;
85
95
  } else {
86
96
  [super removeReactSubview:(UIView *)subview];
97
+ [(UIView *) subview removeFromSuperview];
87
98
  }
88
99
  }
89
100
 
@@ -91,36 +102,40 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
91
102
  {
92
103
  if ([self shouldUsePinView]) {
93
104
  // In this case, we want to render a platform "default" legacy marker.
94
-
95
-
105
+
106
+
96
107
  if (_pinView == nil && _useLegacyPinView) {
97
108
  _pinView = [[MKPinAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
98
109
  [self addGestureRecognizerToView:_pinView];
99
110
  _pinView.annotation = self;
100
-
111
+
101
112
  if ([_pinView respondsToSelector:@selector(setPinTintColor:)]) {
102
113
  _pinView.pinTintColor = self.pinColor;
103
114
  }
104
-
115
+
105
116
  _pinView.draggable = self.draggable;
106
117
  _pinView.layer.zPosition = self.zIndex;
107
-
118
+ _pinView.displayPriority = self.displayPriority;
119
+ _pinView.zPriority = self.zIndex;
108
120
  return _pinView;
109
121
  }
110
-
111
-
112
-
122
+
123
+
124
+
113
125
  if (_markerView == nil && !_useLegacyPinView) {
114
126
  _markerView = [[MKMarkerAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
115
127
  [self addGestureRecognizerToView:_markerView];
116
128
  _markerView.annotation = self;
117
-
118
- _markerView.draggable = self.draggable;
119
- _markerView.layer.zPosition = self.zIndex;
120
- _markerView.markerTintColor = self.pinColor;
121
- _markerView.titleVisibility = self.titleVisibility ?: MKFeatureVisibilityHidden;
122
- _markerView.subtitleVisibility = self.subtitleVisibility ?: MKFeatureVisibilityHidden;
123
-
129
+
130
+ _markerView.draggable = self.draggable;
131
+ _markerView.layer.zPosition = self.zIndex;
132
+ _markerView.markerTintColor = self.pinColor;
133
+ _markerView.titleVisibility = self.titleVisibility ?: MKFeatureVisibilityHidden;
134
+ _markerView.subtitleVisibility = self.subtitleVisibility ?: MKFeatureVisibilityHidden;
135
+ _markerView.displayPriority = self.displayPriority;
136
+ _markerView.zPriority = self.zIndex;
137
+
138
+
124
139
  }
125
140
  return _markerView ?: _pinView;
126
141
  } else {
@@ -129,6 +144,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
129
144
  // In either case, we want to return the AIRMapMarker since it is both an MKAnnotation and an
130
145
  // MKAnnotationView all at the same time.
131
146
  self.layer.zPosition = self.zIndex;
147
+ self.zPriority = self.zIndex;
132
148
  return self;
133
149
  }
134
150
  }
@@ -136,14 +152,14 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
136
152
  - (void)fillCalloutView:(SMCalloutView *)calloutView
137
153
  {
138
154
  // Set everything necessary on the calloutView before it becomes visible.
139
-
155
+
140
156
  // Apply the MKAnnotationView's desired calloutOffset (from the top-middle of the view)
141
- if ([self shouldUsePinView] && !_hasSetCalloutOffset && _useLegacyPinView) {
157
+ if ([self shouldUsePinView] && !_hasSetCalloutOffset && _useLegacyPinView) {
142
158
  calloutView.calloutOffset = CGPointMake(-8,0);
143
159
  } else {
144
160
  calloutView.calloutOffset = self.calloutOffset;
145
161
  }
146
-
162
+
147
163
  if (self.calloutView) {
148
164
  calloutView.title = nil;
149
165
  calloutView.subtitle = nil;
@@ -156,13 +172,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
156
172
  // as a result, we use the default "masked" background view.
157
173
  calloutView.backgroundView = [SMCalloutMaskedBackgroundView new];
158
174
  }
159
-
175
+
160
176
  // when this is set, the callout's content will be whatever react views the user has put as the callout's
161
177
  // children.
162
178
  calloutView.contentView = self.calloutView;
163
-
179
+
164
180
  } else {
165
-
181
+
166
182
  // if there is no calloutView, it means the user wants to use the default callout behavior with title/subtitle
167
183
  // pairs.
168
184
  calloutView.title = self.title;
@@ -176,37 +192,37 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
176
192
  {
177
193
  _calloutIsOpen = YES;
178
194
  [self setZIndex:_zIndexBeforeOpen];
179
-
195
+
180
196
  MKAnnotationView *annotationView = [self getAnnotationView];
181
-
197
+
182
198
  [self setSelected:YES animated:NO];
183
199
  [self.map selectAnnotation:self animated:NO];
184
-
200
+
185
201
  id event = @{
186
- @"action": @"marker-select",
187
- @"id": self.identifier ?: @"unknown",
188
- @"coordinate": @{
189
- @"latitude": @(self.coordinate.latitude),
190
- @"longitude": @(self.coordinate.longitude)
191
- }
202
+ @"action": @"marker-select",
203
+ @"id": self.identifier ?: @"unknown",
204
+ @"coordinate": @{
205
+ @"latitude": @(self.coordinate.latitude),
206
+ @"longitude": @(self.coordinate.longitude)
207
+ }
192
208
  };
193
-
209
+
194
210
  if (self.map.onMarkerSelect) self.map.onMarkerSelect(event);
195
211
  if (self.onSelect) self.onSelect(event);
196
-
212
+
197
213
  if (![self shouldShowCalloutView]) {
198
214
  // no callout to show
199
215
  return;
200
216
  }
201
-
217
+
202
218
  [self fillCalloutView:self.map.calloutView];
203
-
219
+
204
220
  // This is where we present our custom callout view... MapKit's built-in callout doesn't have the flexibility
205
221
  // we need, but a lot of work was done by Nick Farina to make this identical to MapKit's built-in.
206
222
  [self.map.calloutView presentCalloutFromRect:annotationView.bounds
207
- inView:annotationView
208
- constrainedToView:self.map
209
- animated:YES];
223
+ inView:annotationView
224
+ constrainedToView:self.map
225
+ animated:YES];
210
226
  }
211
227
 
212
228
  #pragma mark - Tap Gesture & Events.
@@ -228,12 +244,12 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
228
244
  - (void)_handleTap:(UITapGestureRecognizer *)recognizer {
229
245
  AIRMapMarker *marker = self;
230
246
  if (!marker) return;
231
-
247
+
232
248
  if (marker.selected) {
233
249
  CGPoint touchPoint = [recognizer locationInView:marker.map.calloutView];
234
250
  CGRect bubbleFrame = [self.calloutView convertRect:marker.map.calloutView.bounds toView:marker.map];
235
251
  CGPoint touchPointReal = [recognizer locationInView:self.calloutView];
236
-
252
+
237
253
  UIView *calloutView = [marker.map.calloutView hitTest:touchPoint withEvent:nil];
238
254
  if (calloutView) {
239
255
  // the callout (or its subview) got clicked, not the marker
@@ -247,22 +263,22 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
247
263
  }
248
264
  tmp = tmp.superview;
249
265
  }
250
-
266
+
251
267
  id event = @{
252
- @"action": calloutSubview ? @"callout-inside-press" : @"callout-press",
253
- @"id": marker.identifier ?: @"unknown",
254
- @"point": @{
255
- @"x": @(touchPointReal.x),
256
- @"y": @(touchPointReal.y),
257
- },
258
- @"frame": @{
259
- @"x": @(bubbleFrame.origin.x),
260
- @"y": @(bubbleFrame.origin.y),
261
- @"width": @(bubbleFrame.size.width),
262
- @"height": @(bubbleFrame.size.height),
263
- }
264
- };
265
-
268
+ @"action": calloutSubview ? @"callout-inside-press" : @"callout-press",
269
+ @"id": marker.identifier ?: @"unknown",
270
+ @"point": @{
271
+ @"x": @(touchPointReal.x),
272
+ @"y": @(touchPointReal.y),
273
+ },
274
+ @"frame": @{
275
+ @"x": @(bubbleFrame.origin.x),
276
+ @"y": @(bubbleFrame.origin.y),
277
+ @"width": @(bubbleFrame.size.width),
278
+ @"height": @(bubbleFrame.size.height),
279
+ }
280
+ };
281
+
266
282
  if (calloutSubview) calloutSubview.onPress(event);
267
283
  if (marker.onCalloutPress) marker.onCalloutPress(event);
268
284
  if (marker.calloutView && marker.calloutView.onPress) marker.calloutView.onPress(event);
@@ -270,25 +286,25 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
270
286
  return;
271
287
  }
272
288
  }
273
-
289
+
274
290
  // the actual marker got clicked
275
291
  CGPoint touchPointReal = [recognizer locationInView:self.calloutView];
276
292
  id event = @{
277
- @"action": @"marker-press",
278
- @"id": marker.identifier ?: @"unknown",
279
- @"coordinate": @{
280
- @"latitude": @(marker.coordinate.latitude),
281
- @"longitude": @(marker.coordinate.longitude)
282
- },
283
- @"position": @{
284
- @"x": @(touchPointReal.x),
285
- @"y": @(touchPointReal.y),
286
- }
287
- };
288
-
293
+ @"action": @"marker-press",
294
+ @"id": marker.identifier ?: @"unknown",
295
+ @"coordinate": @{
296
+ @"latitude": @(marker.coordinate.latitude),
297
+ @"longitude": @(marker.coordinate.longitude)
298
+ },
299
+ @"position": @{
300
+ @"x": @(touchPointReal.x),
301
+ @"y": @(touchPointReal.y),
302
+ }
303
+ };
304
+
289
305
  if (marker.onPress) marker.onPress(event);
290
306
  if (marker.map.onMarkerPress) marker.map.onMarkerPress(event);
291
-
307
+
292
308
  [marker.map selectAnnotation:marker animated:NO];
293
309
  }
294
310
 
@@ -298,19 +314,19 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
298
314
  [self setZIndex:_zIndexBeforeOpen];
299
315
  // hide the callout view
300
316
  [self.map.calloutView dismissCalloutAnimated:YES];
301
-
317
+
302
318
  [self setSelected:NO animated:NO];
303
319
  [self.map deselectAnnotation:self animated:NO];
304
-
320
+
305
321
  id event = @{
306
- @"action": @"marker-deselect",
307
- @"id": self.identifier ?: @"unknown",
308
- @"coordinate": @{
309
- @"latitude": @(self.coordinate.latitude),
310
- @"longitude": @(self.coordinate.longitude)
311
- }
322
+ @"action": @"marker-deselect",
323
+ @"id": self.identifier ?: @"unknown",
324
+ @"coordinate": @{
325
+ @"latitude": @(self.coordinate.latitude),
326
+ @"longitude": @(self.coordinate.longitude)
327
+ }
312
328
  };
313
-
329
+
314
330
  if (self.map.onMarkerDeselect) self.map.onMarkerDeselect(event);
315
331
  if (self.onDeselect) self.onDeselect(event);
316
332
  }
@@ -333,39 +349,42 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
333
349
 
334
350
  - (void)setOpacity:(double)opacity
335
351
  {
336
- [self setAlpha:opacity];
352
+ [self setAlpha:opacity];
337
353
  }
338
354
 
339
355
  - (void)setImageSrc:(NSString *)imageSrc
340
356
  {
341
357
  _imageSrc = imageSrc;
342
-
358
+
343
359
  if (_reloadImageCancellationBlock) {
344
360
  _reloadImageCancellationBlock();
345
361
  _reloadImageCancellationBlock = nil;
346
362
  }
347
- _reloadImageCancellationBlock = [[_bridge moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
348
- size:self.bounds.size
349
- scale:RCTScreenScale()
350
- clipped:YES
351
- resizeMode:RCTResizeModeCenter
352
- progressBlock:nil
353
- partialLoadBlock:nil
354
- completionBlock:^(NSError *error, UIImage *image) {
355
- if (error) {
356
- // TODO(lmr): do something with the error?
357
- NSLog(@"%@", error);
358
- }
359
- dispatch_async(dispatch_get_main_queue(), ^{
360
- self.image = image;
361
- });
362
- }];
363
+ __weak __typeof(self) weakSelf = self;
364
+
365
+ _reloadImageCancellationBlock = [[[RCTBridge currentBridge] moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
366
+ size:self.bounds.size
367
+ scale:RCTScreenScale()
368
+ clipped:YES
369
+ resizeMode:RCTResizeModeCenter
370
+ progressBlock:nil
371
+ partialLoadBlock:nil
372
+ completionBlock:^(NSError *error, UIImage *image) {
373
+ if (error) {
374
+ // TODO(lmr): do something with the error?
375
+ NSLog(@"failed to load image: %@", error);
376
+ }
377
+ dispatch_async(dispatch_get_main_queue(), ^{
378
+ __strong __typeof(weakSelf) strongSelf = weakSelf;
379
+ strongSelf.image = image;
380
+ });
381
+ }];
363
382
  }
364
383
 
365
384
  - (void)setPinColor:(UIColor *)pinColor
366
385
  {
367
386
  _pinColor = pinColor;
368
-
387
+
369
388
  if(_useLegacyPinView && [_pinView respondsToSelector:@selector(setPinTintColor:)]) {
370
389
  _pinView.pinTintColor = _pinColor;
371
390
  } else {
@@ -381,7 +400,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
381
400
  }
382
401
 
383
402
  - (BOOL)isSelected {
384
- return _isPreselected || [super isSelected];
403
+ return _isPreselected || [super isSelected];
385
404
  }
386
405
 
387
406
  - (void)dealloc {
@@ -398,4 +417,47 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
398
417
  _useLegacyPinView = value;
399
418
  }
400
419
 
420
+ - (void)animateToCoordinate:(CLLocationCoordinate2D)newCoordinate duration:(NSTimeInterval)duration {
421
+ if (_isAnimating) {
422
+ NSLog(@"Animation already in progress. Rejecting new animation request.");
423
+ return;
424
+ }
425
+
426
+ // Mark as animating
427
+ _isAnimating = YES;
428
+
429
+ // Store animation parameters
430
+ _startCoordinate = self.coordinate;
431
+ _endCoordinate = newCoordinate;
432
+ _animationDuration = duration;
433
+ _animationStartTime = [NSDate timeIntervalSinceReferenceDate];
434
+
435
+ // Start a CADisplayLink
436
+ if (_displayLink) {
437
+ [_displayLink invalidate];
438
+ }
439
+ _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updatePosition)];
440
+ [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
441
+ }
442
+
443
+ - (void)updatePosition {
444
+ NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _animationStartTime;
445
+ CGFloat progress = MIN(elapsed / _animationDuration, 1.0);
446
+
447
+ // Interpolate coordinates
448
+ CLLocationDegrees currentLatitude = _startCoordinate.latitude + progress * (_endCoordinate.latitude - _startCoordinate.latitude);
449
+ CLLocationDegrees currentLongitude = _startCoordinate.longitude + progress * (_endCoordinate.longitude - _startCoordinate.longitude);
450
+
451
+ // Update annotation's coordinate
452
+ CLLocationCoordinate2D currentCoordinate = CLLocationCoordinate2DMake(currentLatitude, currentLongitude);
453
+ [self setValue:[NSValue valueWithMKCoordinate:currentCoordinate] forKey:@"coordinate"];
454
+
455
+ // Stop the animation when complete
456
+ if (progress == 1.0) {
457
+ [_displayLink invalidate];
458
+ _displayLink = nil;
459
+ _isAnimating = NO; // Reset the animation state
460
+ }
461
+ }
462
+
401
463
  @end
@@ -855,4 +855,4 @@ static UIImage *blackArrowImage = nil, *whiteArrowImage = nil, *grayArrowImage =
855
855
  - (CGFloat)frameBottom { return self.frame.origin.y + self.frame.size.height; }
856
856
  - (void)setFrameBottom:(CGFloat)bottom { self.frame = (CGRect){ .origin=self.frame.origin, .size.width=self.frame.size.width, .size.height=fmaxf(bottom-self.frame.origin.y,0) }; }
857
857
 
858
- @end
858
+ @end
@@ -7,6 +7,8 @@
7
7
  #import <MapKit/MapKit.h>
8
8
  #import <React/RCTConvert.h>
9
9
 
10
+ @class AIRMapCoordinate;
11
+
10
12
  @interface RCTConvert (AirMap)
11
13
 
12
14
  + (MKCoordinateSpan)MKCoordinateSpan:(id)json;
@@ -16,4 +18,6 @@
16
18
  + (MKMapType)MKMapType:(id)json;
17
19
  + (NSDictionary*) dictonaryFromString:(NSString *) str;
18
20
  + (NSArray*) arrayFromString:(NSString *) str;
21
+ + (NSArray<NSArray<AIRMapCoordinate *> *> *)AIRMapCoordinateArrayArray:(id)json;
22
+ + (AIRMapCoordinate*) AIRMapCoordinate:(id)json;
19
23
  @end
@@ -27,6 +27,7 @@
27
27
  };
28
28
  }
29
29
 
30
+
30
31
  + (MKMapCamera*)MKMapCamera:(id)json
31
32
  {
32
33
  json = [self NSDictionary:json];
@@ -49,6 +50,7 @@
49
50
  error:&jsonError];
50
51
  }
51
52
 
53
+
52
54
  + (MKMapCamera*)MKMapCameraWithDefaults:(id)json existingCamera:(MKMapCamera*)camera
53
55
  {
54
56
  json = [self NSDictionary:json];
@@ -3,7 +3,7 @@
3
3
  #ifdef RCT_NEW_ARCH_ENABLED
4
4
 
5
5
  #import <Foundation/Foundation.h>
6
- #import <RNMapsSpecs/RNMapsSpecs.h>
6
+ #import <react-native-maps-generated/RNMapsSpecs.h>
7
7
 
8
8
  NS_ASSUME_NONNULL_BEGIN
9
9