react-native-maps 1.21.0-alpha.4 → 1.21.0-alpha.40

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 (69) hide show
  1. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
  2. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
  3. package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
  4. package/ios/AirGoogleMaps/AIRGoogleMap.m +179 -11
  5. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  6. package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
  7. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
  8. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
  9. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
  10. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
  11. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  12. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
  13. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
  14. package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
  15. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
  16. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +32 -2
  17. package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
  18. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
  19. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
  20. package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
  21. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
  22. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  23. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  24. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
  25. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
  26. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +599 -0
  27. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  28. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
  29. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
  30. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
  31. package/ios/AirMaps/AIRMap.h +8 -5
  32. package/ios/AirMaps/AIRMap.m +284 -141
  33. package/ios/AirMaps/AIRMapManager.m +12 -21
  34. package/ios/AirMaps/AIRMapMarker.h +1 -0
  35. package/ios/AirMaps/AIRMapMarker.m +165 -103
  36. package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
  37. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  38. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  39. package/ios/AirMaps/RNMapsAirModule.h +3 -0
  40. package/ios/AirMaps/RNMapsAirModule.mm +42 -172
  41. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  42. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  43. package/ios/AirMaps/RNMapsMapView.h +6 -3
  44. package/ios/AirMaps/RNMapsMapView.mm +341 -334
  45. package/ios/AirMaps/RNMapsMarkerView.h +24 -0
  46. package/ios/AirMaps/RNMapsMarkerView.mm +422 -0
  47. package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
  48. package/ios/AirMaps/UIView +AirMap.m +20 -0
  49. package/ios/AirMaps/UIView+AirMap.h +11 -0
  50. package/lib/MapMarker.d.ts +15 -2
  51. package/lib/MapMarker.js +53 -9
  52. package/lib/MapMarkerNativeComponent.js +0 -2
  53. package/lib/MapOverlay.d.ts +1 -1
  54. package/lib/MapView.d.ts +5 -22
  55. package/lib/MapView.js +34 -21
  56. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
  57. package/lib/createFabricMap.js +175 -0
  58. package/lib/decorateMapComponent.js +18 -0
  59. package/lib/specs/NativeAirMapsModule.d.ts +2 -2
  60. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  61. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  62. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  63. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  64. package/lib/specs/NativeComponentMapView.d.ts +21 -45
  65. package/lib/specs/NativeComponentMarker.d.ts +258 -0
  66. package/lib/specs/NativeComponentMarker.js +21 -0
  67. package/package.json +7 -7
  68. package/react-native-maps.podspec +1 -1
  69. package/lib/FabricMapView.js +0 -175
