react-native-maps 1.21.0-alpha.140 → 1.21.0-alpha.142

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 (35) hide show
  1. package/README.md +4 -4
  2. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java +1 -2
  3. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java +1 -2
  4. package/android/src/main/java/com/rnmaps/fabric/OverlayManager.java +9 -3
  5. package/android/src/main/java/com/rnmaps/maps/MapOverlay.java +2 -22
  6. package/android/src/main/java/com/rnmaps/maps/MapOverlayManager.java +23 -1
  7. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +45 -11
  8. package/ios/AirGoogleMaps/AIRGoogleMap.h +9 -3
  9. package/ios/AirGoogleMaps/{AIRGoogleMap.m → AIRGoogleMap.mm} +12 -11
  10. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +7 -1
  11. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +4 -1
  12. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +16 -1
  13. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +9 -0
  14. package/ios/AirMaps/AIRMap.h +3 -3
  15. package/ios/AirMaps/{AIRMap.m → AIRMap.mm} +18 -14
  16. package/ios/AirMaps/AIRMapManager.m +1 -12
  17. package/ios/AirMaps/AIRMapOverlay.m +2 -2
  18. package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.h +0 -3
  19. package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.mm +9 -0
  20. package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.mm +8 -0
  21. package/ios/AirMaps/RNMapsAirModule.h +2 -3
  22. package/ios/AirMaps/RNMapsAirModule.mm +14 -0
  23. package/ios/AirMaps/RNMapsDefines.h +1 -1
  24. package/ios/AirMaps/RNMapsMapView.h +4 -1
  25. package/ios/AirMaps/RNMapsMapView.mm +12 -2
  26. package/ios/AirMaps/RNMapsMarkerView.mm +8 -0
  27. package/ios/AirMaps/module.modulemap +6 -0
  28. package/ios/generated/RNMapsAirModuleDelegate.h +1 -1
  29. package/package.json +1 -1
  30. package/react-native-google-maps.podspec +2 -1
  31. package/react-native-maps-generated.podspec +1 -2
  32. package/react-native-maps.podspec +13 -4
  33. package/src/MapOverlay.tsx +26 -4
  34. package/src/specs/NativeComponentOverlay.ts +10 -1
  35. /package/ios/AirMaps/{UIView +AirMap.m → UIView+AirMap.m} +0 -0