@@ -0,0 +1,217 @@
1
+ //
2
+ // RNMapsGoogleMapView.mm
3
+ //
4
+ //
5
+ // Created by Salah Ghanim on 23.11.24.
6
+ // Copyright © 2024 react-native-maps. All rights reserved.
7
+ //
8
+ #ifdef HAVE_GOOGLE_MAPS
9
+
10
+ #import "RNMapsGooglePolygonView.h"
11
+ #import "AIRGMSPolygon.h"
12
+ #import "AIRGoogleMap.h"
13
+
14
+ #import <react/renderer/components/RNMapsSpecs/ComponentDescriptors.h>
15
+ #import <react/renderer/components/RNMapsSpecs/EventEmitters.h>
16
+ #import <react/renderer/components/RNMapsSpecs/Props.h>
17
+ #import <react/renderer/components/RNMapsSpecs/RCTComponentViewHelpers.h>
18
+
19
+ #import "RCTFabricComponentsPlugins.h"
20
+ #import <React/RCTConversions.h>
21
+ #import "RCTConvert+GMSMapViewType.h"
22
+ #import "RCTConvert+AirMap.h"
23
+ #import "UIView+AirMap.h"
24
+
25
+ using namespace facebook::react;
26
+
27
+ bool areHolesEqual(const std::vector<std::vector<RNMapsGooglePolygonHolesStruct>>& newHoles, const std::vector<std::vector<RNMapsGooglePolygonHolesStruct>>& oldHoles) {
28
+ // First-level check: compare the sizes of the top-level vectors
29
+ if (newHoles.size() != oldHoles.size()) {
30
+ return false;
31
+ }
32
+
33
+ // Second-level check: compare the contents of each child vector
34
+ for (size_t i = 0; i < newHoles.size(); ++i) {
35
+ const auto& newHole = newHoles.at(i);
36
+ const auto& oldHole = oldHoles.at(i);
37
+
38
+ // Compare sizes of the child vectors
39
+ if (newHole.size() != oldHole.size()) {
40
+ return false;
41
+ }
42
+
43
+ }
44
+
45
+ return true;
46
+ }
47
+
48
+ @interface RNMapsGooglePolygonView () <RCTRNMapsGooglePolygonViewProtocol>
49
+ @end
50
+
51
+ @implementation RNMapsGooglePolygonView {
52
+ AIRGMSPolygon *_view;
53
+ }
54
+
55
+
56
+ - (AIRGMSPolygon*) polygon {
57
+ return _view;
58
+ }
59
+
60
+ + (ComponentDescriptorProvider)componentDescriptorProvider
61
+ {
62
+ return concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>();
63
+ }
64
+
65
+ - (void) didInsertInMap:(AIRGoogleMap*) map
66
+ {
67
+ _view.map = map;
68
+ }
69
+
70
+ -(void) didRemoveFromMap
71
+ {
72
+ _view.map = nil;
73
+ _view = nil;
74
+ }
75
+
76
+ - (void) prepareContentView {
77
+
78
+ _view = [AIRGMSPolygon new];
79
+ _view.onPress = [self](NSDictionary* dictionary) {
80
+ if (_eventEmitter) {
81
+ // Extract values from the NSDictionary
82
+ NSDictionary* coordinateDict = dictionary[@"coordinate"];
83
+ NSDictionary* positionDict = dictionary[@"position"];
84
+
85
+ // Populate the OnMapPressCoordinate struct
86
+ facebook::react::RNMapsGooglePolygonEventEmitter::OnPressCoordinate coordinate = {
87
+ .latitude = [coordinateDict[@"latitude"] doubleValue],
88
+ .longitude = [coordinateDict[@"longitude"] doubleValue],
89
+ };
90
+
91
+ // Populate the OnMapPressPosition struct
92
+ facebook::react::RNMapsGooglePolygonEventEmitter::OnPressPosition position = {
93
+ .x = [positionDict[@"x"] doubleValue],
94
+ .y = [positionDict[@"y"] doubleValue],
95
+ };
96
+
97
+ auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGooglePolygonEventEmitter const>(_eventEmitter);
98
+ facebook::react::RNMapsGooglePolygonEventEmitter::OnPress data = {
99
+ .action = std::string([@"press" UTF8String]),
100
+ .position = position,
101
+ .coordinate = coordinate
102
+ };
103
+ mapViewEventEmitter->onPress(data);
104
+ }
105
+ };
106
+
107
+ }
108
+
109
+ - (instancetype)initWithFrame:(CGRect)frame
110
+ {
111
+ if (self = [super initWithFrame:frame]) {
112
+ static const auto defaultProps = std::make_shared<const RNMapsGooglePolygonProps>();
113
+ _props = defaultProps;
114
+ [self prepareContentView];
115
+
116
+ }
117
+
118
+ return self;
119
+ }
120
+
121
+
122
+
123
+ - (void) prepareForRecycle
124
+ {
125
+ [super prepareForRecycle];
126
+ static const auto defaultProps = std::make_shared<const RNMapsGooglePolygonProps>();
127
+ _props = defaultProps;
128
+ _view = nil;
129
+ }
130
+
131
+
132
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
133
+ {
134
+ const auto &oldViewProps = *std::static_pointer_cast<RNMapsGooglePolygonProps const>(_props);
135
+ const auto &newViewProps = *std::static_pointer_cast<RNMapsGooglePolygonProps const>(props);
136
+
137
+
138
+ if (!_view){
139
+ [self prepareContentView];
140
+ }
141
+
142
+ #define REMAP_MAPVIEW_PROP(name) \
143
+ if (oldViewProps.name != newViewProps.name) { \
144
+ _view.name = newViewProps.name; \
145
+ }
146
+
147
+ #define REMAP_MAPVIEW_STRING_PROP(name) \
148
+ if (oldViewProps.name != newViewProps.name) { \
149
+ _view.name = RCTNSStringFromString(newViewProps.name); \
150
+ }
151
+
152
+ #define REMAP_MAPVIEW_POINT_PROP(name) \
153
+ if (newViewProps.name.x != oldViewProps.name.x || \
154
+ newViewProps.name.y != oldViewProps.name.y) { \
155
+ _view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
156
+ }
157
+
158
+
159
+ if(newViewProps.zIndex.has_value()){
160
+ _view.zIndex = newViewProps.zIndex.value();
161
+ }
162
+ if (newViewProps.coordinates.size() != oldViewProps.coordinates.size()){
163
+ GMSMutablePath *path = [GMSMutablePath path];
164
+ for(int i = 0; i < newViewProps.coordinates.size(); i++)
165
+ {
166
+ CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(
167
+ newViewProps.coordinates.at(i).latitude,newViewProps.coordinates.at(i).longitude);
168
+ [path addCoordinate:coordinates];
169
+ }
170
+ _view.path = path;
171
+ }
172
+
173
+ if (!areHolesEqual(newViewProps.holes, oldViewProps.holes)){
174
+ NSMutableArray<GMSMutablePath *> *interiorPolygons = [NSMutableArray array];
175
+ for(int h = 0; h < newViewProps.holes.size(); h++)
176
+ {
177
+ GMSMutablePath *path = [GMSMutablePath path];
178
+ for(int i = 0; i < newViewProps.holes[h].size(); i++)
179
+ {
180
+ CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(
181
+ newViewProps.holes.at(h).at(i).latitude,
182
+ newViewProps.holes.at(h).at(i).longitude);
183
+ [path addCoordinate:coordinates];
184
+ }
185
+ [interiorPolygons addObject:path];
186
+ }
187
+ _view.holes = interiorPolygons;
188
+ }
189
+
190
+
191
+ REMAP_MAPVIEW_PROP(tappable)
192
+
193
+ if (newViewProps.fillColor){
194
+ _view.fillColor = RCTUIColorFromSharedColor(newViewProps.fillColor);
195
+ }
196
+
197
+ if (newViewProps.strokeColor){
198
+ _view.strokeColor = RCTUIColorFromSharedColor(newViewProps.strokeColor);
199
+ }
200
+
201
+
202
+
203
+
204
+ [super updateProps:props oldProps:oldProps];
205
+ }
206
+ - (void) didMoveToSuperview {
207
+ [super didMoveToSuperview];
208
+ NSLog(@"SuperView ? %@", self.superview);
209
+ }
210
+ @end
211
+
212
+ Class<RCTComponentViewProtocol> RNMapsGooglePolygonCls(void)
213
+ {
214
+ return RNMapsGooglePolygonView.class;
215
+ }
216
+
217
+ #endif
@@ -0,0 +1,25 @@
1
+ //
2
+ // RNMapsMapViewManager.mm
3
+ // AirMaps
4
+ //
5
+ // Created by Salah Ghanim on 23.11.24.
6
+ // Copyright © 2024 react-native-maps. All rights reserved.
7
+ //
8
+ #ifdef HAVE_GOOGLE_MAPS
9
+
10
+ #import <React/RCTLog.h>
11
+ #import <React/RCTUIManager.h>
12
+ #import <React/RCTViewManager.h>
13
+
14
+ @interface RNMapsGooglePolygonViewManager : RCTViewManager
15
+ @end
16
+
17
+ @implementation RNMapsGooglePolygonViewManager
18
+
19
+ RCT_EXPORT_MODULE(RNMapsGooglePolygonViewManager)
20
+
21
+
22
+
23
+ @end
24
+
25
+ #endif
@@ -14,14 +14,16 @@
14
14
  #import "SMCalloutView.h"
15
15
  #import "RCTConvert+AirMap.h"
16
16
  #import "AIRMapCalloutSubview.h"
17
+ #import "RNMapsAirModuleDelegate.h"
17
18
 
19
+ @class AIRMapCoordinate;
18
20
  @class AIRMapMarker;
19
21
 
20
22
  extern const NSTimeInterval AIRMapRegionChangeObserveInterval;
21
23
  extern const CGFloat AIRMapZoomBoundBuffer;
22
24
  extern const NSInteger AIRMapMaxZoomLevel;
23
25
 
24
- @interface AIRMap: MKMapView<SMCalloutViewDelegate>
26
+ @interface AIRMap: MKMapView<SMCalloutViewDelegate, RNMapsAirModuleDelegate>
25
27
 
26
28
  @property (nonatomic, strong) SMCalloutView *calloutView;
27
29
  @property (nonatomic, strong) UIImageView *cacheImageView;
@@ -33,6 +35,7 @@ extern const NSInteger AIRMapMaxZoomLevel;
33
35
  @property (nonatomic, assign) BOOL hasStartedRendering;
34
36
  @property (nonatomic, assign) BOOL cacheEnabled;
35
37
  @property (nonatomic, assign) BOOL loadingEnabled;
38
+ @property (nonatomic, assign) BOOL handlePanDrag;
36
39
  @property (nonatomic, assign) BOOL legacyZoomConstraintsEnabled;
37
40
  @property (nonatomic, strong) UIColor *loadingBackgroundColor;
38
41
  @property (nonatomic, strong) UIColor *loadingIndicatorColor;
@@ -41,9 +44,9 @@ extern const NSInteger AIRMapMaxZoomLevel;
41
44
  @property (nonatomic, assign) CGFloat maxDelta;
42
45
  @property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
43
46
  @property (nonatomic, assign) MKCoordinateRegion initialRegion;
44
- @property (nonatomic, assign) MKMapCamera *initialCamera;
45
- @property (nonatomic, assign) CGFloat minZoomLevel;
46
- @property (nonatomic, assign) CGFloat maxZoomLevel;
47
+ @property (nonatomic, retain) MKMapCamera *initialCamera;
48
+ @property (nonatomic, assign) CGFloat minZoom;
49
+ @property (nonatomic, assign) CGFloat maxZoom;
47
50
  @property (nonatomic, assign) CGPoint compassOffset;
48
51
  @property (nonatomic, assign) UIEdgeInsets mapPadding;
49
52
 
@@ -80,5 +83,5 @@ extern const NSInteger AIRMapMaxZoomLevel;
80
83
  - (AIRMapMarker*) markerAtPoint:(CGPoint)point;
81
84
  - (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
82
85
  - (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex;
83
-
86
+ -(void) fitToCoordinates:(NSArray<AIRMapCoordinate*>*) coordinates edgePadding:(UIEdgeInsets) edgeInsets animated:(Boolean) animated;
84
87
  @end