package/README.md CHANGED
@@ -18,13 +18,13 @@ See [Setup Instructions for the Included Example Project](docs/examples-setup.md
18
18
 
19
19
  ### Important Notes:
20
20
 
21
- - **Fabric is not yet supported**:
22
- This feature is currently under development. Fabric is enabled by default in React Native `0.76` and above, so **please disable it** for now.
23
- Follow updates on this issue here: [react-native-maps/issues/5206](https://github.com/react-native-maps/react-native-maps/issues/5206).
24
- Kindly refrain from opening duplicate tickets regarding this matter.
21
+ - **Fabric is now supported**:
22
+ Fabric is now supported for the latest version of the library, if you don't have Fabric (New Arch) enabled, please use v1.21.0 or earlier
25
23
 
26
24
  ### Version Requirements:
27
25
 
26
+ - **Version `1.22.0` and below**: Requires **React Native `>= 0.76`**.
27
+ - **Version `1.21.0` and below**: Requires **React Native `>= 0.74`**.
28
28
  - **Version `1.14.0` and above**: Requires **React Native `>= 0.74`**.
29
29
  - **Versions below `1.14.0`**: Require **React Native `>= 0.64.3`**.
30
30
 
@@ -11,7 +11,6 @@ package com.facebook.react.viewmanagers;
11
11
 
12
12
  import android.view.View;
13
13
  import androidx.annotation.Nullable;
14
- import com.facebook.react.bridge.ReadableArray;
15
14
  import com.facebook.react.bridge.ReadableMap;
16
15
  import com.facebook.react.uimanager.BaseViewManager;
17
16
  import com.facebook.react.uimanager.BaseViewManagerDelegate;
@@ -28,7 +27,7 @@ public class RNMapsOverlayManagerDelegate<T extends View, U extends BaseViewMana
28
27
  mViewManager.setBearing(view, value == null ? 0f : ((Double) value).floatValue());
29
28
  break;
30
29
  case "bounds":
31
- mViewManager.setBounds(view, (ReadableArray) value);
30
+ mViewManager.setBounds(view, (ReadableMap) value);
32
31
  break;
33
32
  case "image":
34
33
  mViewManager.setImage(view, (ReadableMap) value);
@@ -11,12 +11,11 @@ package com.facebook.react.viewmanagers;
11
11
 
12
12
  import android.view.View;
13
13
  import androidx.annotation.Nullable;
14
- import com.facebook.react.bridge.ReadableArray;
15
14
  import com.facebook.react.bridge.ReadableMap;
16
15
 
17
16
  public interface RNMapsOverlayManagerInterface<T extends View> {
18
17
  void setBearing(T view, float value);
19
- void setBounds(T view, @Nullable ReadableArray value);
18
+ void setBounds(T view, @Nullable ReadableMap value);
20
19
  void setImage(T view, @Nullable ReadableMap value);
21
20
  void setOpacity(T view, float value);
22
21
  void setTappable(T view, boolean value);
@@ -4,7 +4,6 @@ package com.rnmaps.fabric;
4
4
  import androidx.annotation.Nullable;
5
5
 
6
6
  import com.facebook.react.bridge.ReactApplicationContext;
7
- import com.facebook.react.bridge.ReadableArray;
8
7
  import com.facebook.react.bridge.ReadableMap;
9
8
  import com.facebook.react.module.annotations.ReactModule;
10
9
  import com.facebook.react.uimanager.ThemedReactContext;
@@ -12,6 +11,8 @@ import com.facebook.react.uimanager.ViewGroupManager;
12
11
  import com.facebook.react.uimanager.ViewManagerDelegate;
13
12
  import com.facebook.react.viewmanagers.RNMapsOverlayManagerDelegate;
14
13
  import com.facebook.react.viewmanagers.RNMapsOverlayManagerInterface;
14
+ import com.google.android.gms.maps.model.LatLng;
15
+ import com.google.android.gms.maps.model.LatLngBounds;
15
16
  import com.rnmaps.maps.MapOverlay;
16
17
 
17
18
  import java.util.HashMap;
@@ -70,8 +71,13 @@ public class OverlayManager extends ViewGroupManager<MapOverlay> implements RNMa
70
71
  }
71
72
 
72
73
  @Override
73
- public void setBounds(MapOverlay view, @Nullable ReadableArray value) {
74
- view.setBounds(value);
74
+ public void setBounds(MapOverlay view, @Nullable ReadableMap value) {
75
+ LatLng sw = new LatLng(value.getMap("southWest").getDouble("latitude"),
76
+ value.getMap("southWest").getDouble("longitude"));
77
+ LatLng ne = new LatLng(value.getMap("northEast").getDouble("latitude"),
78
+ value.getMap("northEast").getDouble("longitude"));
79
+ LatLngBounds bounds = new LatLngBounds(sw, ne);
80
+ view.setBounds(bounds);
75
81
  }
76
82
 
77
83
  @Override
@@ -68,29 +68,9 @@ public class MapOverlay extends MapFeature {
68
68
  }
69
69
 
70
70
 
71
- // seems like apple users north west, south east
72
- // google uses north east, south west
73
- private static LatLngBounds fixBoundsIfNecessary(ReadableArray bounds) {
74
- double lat1 = bounds.getArray(0).getDouble(0);
75
- double lon1 = bounds.getArray(0).getDouble(1);
76
- double lat2 = bounds.getArray(1).getDouble(0);
77
- double lon2 = bounds.getArray(1).getDouble(1);
78
-
79
- // Ensure lat1/lon1 is the SW corner and lat2/lon2 is the NE corner
80
- double southLat = Math.min(lat1, lat2);
81
- double northLat = Math.max(lat1, lat2);
82
- double westLon = Math.min(lon1, lon2);
83
- double eastLon = Math.max(lon1, lon2);
84
-
85
- // Create corrected LatLngs
86
- LatLng sw = new LatLng(southLat, westLon);
87
- LatLng ne = new LatLng(northLat, eastLon);
88
- return new LatLngBounds(sw, ne);
89
- }
90
-
91
- public void setBounds(ReadableArray bounds) {
92
71
 
93
- this.bounds = fixBoundsIfNecessary(bounds);
72
+ public void setBounds(LatLngBounds bounds) {
73
+ this.bounds = bounds;
94
74
  if (this.groundOverlay != null) {
95
75
  this.groundOverlay.setPositionFromBounds(this.bounds);
96
76
  }
@@ -12,6 +12,8 @@ import com.facebook.react.common.MapBuilder;
12
12
  import com.facebook.react.uimanager.ThemedReactContext;
13
13
  import com.facebook.react.uimanager.ViewGroupManager;
14
14
  import com.facebook.react.uimanager.annotations.ReactProp;
15
+ import com.google.android.gms.maps.model.LatLng;
16
+ import com.google.android.gms.maps.model.LatLngBounds;
15
17
 
16
18
  import java.util.Map;
17
19
 
@@ -37,7 +39,27 @@ public class MapOverlayManager extends ViewGroupManager<MapOverlay> {
37
39
 
38
40
  @ReactProp(name = "bounds")
39
41
  public void setBounds(MapOverlay view, ReadableArray bounds) {
40
- view.setBounds(bounds);
42
+ view.setBounds(fixBoundsIfNecessary(bounds));
43
+ }
44
+
45
+ // seems like apple users north west, south east
46
+ // google uses north east, south west
47
+ private static LatLngBounds fixBoundsIfNecessary(ReadableArray bounds) {
48
+ double lat1 = bounds.getArray(0).getDouble(0);
49
+ double lon1 = bounds.getArray(0).getDouble(1);
50
+ double lat2 = bounds.getArray(1).getDouble(0);
51
+ double lon2 = bounds.getArray(1).getDouble(1);
52
+
53
+ // Ensure lat1/lon1 is the SW corner and lat2/lon2 is the NE corner
54
+ double southLat = Math.min(lat1, lat2);
55
+ double northLat = Math.max(lat1, lat2);
56
+ double westLon = Math.min(lon1, lon2);
57
+ double eastLon = Math.max(lon1, lon2);
58
+
59
+ // Create corrected LatLngs
60
+ LatLng sw = new LatLng(southLat, westLon);
61
+ LatLng ne = new LatLng(northLat, eastLon);
62
+ return new LatLngBounds(sw, ne);
41
63
  }
42
64
 
43
65
  @ReactProp(name = "bearing")
@@ -1094,12 +1094,12 @@ class RNMapsMarkerProps final : public ViewProps {
1094
1094
  bool useLegacyPinView{false};
1095
1095
  };
1096
1096
 
1097
- struct RNMapsOverlayBoundsStruct {
1097
+ struct RNMapsOverlayBoundsNorthEastStruct {
1098
1098
  double latitude{0.0};
1099
1099
  double longitude{0.0};
1100
1100
  };
1101
1101
 
1102
- static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsStruct &result) {
1102
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsNorthEastStruct &result) {
1103
1103
  auto map = (std::unordered_map<std::string, RawValue>)value;
1104
1104
 
1105
1105
  auto tmp_latitude = map.find("latitude");
@@ -1112,19 +1112,53 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
1112
1112
  }
1113
1113
  }
1114
1114
 
1115
- static inline std::string toString(const RNMapsOverlayBoundsStruct &value) {
1116
- return "[Object RNMapsOverlayBoundsStruct]";
1115
+ static inline std::string toString(const RNMapsOverlayBoundsNorthEastStruct &value) {
1116
+ return "[Object RNMapsOverlayBoundsNorthEastStruct]";
1117
1117
  }
1118
1118
 
1119
- static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector<RNMapsOverlayBoundsStruct> &result) {
1120
- auto items = (std::vector<RawValue>)value;
1121
- for (const auto &item : items) {
1122
- RNMapsOverlayBoundsStruct newItem;
1123
- fromRawValue(context, item, newItem);
1124
- result.emplace_back(newItem);
1119
+ struct RNMapsOverlayBoundsSouthWestStruct {
1120
+ double latitude{0.0};
1121
+ double longitude{0.0};
1122
+ };
1123
+
1124
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsSouthWestStruct &result) {
1125
+ auto map = (std::unordered_map<std::string, RawValue>)value;
1126
+
1127
+ auto tmp_latitude = map.find("latitude");
1128
+ if (tmp_latitude != map.end()) {
1129
+ fromRawValue(context, tmp_latitude->second, result.latitude);
1130
+ }
1131
+ auto tmp_longitude = map.find("longitude");
1132
+ if (tmp_longitude != map.end()) {
1133
+ fromRawValue(context, tmp_longitude->second, result.longitude);
1134
+ }
1135
+ }
1136
+
1137
+ static inline std::string toString(const RNMapsOverlayBoundsSouthWestStruct &value) {
1138
+ return "[Object RNMapsOverlayBoundsSouthWestStruct]";
1139
+ }
1140
+
1141
+ struct RNMapsOverlayBoundsStruct {
1142
+ RNMapsOverlayBoundsNorthEastStruct northEast{};
1143
+ RNMapsOverlayBoundsSouthWestStruct southWest{};
1144
+ };
1145
+
1146
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsStruct &result) {
1147
+ auto map = (std::unordered_map<std::string, RawValue>)value;
1148
+
1149
+ auto tmp_northEast = map.find("northEast");
1150
+ if (tmp_northEast != map.end()) {
1151
+ fromRawValue(context, tmp_northEast->second, result.northEast);
1152
+ }
1153
+ auto tmp_southWest = map.find("southWest");
1154
+ if (tmp_southWest != map.end()) {
1155
+ fromRawValue(context, tmp_southWest->second, result.southWest);
1125
1156
  }
1126
1157
  }
1127
1158
 
1159
+ static inline std::string toString(const RNMapsOverlayBoundsStruct &value) {
1160
+ return "[Object RNMapsOverlayBoundsStruct]";
1161
+ }
1128
1162
  class RNMapsOverlayProps final : public ViewProps {
1129
1163
  public:
1130
1164
  RNMapsOverlayProps() = default;
@@ -1133,7 +1167,7 @@ class RNMapsOverlayProps final : public ViewProps {
1133
1167
  #pragma mark - Props
1134
1168
 
1135
1169
  Float bearing{0.0};
1136
- std::vector<RNMapsOverlayBoundsStruct> bounds{};
1170
+ RNMapsOverlayBoundsStruct bounds{};
1137
1171
  ImageSource image{};
1138
1172
  Float opacity{1.0};
1139
1173
  bool tappable{false};
@@ -13,10 +13,16 @@
13
13
  #import <GoogleMaps/GoogleMaps.h>
14
14
  #import <MapKit/MapKit.h>
15
15
  #import "AIRGMSMarker.h"
16
- #import <react-native-maps-generated/RNMapsAirModuleDelegate.h>
16
+
17
17
  #import "AIRGoogleMapCoordinate.h"
18
18
 
19
- @interface AIRGoogleMap : GMSMapView <RNMapsAirModuleDelegate>
19
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
20
+ #import <ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>
21
+ #else
22
+ #import <react-native-maps-generated/RNMapsAirModuleDelegate.h>
23
+ #endif
24
+
25
+ @interface AIRGoogleMap : GMSMapView<RNMapsAirModuleDelegate>
20
26
 
21
27
  // TODO: don't use MK region?
22
28
  @property (nonatomic, weak) RCTBridge *bridge;
@@ -78,7 +84,7 @@
78
84
  - (void)didChangeCameraPosition:(GMSCameraPosition *)position isGesture:(BOOL)isGesture;
79
85
  - (void)idleAtCameraPosition:(GMSCameraPosition *)position isGesture:(BOOL)isGesture;
80
86
  - (void)didTapPOIWithPlaceID:(NSString *)placeID name:(NSString *) name location:(CLLocationCoordinate2D) location;
81
- - (NSArray *)getMapBoundaries;
87
+ - (NSDictionary *)getMapBoundaries;
82
88
 
83
89
  + (MKCoordinateRegion)makeGMSCameraPositionFromMap:(GMSMapView *)map andGMSCameraPosition:(GMSCameraPosition *)position;
84
90
  + (GMSCameraPosition*)makeGMSCameraPositionFromMap:(GMSMapView *)map andMKCoordinateRegion:(MKCoordinateRegion)region;
@@ -25,6 +25,7 @@
25
25
  #import <React/RCTConvert.h>
26
26
  #import <objc/runtime.h>
27
27
 
28
+
28
29
  #ifdef HAVE_GOOGLE_MAPS_UTILS
29
30
  #import "GMUKMLParser.h"
30
31
  #import "GMUPlacemark.h"
@@ -342,7 +343,7 @@ id regionAsJSON(MKCoordinateRegion region) {
342
343
  }
343
344
  #pragma clang diagnostic pop
344
345
 
345
- - (NSArray *)getMapBoundaries
346
+ - (NSDictionary *)getMapBoundaries
346
347
  {
347
348
  GMSVisibleRegion visibleRegion = self.projection.visibleRegion;
348
349
  GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion:visibleRegion];
@@ -350,16 +351,16 @@ id regionAsJSON(MKCoordinateRegion region) {
350
351
  CLLocationCoordinate2D northEast = bounds.northEast;
351
352
  CLLocationCoordinate2D southWest = bounds.southWest;
352
353
 
353
- return @[
354
- @[
355
- [NSNumber numberWithDouble:northEast.longitude],
356
- [NSNumber numberWithDouble:northEast.latitude]
357
- ],
358
- @[
359
- [NSNumber numberWithDouble:southWest.longitude],
360
- [NSNumber numberWithDouble:southWest.latitude]
361
- ]
362
- ];
354
+ return @{
355
+ @"northEast": @{
356
+ @"latitude": [NSNumber numberWithDouble:northEast.latitude],
357
+ @"longitude": [NSNumber numberWithDouble:northEast.longitude],
358
+ },
359
+ @"southWest": @{
360
+ @"latitude": [NSNumber numberWithDouble:southWest.latitude],
361
+ @"longitude": [NSNumber numberWithDouble:southWest.longitude],
362
+ },
363
+ };
363
364
  }
364
365
 
365
366
  - (NSDictionary *) getCameraDic {
@@ -25,6 +25,12 @@
25
25
  #import <MapKit/MapKit.h>
26
26
  #import <QuartzCore/QuartzCore.h>
27
27
 
28
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
29
+ #import <ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>
30
+ #else
31
+ #import <react-native-maps-generated/RNMapsAirModuleDelegate.h>
32
+ #endif
33
+
28
34
  static NSString *const RCTMapViewKey = @"MapView";
29
35
 
30
36
 
@@ -344,7 +350,7 @@ RCT_EXPORT_METHOD(coordinateForPoint:(nonnull NSNumber *)reactTag
344
350
  if (![view isKindOfClass:[AIRGoogleMap class]]) {
345
351
  RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
346
352
  } else {
347
- AIRGoogleMap *mapView = (AIRGoogleMap *)view;
353
+ id<RNMapsAirModuleDelegate> mapView = (id<RNMapsAirModuleDelegate>) view;
348
354
  resolve([view getCoordinatesForPoint:pt]);
349
355
  }
350
356
  }];
@@ -10,8 +10,11 @@
10
10
 
11
11
  #import <React/RCTViewComponentView.h>
12
12
  #import <UIKit/UIKit.h>
13
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
14
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
15
+ #else
13
16
  #import <react-native-maps-generated/RNMapsHostVewDelegate.h>
14
-
17
+ #endif
15
18
  @class AIRGoogleMap;
16
19
 
17
20
  NS_ASSUME_NONNULL_BEGIN
@@ -10,18 +10,33 @@
10
10
  #import "RNMapsGoogleMapView.h"
11
11
  #import "RNMapsGooglePolygonView.h"
12
12
  #import "AIRGoogleMap.h"
13
- #import "AIRMapMarker.h"
14
13
  #import "AIRGoogleMapManager.h"
14
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
15
+ #import <ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>
16
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
17
+ #import <ReactNativeMapsGenerated/ComponentDescriptors.h>
18
+ #import <ReactNativeMapsGenerated/EventEmitters.h>
19
+ #import <ReactNativeMapsGenerated/Props.h>
20
+ #import <ReactNativeMapsGenerated/RCTComponentViewHelpers.h>
21
+ #else
22
+ #import <react-native-maps-generated/RNMapsAirModuleDelegate.h>
15
23
  #import <react-native-maps-generated/ComponentDescriptors.h>
16
24
  #import <react-native-maps-generated/EventEmitters.h>
17
25
  #import <react-native-maps-generated/Props.h>
18
26
  #import <react-native-maps-generated/RCTComponentViewHelpers.h>
27
+ #endif
19
28
  #import "RCTFabricComponentsPlugins.h"
20
29
  #import <React/RCTConversions.h>
21
30
  #import <React/RCTUtils.h>
22
31
  #import "RCTConvert+GMSMapViewType.h"
32
+ #if __has_include(<ReactNativeMaps/RCTConvert+AirMap.h>)
33
+ #import <ReactNativeMaps/RCTConvert+AirMap.h>
34
+ #import <ReactNativeMaps/UIView+AirMap.h>
35
+ #else
23
36
  #import "RCTConvert+AirMap.h"
24
37
  #import "UIView+AirMap.h"
38
+ #endif
39
+
25
40
 
26
41
  using namespace facebook::react;
27
42
 
@@ -10,11 +10,20 @@
10
10
  #import "RNMapsGooglePolygonView.h"
11
11
  #import "AIRGMSPolygon.h"
12
12
  #import "AIRGoogleMap.h"
13
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
14
+ #import <ReactNativeMapsGenerated/RNMapsSpecs.h>
15
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
16
+ #import <ReactNativeMapsGenerated/ComponentDescriptors.h>
17
+ #import <ReactNativeMapsGenerated/EventEmitters.h>
18
+ #import <ReactNativeMapsGenerated/Props.h>
19
+ #import <ReactNativeMapsGenerated/RCTComponentViewHelpers.h>
20
+ #else
13
21
  #import <react-native-maps-generated/RNMapsSpecs.h>
14
22
  #import <react-native-maps-generated/ComponentDescriptors.h>
15
23
  #import <react-native-maps-generated/EventEmitters.h>
16
24
  #import <react-native-maps-generated/Props.h>
17
25
  #import <react-native-maps-generated/RCTComponentViewHelpers.h>
26
+ #endif
18
27
 
19
28
  #import "RCTFabricComponentsPlugins.h"
20
29
  #import <React/RCTConversions.h>
@@ -14,7 +14,7 @@
14
14
  #import "SMCalloutView.h"
15
15
  #import "RCTConvert+AirMap.h"
16
16
  #import "AIRMapCalloutSubview.h"
17
- #import <react-native-maps-generated/RNMapsAirModuleDelegate.h>
17
+
18
18
 
19
19
  @class AIRMapCoordinate;
20
20
  @class AIRMapMarker;
@@ -23,7 +23,7 @@ extern const NSTimeInterval AIRMapRegionChangeObserveInterval;
23
23
  extern const CGFloat AIRMapZoomBoundBuffer;
24
24
  extern const NSInteger AIRMapMaxZoomLevel;
25
25
 
26
- @interface AIRMap: MKMapView<SMCalloutViewDelegate, RNMapsAirModuleDelegate>
26
+ @interface AIRMap: MKMapView<SMCalloutViewDelegate>
27
27
 
28
28
  @property (nonatomic, strong) SMCalloutView *calloutView;
29
29
  @property (nonatomic, strong) UIImageView *cacheImageView;
@@ -77,7 +77,7 @@ extern const NSInteger AIRMapMaxZoomLevel;
77
77
  - (void)beginLoading;
78
78
  - (void)finishLoading;
79
79
  - (double)getZoomLevel;
80
- - (NSArray *)getMapBoundaries;
80
+ - (NSDictionary *)getMapBoundaries;
81
81
 
82
82
  - (AIRMapMarker*) markerAtPoint:(CGPoint)point;
83
83
  - (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
@@ -26,8 +26,12 @@ const NSTimeInterval AIRMapRegionChangeObserveInterval = 0.1;
26
26
  const CGFloat AIRMapZoomBoundBuffer = 0.01;
27
27
  const NSInteger AIRMapMaxZoomLevel = 20;
28
28
 
29
-
30
- @interface MKMapView (UIGestureRecognizer)
29
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
30
+ #import <ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>
31
+ #else
32
+ #import <react-native-maps-generated/RNMapsAirModuleDelegate.h>
33
+ #endif
34
+ @interface MKMapView (UIGestureRecognizer)<RNMapsAirModuleDelegate>
31
35
 
32
36
  // this tells the compiler that MKMapView actually implements this method
33
37
  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
@@ -320,23 +324,23 @@ const NSInteger AIRMapMaxZoomLevel = 20;
320
324
 
321
325
  #pragma mark RNMapsAirModuleDelegate.h
322
326
 
323
- - (NSArray *)getMapBoundaries
327
+ - (NSDictionary *)getMapBoundaries
324
328
  {
325
329
  MKMapRect mapRect = self.visibleMapRect;
326
330
 
327
331
  CLLocationCoordinate2D northEast = MKCoordinateForMapPoint(MKMapPointMake(MKMapRectGetMaxX(mapRect), mapRect.origin.y));
328
332
  CLLocationCoordinate2D southWest = MKCoordinateForMapPoint(MKMapPointMake(mapRect.origin.x, MKMapRectGetMaxY(mapRect)));
329
333
 
330
- return @[
331
- @[
332
- [NSNumber numberWithDouble:northEast.longitude],
333
- [NSNumber numberWithDouble:northEast.latitude]
334
- ],
335
- @[
336
- [NSNumber numberWithDouble:southWest.longitude],
337
- [NSNumber numberWithDouble:southWest.latitude]
338
- ]
339
- ];
334
+ return @{
335
+ @"northEast": @{
336
+ @"latitude": [NSNumber numberWithDouble:northEast.latitude],
337
+ @"longitude": [NSNumber numberWithDouble:northEast.longitude],
338
+ },
339
+ @"southWest": @{
340
+ @"latitude": [NSNumber numberWithDouble:southWest.latitude],
341
+ @"longitude": [NSNumber numberWithDouble:southWest.longitude],
342
+ },
343
+ };
340
344
  }
341
345
  - (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D) location
342
346
  {
@@ -749,7 +753,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
749
753
 
750
754
  - (void) listenToMemoryWarnings
751
755
  {
752
- __weak typeof(self) weakSelf = self;
756
+ __weak __typeof(self) weakSelf = self;
753
757
  static dispatch_once_t onceToken;
754
758
  static dispatch_source_t source;
755
759
  dispatch_once(&onceToken, ^{
@@ -186,18 +186,7 @@ RCT_EXPORT_METHOD(getMapBoundaries:(nonnull NSNumber *)reactTag
186
186
  if (![view isKindOfClass:[AIRMap class]]) {
187
187
  RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
188
188
  } else {
189
- NSArray *boundingBox = [view getMapBoundaries];
190
-
191
- resolve(@{
192
- @"northEast" : @{
193
- @"longitude" : boundingBox[0][0],
194
- @"latitude" : boundingBox[0][1]
195
- },
196
- @"southWest" : @{
197
- @"longitude" : boundingBox[1][0],
198
- @"latitude" : boundingBox[1][1]
199
- }
200
- });
189
+ resolve([view getMapBoundaries]);
201
190
  }
202
191
  }];
203
192
  }
@@ -50,8 +50,8 @@
50
50
  - (void)setBoundsRect:(NSArray *)boundsRect {
51
51
  _boundsRect = boundsRect;
52
52
 
53
- _southWest = CLLocationCoordinate2DMake([boundsRect[0][0] doubleValue], [boundsRect[0][1] doubleValue]);
54
- _northEast = CLLocationCoordinate2DMake([boundsRect[1][0] doubleValue], [boundsRect[1][1] doubleValue]);
53
+ _northEast = CLLocationCoordinate2DMake([boundsRect[0][0] doubleValue], [boundsRect[0][1] doubleValue]);
54
+ _southWest = CLLocationCoordinate2DMake([boundsRect[1][0] doubleValue], [boundsRect[1][1] doubleValue]);
55
55
 
56
56
  MKMapPoint southWest = MKMapPointForCoordinate(_southWest);
57
57
  MKMapPoint northEast = MKMapPointForCoordinate(_northEast);
@@ -12,9 +12,6 @@
12
12
 
13
13
  #import <React/RCTViewComponentView.h>
14
14
  #import <UIKit/UIKit.h>
15
- #import <react-native-maps-generated/RNMapsHostVewDelegate.h>
16
-
17
-
18
15
 
19
16
  NS_ASSUME_NONNULL_BEGIN
20
17
 
@@ -9,10 +9,19 @@
9
9
 
10
10
  #if HAVE_GOOGLE_MAPS == 0
11
11
 
12
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
13
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
14
+ #import <ReactNativeMapsGenerated/ComponentDescriptors.h>
15
+ #import <ReactNativeMapsGenerated/EventEmitters.h>
16
+ #import <ReactNativeMapsGenerated/Props.h>
17
+ #import <ReactNativeMapsGenerated/RCTComponentViewHelpers.h>
18
+ #else
12
19
  #import <react-native-maps-generated/ComponentDescriptors.h>
13
20
  #import <react-native-maps-generated/EventEmitters.h>
14
21
  #import <react-native-maps-generated/Props.h>
15
22
  #import <react-native-maps-generated/RCTComponentViewHelpers.h>
23
+ #import <react-native-maps-generated/RNMapsHostVewDelegate.h>
24
+ #endif
16
25
  #import "RCTFabricComponentsPlugins.h"
17
26
  #import <React/RCTConversions.h>
18
27
  #import "PlaceHolderGoogleMapView.h"
@@ -9,10 +9,18 @@
9
9
 
10
10
  #if HAVE_GOOGLE_MAPS == 0
11
11
 
12
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
13
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
14
+ #import <ReactNativeMapsGenerated/ComponentDescriptors.h>
15
+ #import <ReactNativeMapsGenerated/EventEmitters.h>
16
+ #import <ReactNativeMapsGenerated/Props.h>
17
+ #import <ReactNativeMapsGenerated/RCTComponentViewHelpers.h>
18
+ #else
12
19
  #import <react-native-maps-generated/ComponentDescriptors.h>
13
20
  #import <react-native-maps-generated/EventEmitters.h>
14
21
  #import <react-native-maps-generated/Props.h>
15
22
  #import <react-native-maps-generated/RCTComponentViewHelpers.h>
23
+ #endif
16
24
 
17
25
  #import "RCTFabricComponentsPlugins.h"
18
26
  #import <React/RCTConversions.h>
@@ -1,13 +1,12 @@
1
- // RCTNativeLocalStorage.h
2
1
  // TurboModuleExample
3
2
  #ifdef RCT_NEW_ARCH_ENABLED
4
3
 
5
4
  #import <Foundation/Foundation.h>
6
- #import <react-native-maps-generated/RNMapsSpecs.h>
5
+
7
6
 
8
7
  NS_ASSUME_NONNULL_BEGIN
9
8
 
10
- @interface RNMapsAirModule : NSObject <NativeAirMapsModuleSpec>
9
+ @interface RNMapsAirModule : NSObject
11
10
 
12
11
  @end
13
12
 
@@ -5,6 +5,8 @@
5
5
  // Created by Salah Ghanim on 23.11.24.
6
6
  // Copyright © 2024 react-native-maps. All rights reserved.
7
7
  //
8
+ #ifdef RCT_NEW_ARCH_ENABLED
9
+
8
10
 
9
11
  #import "RNMapsAirModule.h"
10
12
  #import <React/RCTUIManager.h>
@@ -15,6 +17,16 @@
15
17
  #import <MapKit/MapKit.h>
16
18
  #import "RCTConvert+AirMap.h"
17
19
 
20
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
21
+ #import <ReactNativeMapsGenerated/RNMapsSpecs.h>
22
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
23
+ #else
24
+ #import <react-native-maps-generated/RNMapsSpecs.h>
25
+ #import <react-native-maps-generated/RNMapsHostVewDelegate.h>
26
+ #endif
27
+ @interface RNMapsAirModule()<NativeAirMapsModuleSpec>
28
+ @end
29
+
18
30
  @implementation RNMapsAirModule
19
31
 
20
32
  @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
@@ -148,3 +160,5 @@
148
160
 
149
161
  @end
150
162
 
163
+
164
+ #endif
@@ -1 +1 @@
1
- #define HAVE_GOOGLE_MAPS 1
1
+ #define HAVE_GOOGLE_MAPS 0
@@ -9,8 +9,11 @@
9
9
 
10
10
  #import <React/RCTViewComponentView.h>
11
11
  #import <UIKit/UIKit.h>
12
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>)
13
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
14
+ #else
12
15
  #import <react-native-maps-generated/RNMapsHostVewDelegate.h>
13
-
16
+ #endif
14
17
  @class AIRMap;
15
18
 
16
19
  NS_ASSUME_NONNULL_BEGIN
@@ -11,10 +11,20 @@
11
11
  #import "AIRMapMarker.h"
12
12
  #import "AIRMapManager.h"
13
13
  #import "RNMapsMarkerView.h"
14
- #import <react-native-maps-generated/EventEmitters.h>
14
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
15
+ #import <ReactNativeMapsGenerated/RNMapsSpecs.h>
16
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
17
+ #import <ReactNativeMapsGenerated/ComponentDescriptors.h>
18
+ #import <ReactNativeMapsGenerated/EventEmitters.h>
19
+ #import <ReactNativeMapsGenerated/Props.h>
20
+ #import <ReactNativeMapsGenerated/RCTComponentViewHelpers.h>
21
+ #else
22
+ #import <react-native-maps-generated/RNMapsSpecs.h>
15
23
  #import <react-native-maps-generated/ComponentDescriptors.h>
24
+ #import <react-native-maps-generated/EventEmitters.h>
16
25
  #import <react-native-maps-generated/Props.h>
17
26
  #import <react-native-maps-generated/RCTComponentViewHelpers.h>
27
+ #endif
18
28
  #import "RCTFabricComponentsPlugins.h"
19
29
  #import <React/RCTConversions.h>
20
30
  #import "UIView+AirMap.h"
@@ -31,7 +41,7 @@ using namespace facebook::react;
31
41
 
32
42
 
33
43
  - (id<RNMapsAirModuleDelegate>) mapView {
34
- return _view;
44
+ return nil;
35
45
  }
36
46
 
37
47
  - (void) prepareForRecycle
@@ -10,10 +10,18 @@
10
10
  #import "AIRMap.h"
11
11
  #import "AIRMapMarker.h"
12
12
  #import "AIRMapMarkerManager.h"
13
+ #if __has_include(<ReactNativeMapsGenerated/RNMapsAirModuleDelegate.h>)
14
+ #import <ReactNativeMapsGenerated/RNMapsHostVewDelegate.h>
15
+ #import <ReactNativeMapsGenerated/ComponentDescriptors.h>
16
+ #import <ReactNativeMapsGenerated/EventEmitters.h>
17
+ #import <ReactNativeMapsGenerated/Props.h>
18
+ #import <ReactNativeMapsGenerated/RCTComponentViewHelpers.h>
19
+ #else
13
20
  #import <react-native-maps-generated/ComponentDescriptors.h>
14
21
  #import <react-native-maps-generated/EventEmitters.h>
15
22
  #import <react-native-maps-generated/Props.h>
16
23
  #import <react-native-maps-generated/RCTComponentViewHelpers.h>
24
+ #endif
17
25
  #import "RCTFabricComponentsPlugins.h"
18
26
  #import <React/RCTConversions.h>
19
27
  #import "UIView+AirMap.h"
@@ -0,0 +1,6 @@
1
+ framework module ReactNativeMaps {
2
+ header "UIView+AirMap.h"
3
+ header "RCTConvert+AirMap.h"
4
+
5
+ export *
6
+ }
@@ -18,7 +18,7 @@
18
18
 
19
19
  - (NSDictionary *) getCameraDic;
20
20
  - (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
21
- - (NSArray *) getMapBoundaries;
21
+ - (NSDictionary *) getMapBoundaries;
22
22
  - (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D) location;
23
23
  - (NSDictionary *) getCoordinatesForPoint:(CGPoint) point;
24
24
  @end
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "src/index.ts",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.21.0-alpha.140",
8
+ "version": "1.21.0-alpha.142",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
  s.homepage = package["homepage"]
13
13
  s.license = package["license"]
14
- s.platform = :ios, "15.0"
14
+ s.platform = :ios, "15.1"
15
15
  s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag=> "v#{s.version}" }
16
16
  s.source_files = "ios/AirGoogleMaps/**/*.{h,m,mm,swift}"
17
17
  s.resource_bundles = {
@@ -21,6 +21,7 @@ Pod::Spec.new do |s|
21
21
  s.dependency 'GoogleMaps', '9.3.0'
22
22
  s.dependency 'Google-Maps-iOS-Utils', '6.1.0'
23
23
  s.dependency 'react-native-maps-generated'
24
+ s.dependency 'react-native-maps'
24
25
  install_modules_dependencies(s)
25
26
 
26
27
  end
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
  s.homepage = package["homepage"]
13
13
  s.license = package["license"]
14
- s.platform = :ios, "13.0"
14
+ s.platform = :ios, "15.1"
15
15
  s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag=> "v#{s.version}" }
16
16
  s.source_files = "ios/generated/**/*.{h,m,mm,cpp,swift}"
17
17
  s.exclude_files = [
@@ -24,7 +24,6 @@ Pod::Spec.new do |s|
24
24
  ]
25
25
  s.public_header_files = "ios/generated/**/*.h"
26
26
  s.module_name = 'ReactNativeMapsGenerated'
27
- s.dependency "React-Core"
28
27
  s.compiler_flags = folly_compiler_flags
29
28
  install_modules_dependencies(s)
30
29
 
@@ -11,13 +11,19 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
  s.homepage = package["homepage"]
13
13
  s.license = package["license"]
14
- s.platform = :ios, "13.0"
14
+ s.platform = :ios, "15.1"
15
15
  s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag=> "v#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/AirMaps/**/*.{h,m,mm,swift}"
18
- s.dependency "React-Core"
18
+ s.module_map = 'ios/AirMaps/module.modulemap'
19
+ s.public_header_files = [
20
+ 'ios/AirMaps/UIView+AirMap.h',
21
+ 'ios/AirMaps/RCTConvert+AirMap.h',
22
+ ]
23
+ s.module_name = 'ReactNativeMaps'
19
24
  s.compiler_flags = folly_compiler_flags
20
25
  s.dependency 'react-native-maps-generated'
26
+ s.dependency "React-Core"
21
27
  install_modules_dependencies(s)
22
28
 
23
29
  # Add script phase to detect Google Maps
@@ -55,8 +61,11 @@ Pod::Spec.new do |s|
55
61
  }
56
62
  ]
57
63
 
58
- # Add the generated defines header to the header search path
59
64
  s.pod_target_xcconfig = {
60
- 'HEADER_SEARCH_PATHS' => "\"$(CONFIGURATION_BUILD_DIR)/react-native-google-maps\" \"${PODS_ROOT}/Headers/Private/Yoga\""
65
+ 'HEADER_SEARCH_PATHS' => [
66
+ '$(PODS_ROOT)/Headers/Public/React-Core',
67
+ '$(PODS_TARGET_SRCROOT)/../../../node_modules/react-native/React'
68
+ ]
61
69
  }
70
+
62
71
  end
@@ -77,6 +77,13 @@ export type MapOverlayProps = ViewProps & {
77
77
 
78
78
  type NativeProps = Modify<MapOverlayProps, {image?: string}>;
79
79
 
80
+ function normalizeBounds(bounds: [number, number][]): any {
81
+ return {
82
+ northEast: {latitude: bounds[0][0], longitude: bounds[0][1]},
83
+ southWest: {latitude: bounds[1][0], longitude: bounds[1][1]},
84
+ };
85
+ }
86
+
80
87
  export class MapOverlay extends React.Component<MapOverlayProps> {
81
88
  // declaration only, as they are set through decorateMap
82
89
  /// @ts-ignore
@@ -90,7 +97,7 @@ export class MapOverlay extends React.Component<MapOverlayProps> {
90
97
  private fabricOverlay?: Boolean = undefined;
91
98
 
92
99
  render() {
93
- const {opacity = 1.0} = this.props;
100
+ const {opacity = 1.0, bounds} = this.props;
94
101
 
95
102
  if (this.fabricOverlay === undefined) {
96
103
  this.fabricOverlay = Platform.OS === 'android';
@@ -98,12 +105,27 @@ export class MapOverlay extends React.Component<MapOverlayProps> {
98
105
 
99
106
  const AIRMapOverlay = this.getNativeComponent();
100
107
  let image: any = this.props.image;
101
- if (this.props.image && this.fabricOverlay) {
102
- image = fixImageProp(this.props.image);
108
+
109
+ let boundsParam: any = bounds;
110
+ if (this.fabricOverlay) {
111
+ if (this.props.image) {
112
+ image = fixImageProp(this.props.image);
113
+ }
114
+ if (bounds) {
115
+ boundsParam = normalizeBounds(bounds);
116
+ }
117
+ } else {
118
+ if (this.props.image) {
119
+ image = fixImageProp(this.props.image);
120
+ if (image.uri) {
121
+ image = image.uri;
122
+ }
123
+ }
103
124
  }
104
125
  return (
105
126
  <AIRMapOverlay
106
- {...this.props}
127
+ // @ts-ignore
128
+ bounds={boundsParam}
107
129
  opacity={opacity}
108
130
  // @ts-ignore
109
131
  image={image}
@@ -46,7 +46,16 @@ export interface OverlayFabricNativeProps extends ViewProps {
46
46
  * @platform iOS: Supported
47
47
  * @platform Android: Supported
48
48
  */
49
- bounds: ReadonlyArray<LatLng>;
49
+ bounds: Readonly<{
50
+ northEast: {
51
+ latitude: Double; // Non-nullable Double for latitude
52
+ longitude: Double; // Non-nullable Double for longitude
53
+ };
54
+ southWest: {
55
+ latitude: Double; // Non-nullable Double for latitude
56
+ longitude: Double; // Non-nullable Double for longitude
57
+ };
58
+ }>;
50
59
 
51
60
  /**
52
61
  * A custom image to be used as the overlay.