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.
- package/android/build.gradle +38 -13
- package/android/generated/RCTAppDependencyProvider.h +25 -0
- package/android/generated/RCTAppDependencyProvider.mm +55 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/android/generated/RCTThirdPartyComponentsProvider.mm +26 -0
- package/android/generated/ReactAppDependencyProvider.podspec +34 -0
- package/android/generated/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerDelegate.java +35 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerInterface.java +17 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +200 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +71 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNMapsSpecs-generated.cpp +68 -0
- package/android/generated/jni/RNMapsSpecs.h +31 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +28 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +918 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +787 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +154 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1058 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +268 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +21 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +76 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +77 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/rnmaps/fabric/CalloutManager.java +77 -0
- package/android/src/main/java/com/rnmaps/fabric/JSONUtil.java +86 -0
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +593 -0
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +259 -0
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +156 -4
- package/android/src/main/java/com/rnmaps/fabric/event/OnCalloutPressEvent.java +25 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDeselectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragEndEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragStartEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnLongPressEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMapLoadedEvent.java +29 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMapReadyEvent.java +29 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDeselectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEndEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragStartEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerPressEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerSelectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnPoiClickEvent.java +27 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnPressEvent.java +27 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeCompleteEvent.java +30 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +48 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeStartEvent.java +33 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnSelectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnUserLocationChangeEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +22 -2
- package/android/src/main/java/com/rnmaps/maps/MapCallout.java +18 -0
- package/android/src/main/java/com/rnmaps/maps/MapManager.java +14 -14
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +79 -3
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +206 -206
- package/android/src/main/java/com/rnmaps/maps/MapView.java +1618 -1346
- package/ios/AirGoogleMaps/AIRGoogleMap.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +153 -48
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +17 -28
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +2 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +30 -0
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +0 -7
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +2 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +3 -3
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +161 -61
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +6 -3
- package/ios/AirMaps/AIRMap.m +289 -145
- package/ios/AirMaps/AIRMapManager.m +8 -17
- package/ios/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +165 -103
- package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
- package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
- package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
- package/ios/AirMaps/RNMapsAirModule.h +1 -1
- package/ios/AirMaps/RNMapsAirModule.mm +42 -172
- package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
- package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
- package/ios/AirMaps/RNMapsMapView.h +3 -3
- package/ios/AirMaps/RNMapsMapView.mm +344 -307
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
- package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
- package/ios/AirMaps/UIView +AirMap.m +20 -0
- package/ios/AirMaps/UIView+AirMap.h +11 -0
- package/ios/AirMaps.xcodeproj/project.pbxproj +60 -0
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +26 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +28 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +918 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +787 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +154 -0
- package/ios/generated/RNMapsSpecs/Props.h +1058 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +549 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +21 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +76 -0
- package/ios/generated/RNMapsSpecs/States.cpp +16 -0
- package/ios/generated/RNMapsSpecs/States.h +77 -0
- package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
- package/ios/generated/RNMapsSpecsJSI.h +268 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/MapCallout.js +1 -0
- package/lib/MapMarker.d.ts +15 -2
- package/lib/MapMarker.js +53 -9
- package/lib/MapMarkerNativeComponent.js +0 -2
- package/lib/MapOverlay.js +2 -8
- package/lib/MapPolyline.d.ts +1 -1
- package/lib/MapView.d.ts +7 -22
- package/lib/MapView.js +83 -94
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -11
- package/lib/createFabricMap.js +175 -0
- package/lib/decorateMapComponent.js +22 -0
- package/lib/specs/NativeAirMapsModule.d.ts +2 -2
- package/lib/specs/NativeComponentCallout.d.ts +46 -0
- package/lib/specs/NativeComponentCallout.js +9 -0
- package/lib/specs/NativeComponentGoogleMapView.d.ts +12 -12
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -0
- package/lib/specs/NativeComponentMapView.d.ts +19 -36
- package/lib/specs/NativeComponentMapView.js +1 -3
- package/lib/specs/NativeComponentMarker.d.ts +258 -0
- package/lib/specs/NativeComponentMarker.js +19 -0
- package/package.json +15 -10
- package/react-native-maps.podspec +2 -1
- package/lib/FabricMapView.js +0 -181
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#import <React/RCTBridge.h>
|
|
11
11
|
#import "AIRGMSPolygon.h"
|
|
12
12
|
#import "AIRGoogleMapCoordinate.h"
|
|
13
|
+
#import "AIRGoogleMap.h"
|
|
13
14
|
|
|
14
15
|
@interface AIRGoogleMapPolygon : UIView
|
|
15
16
|
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
@property (nonatomic, assign) BOOL geodesic;
|
|
27
28
|
@property (nonatomic, assign) int zIndex;
|
|
28
29
|
@property (nonatomic, assign) BOOL tappable;
|
|
29
|
-
|
|
30
|
+
- (void) didInsertInMap:(AIRGoogleMap *) map;
|
|
30
31
|
@end
|
|
31
32
|
|
|
32
33
|
#endif
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#import "AIRGoogleMapPolygon.h"
|
|
10
10
|
#import "AIRGMSPolygon.h"
|
|
11
11
|
#import <GoogleMaps/GoogleMaps.h>
|
|
12
|
+
#import "AIRGoogleMap.h"
|
|
12
13
|
|
|
13
14
|
@implementation AIRGoogleMapPolygon
|
|
14
15
|
{
|
|
@@ -41,6 +42,35 @@
|
|
|
41
42
|
_polygon.strokeWidth = _strokeWidth;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
- (void) didInsertInMap:(AIRGoogleMap *) map
|
|
46
|
+
{
|
|
47
|
+
_polygon = [AIRGMSPolygon new];
|
|
48
|
+
|
|
49
|
+
if (_identifier){
|
|
50
|
+
[_polygon setIdentifier:_identifier];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[_polygon setTappable:_tappable];
|
|
54
|
+
if (_strokeColor){
|
|
55
|
+
_polygon.strokeColor = _strokeColor;
|
|
56
|
+
}
|
|
57
|
+
if (_fillColor){
|
|
58
|
+
_polygon.fillColor = _fillColor;
|
|
59
|
+
}
|
|
60
|
+
if (_strokeWidth){
|
|
61
|
+
_polygon.strokeWidth = _strokeWidth;
|
|
62
|
+
}
|
|
63
|
+
if (_coordinates){
|
|
64
|
+
[self setCoordinates:_coordinates];
|
|
65
|
+
}
|
|
66
|
+
if (_holes){
|
|
67
|
+
[self setHoles:_holes];
|
|
68
|
+
}
|
|
69
|
+
if (_zIndex){
|
|
70
|
+
_polygon.zIndex = _zIndex;
|
|
71
|
+
}
|
|
72
|
+
[_polygon setMap:map];
|
|
73
|
+
}
|
|
44
74
|
|
|
45
75
|
- (void)setCoordinates:(NSArray<AIRGoogleMapCoordinate *> *)coordinates
|
|
46
76
|
{
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
@property (nonatomic, strong) UIColor *strokeColor;
|
|
26
26
|
@property (nonatomic, strong) NSArray<UIColor *> *strokeColors;
|
|
27
27
|
@property (nonatomic, assign) double strokeWidth;
|
|
28
|
-
@property (nonatomic, assign) UIColor *fillColor;
|
|
29
28
|
@property (nonatomic, strong) NSArray<NSNumber *> *lineDashPattern;
|
|
30
29
|
@property (nonatomic, assign) BOOL geodesic;
|
|
31
30
|
@property (nonatomic, assign) NSString *title;
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
{
|
|
20
20
|
if (self = [super init]) {
|
|
21
21
|
_polyline = [[AIRGMSPolyline alloc] init];
|
|
22
|
-
_polyline.spans = @[[GMSStyleSpan spanWithColor:_strokeColor]];
|
|
23
22
|
_polyline.strokeColor = _strokeColor;
|
|
24
23
|
}
|
|
25
24
|
return self;
|
|
@@ -79,12 +78,6 @@
|
|
|
79
78
|
_polyline.strokeWidth = strokeWidth;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
-(void)setFillColor:(UIColor *)fillColor
|
|
83
|
-
{
|
|
84
|
-
_fillColor = fillColor;
|
|
85
|
-
_polyline.spans = @[[GMSStyleSpan spanWithColor:fillColor]];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
81
|
- (void)setLineDashPattern:(NSArray<NSNumber *> *)lineDashPattern {
|
|
89
82
|
_lineDashPattern = lineDashPattern;
|
|
90
83
|
[self configureStyleSpansIfNeeded];
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
@interface WMSTileOverlay : GMSSyncTileLayer
|
|
15
15
|
@property (nonatomic) double MapX,MapY,FULL;
|
|
16
|
-
@property (nonatomic,
|
|
16
|
+
@property (nonatomic, assign) NSString *urlTemplate;
|
|
17
17
|
@property (nonatomic, assign) NSInteger maximumZ;
|
|
18
18
|
@property (nonatomic, assign) NSInteger minimumZ;
|
|
19
19
|
@end
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
{
|
|
63
63
|
_urlTemplate = urlTemplate;
|
|
64
64
|
WMSTileOverlay *tile = [[WMSTileOverlay alloc] init];
|
|
65
|
-
[tile
|
|
65
|
+
[tile setUrlTemplate:urlTemplate];
|
|
66
66
|
[tile setMaximumZ: _maximumZ];
|
|
67
67
|
[tile setMinimumZ: _minimumZ];
|
|
68
68
|
[tile setOpacity: _opacity];
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
return nil;
|
|
108
108
|
}
|
|
109
109
|
NSArray *bb = [self getBoundBox:x yAxis:y zoom:zoom];
|
|
110
|
-
NSMutableString *url = [self.
|
|
110
|
+
NSMutableString *url = [self.urlTemplate mutableCopy];
|
|
111
111
|
[url replaceOccurrencesOfString: @"{minX}" withString:[NSString stringWithFormat:@"%@", bb[0]] options:0 range:NSMakeRange(0, url.length)];
|
|
112
112
|
[url replaceOccurrencesOfString: @"{minY}" withString:[NSString stringWithFormat:@"%@", bb[1]] options:0 range:NSMakeRange(0, url.length)];
|
|
113
113
|
[url replaceOccurrencesOfString: @"{maxX}" withString:[NSString stringWithFormat:@"%@", bb[2]] options:0 range:NSMakeRange(0, url.length)];
|
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
#import <Foundation/Foundation.h>
|
|
10
10
|
#import <GoogleMaps/GoogleMaps.h>
|
|
11
11
|
#import <React/RCTConvert.h>
|
|
12
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
12
13
|
|
|
13
14
|
@interface RCTConvert (GMSMapViewType)
|
|
14
15
|
+ (GMSCameraPosition*)GMSCameraPositionWithDefaults:(id)json existingCamera:(GMSCameraPosition*)existingCamera;
|
|
16
|
+
+ (NSArray<NSArray<AIRGoogleMapCoordinate *> *> *)AIRGoogleMapCoordinateArrayArray:(id)json;
|
|
17
|
+
+ (AIRGoogleMapCoordinate *)AIRGoogleMapCoordinate:(id)json;
|
|
15
18
|
@end
|
|
16
19
|
|
|
17
20
|
#endif
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
|
|
34
34
|
+ (AIRGoogleMapCoordinate *)AIRGoogleMapCoordinate:(id)json
|
|
35
35
|
{
|
|
36
|
+
// empty coordinates
|
|
37
|
+
if ([json isKindOfClass:[NSArray class]] && [json count] == 0) return nil;
|
|
36
38
|
AIRGoogleMapCoordinate *coord = [AIRGoogleMapCoordinate new];
|
|
37
39
|
coord.coordinate = [self CLLocationCoordinate2D:json];
|
|
38
40
|
return coord;
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
#import <React/RCTViewComponentView.h>
|
|
12
12
|
#import <UIKit/UIKit.h>
|
|
13
|
+
#import "RNMapsHostVewDelegate.h"
|
|
14
|
+
|
|
13
15
|
@class AIRGoogleMap;
|
|
14
16
|
|
|
15
17
|
NS_ASSUME_NONNULL_BEGIN
|
|
16
18
|
|
|
17
|
-
@interface RNMapsGoogleMapView : RCTViewComponentView
|
|
18
|
-
|
|
19
|
-
- (AIRGoogleMap *) mapView;
|
|
19
|
+
@interface RNMapsGoogleMapView : RCTViewComponentView<RNMapsHostVewDelegate>
|
|
20
20
|
|
|
21
21
|
@end
|
|
22
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
2
|
// RNMapsGoogleMapView.mm
|
|
3
|
-
//
|
|
3
|
+
//
|
|
4
4
|
//
|
|
5
5
|
// Created by Salah Ghanim on 23.11.24.
|
|
6
6
|
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
@@ -8,20 +8,21 @@
|
|
|
8
8
|
#ifdef HAVE_GOOGLE_MAPS
|
|
9
9
|
|
|
10
10
|
#import "RNMapsGoogleMapView.h"
|
|
11
|
+
#import "RNMapsGooglePolygonView.h"
|
|
11
12
|
#import "AirGoogleMap.h"
|
|
12
13
|
#import "AIRMapMarker.h"
|
|
13
14
|
#import "AirGoogleMapManager.h"
|
|
14
15
|
|
|
15
|
-
#import <react/
|
|
16
|
-
#import <react/
|
|
17
|
-
#import <react/
|
|
18
|
-
#import <react/
|
|
16
|
+
#import <react-native-maps-generated/ComponentDescriptors.h>
|
|
17
|
+
#import <react-native-maps-generated/EventEmitters.h>
|
|
18
|
+
#import <react-native-maps-generated/Props.h>
|
|
19
|
+
#import <react-native-maps-generated/RCTComponentViewHelpers.h>
|
|
19
20
|
|
|
20
21
|
#import "RCTFabricComponentsPlugins.h"
|
|
21
22
|
#import <React/RCTConversions.h>
|
|
22
23
|
#import "RCTConvert+GMSMapViewType.h"
|
|
23
24
|
#import "RCTConvert+AirMap.h"
|
|
24
|
-
|
|
25
|
+
#import "UIView+AirMap.h"
|
|
25
26
|
|
|
26
27
|
using namespace facebook::react;
|
|
27
28
|
|
|
@@ -31,10 +32,12 @@ using namespace facebook::react;
|
|
|
31
32
|
@implementation RNMapsGoogleMapView {
|
|
32
33
|
AIRGoogleMap *_view;
|
|
33
34
|
AIRGoogleMapManager* _legacyMapManager;
|
|
35
|
+
NSMutableDictionary<NSNumber*, UIView*>* _pendingInsertsSubviews;
|
|
36
|
+
NSMutableArray *_polygons;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
|
|
37
|
-
- (
|
|
40
|
+
- (id<RNMapsAirModuleDelegate>) mapView {
|
|
38
41
|
return _view;
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -42,11 +45,12 @@ using namespace facebook::react;
|
|
|
42
45
|
- (void)animateToRegion:(NSString *)regionJSON duration:(NSInteger)duration{
|
|
43
46
|
NSDictionary* regionDic = [RCTConvert dictonaryFromString:regionJSON];
|
|
44
47
|
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:regionDic];
|
|
45
|
-
[CATransaction begin];
|
|
46
|
-
[CATransaction setAnimationDuration:duration/1000];
|
|
47
48
|
GMSCameraPosition *camera = [AIRGoogleMap makeGMSCameraPositionFromMap:_view andMKCoordinateRegion:region];
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
if (duration == 0){
|
|
50
|
+
[_view setRegion:region];
|
|
51
|
+
} else {
|
|
52
|
+
[_view animateToCameraPosition:camera];
|
|
53
|
+
}
|
|
50
54
|
}
|
|
51
55
|
- (void)setCamera:(NSString *)cameraJSON{
|
|
52
56
|
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
@@ -73,10 +77,14 @@ using namespace facebook::react;
|
|
|
73
77
|
}
|
|
74
78
|
- (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
75
79
|
NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
|
|
80
|
+
NSMutableArray<AIRGoogleMapCoordinate*>* coordinatesArray = [NSMutableArray new];
|
|
81
|
+
for (id json : coordinatesArr){
|
|
82
|
+
[coordinatesArray addObject:[RCTConvert AIRGoogleMapCoordinate:json]];
|
|
83
|
+
}
|
|
76
84
|
|
|
77
85
|
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
|
|
87
|
+
[_view fitToCoordinates:coordinatesArray withEdgePadding:edgePadding animated:animated];
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
#pragma mark - Native commands
|
|
@@ -91,11 +99,25 @@ using namespace facebook::react;
|
|
|
91
99
|
{
|
|
92
100
|
return concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDescriptor>();
|
|
93
101
|
}
|
|
102
|
+
- (void) loadPendingInsertSubviews
|
|
103
|
+
{
|
|
104
|
+
if ([_pendingInsertsSubviews count] > 0){
|
|
105
|
+
NSArray<NSNumber *> *sortedKeys = [[_pendingInsertsSubviews allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
|
106
|
+
for (NSNumber *key in sortedKeys) {
|
|
107
|
+
// Get the corresponding view
|
|
108
|
+
UIView *view = [_pendingInsertsSubviews objectForKey:key];
|
|
109
|
+
[_view insertReactSubview:view atIndex:[key integerValue]];
|
|
110
|
+
// Remove the entry from the dictionary
|
|
111
|
+
[_pendingInsertsSubviews removeObjectForKey:key];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
94
115
|
|
|
95
116
|
- (void) prepareContentView {
|
|
96
|
-
|
|
117
|
+
|
|
97
118
|
_view = (AIRGoogleMap *)[_legacyMapManager view];
|
|
98
|
-
|
|
119
|
+
_polygons = [NSMutableArray new];
|
|
120
|
+
|
|
99
121
|
self.contentView = _view;
|
|
100
122
|
|
|
101
123
|
_view.onPress = [self](NSDictionary* dictionary) {
|
|
@@ -126,24 +148,51 @@ using namespace facebook::react;
|
|
|
126
148
|
}
|
|
127
149
|
};
|
|
128
150
|
|
|
151
|
+
_view.onLongPress = [self](NSDictionary* dictionary) {
|
|
152
|
+
if (_eventEmitter) {
|
|
153
|
+
// Extract values from the NSDictionary
|
|
154
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
155
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
156
|
+
|
|
157
|
+
// Populate the OnMapPressCoordinate struct
|
|
158
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnLongPressCoordinate coordinate = {
|
|
159
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
160
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Populate the OnMapPressPosition struct
|
|
164
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnLongPressPosition position = {
|
|
165
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
166
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
170
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnLongPress data = {
|
|
171
|
+
.action = std::string([@"press" UTF8String]),
|
|
172
|
+
.position = position,
|
|
173
|
+
.coordinate = coordinate
|
|
174
|
+
};
|
|
175
|
+
mapViewEventEmitter->onLongPress(data);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
129
179
|
_view.onMapReady = [self](NSDictionary* dictionary) {
|
|
180
|
+
[self loadPendingInsertSubviews];
|
|
130
181
|
if (_eventEmitter) {
|
|
131
|
-
NSLog(@"mapReady");
|
|
132
182
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
133
183
|
facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapReady data = {};
|
|
134
184
|
mapViewEventEmitter->onMapReady(data);
|
|
135
185
|
}
|
|
136
186
|
};
|
|
137
|
-
|
|
187
|
+
|
|
138
188
|
_view.onMapLoaded = [self](NSDictionary* dictionary) {
|
|
139
189
|
if (_eventEmitter) {
|
|
140
|
-
NSLog(@"mapLoaded");
|
|
141
190
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
142
191
|
facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapLoaded data = {};
|
|
143
192
|
mapViewEventEmitter->onMapLoaded(data);
|
|
144
193
|
}
|
|
145
194
|
};
|
|
146
|
-
|
|
195
|
+
|
|
147
196
|
_view.onKmlReady = [self](NSDictionary* dictionary) {
|
|
148
197
|
if (_eventEmitter) {
|
|
149
198
|
|
|
@@ -211,7 +260,7 @@ using namespace facebook::react;
|
|
|
211
260
|
if (errorDict){
|
|
212
261
|
str = errorDict[@"message"];
|
|
213
262
|
}
|
|
214
|
-
|
|
263
|
+
|
|
215
264
|
facebook::react::RNMapsGoogleMapViewEventEmitter::OnUserLocationChangeError error = {
|
|
216
265
|
.message = std::string([str UTF8String]),
|
|
217
266
|
};
|
|
@@ -225,6 +274,35 @@ using namespace facebook::react;
|
|
|
225
274
|
mapViewEventEmitter->onUserLocationChange(data);
|
|
226
275
|
}
|
|
227
276
|
};
|
|
277
|
+
|
|
278
|
+
_view.onPoiClick = [self](NSDictionary* dictionary) {
|
|
279
|
+
if (_eventEmitter) {
|
|
280
|
+
|
|
281
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
282
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
283
|
+
|
|
284
|
+
// Populate the OnMapPressCoordinate struct
|
|
285
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPoiClickCoordinate coordinate = {
|
|
286
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
287
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
288
|
+
};
|
|
289
|
+
// Populate the OnMapDouplePressPosition struct
|
|
290
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPoiClickPosition position = {
|
|
291
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
292
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
297
|
+
facebook::react::RNMapsGoogleMapViewEventEmitter::OnPoiClick data = {
|
|
298
|
+
.coordinate = coordinate,
|
|
299
|
+
.position = position,
|
|
300
|
+
.placeId = [dictionary[@"placeId"] UTF8String],
|
|
301
|
+
.name = [dictionary[@"name"] UTF8String],
|
|
302
|
+
};
|
|
303
|
+
mapViewEventEmitter->onPoiClick(data);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
228
306
|
|
|
229
307
|
|
|
230
308
|
|
|
@@ -243,7 +321,7 @@ using namespace facebook::react;
|
|
|
243
321
|
mapViewEventEmitter->onRegionChangeStart(data);
|
|
244
322
|
}
|
|
245
323
|
};
|
|
246
|
-
|
|
324
|
+
|
|
247
325
|
_view.onRegionChange = [self](NSDictionary* dictionary) {
|
|
248
326
|
if (_eventEmitter) {
|
|
249
327
|
|
|
@@ -259,7 +337,7 @@ using namespace facebook::react;
|
|
|
259
337
|
mapViewEventEmitter->onRegionChange(data);
|
|
260
338
|
}
|
|
261
339
|
};
|
|
262
|
-
|
|
340
|
+
|
|
263
341
|
_view.onRegionChangeComplete = [self](NSDictionary* dictionary) {
|
|
264
342
|
if (_eventEmitter) {
|
|
265
343
|
|
|
@@ -329,41 +407,66 @@ using namespace facebook::react;
|
|
|
329
407
|
static const auto defaultProps = std::make_shared<const RNMapsGoogleMapViewProps>();
|
|
330
408
|
_props = defaultProps;
|
|
331
409
|
_legacyMapManager = [[AIRGoogleMapManager alloc] init];
|
|
410
|
+
_pendingInsertsSubviews = [NSMutableDictionary new];
|
|
332
411
|
}
|
|
333
412
|
|
|
334
413
|
return self;
|
|
335
414
|
}
|
|
336
415
|
|
|
337
|
-
- (id)getPaperViewFromChildComponentView:(UIView *)childComponentView {
|
|
338
|
-
// Check if the childComponentView responds to the "adapter" selector
|
|
339
|
-
if ([childComponentView respondsToSelector:@selector(paperView)]) {
|
|
340
|
-
// Safely return the paperView
|
|
341
|
-
return [childComponentView valueForKey:@"paperView"];
|
|
342
|
-
}
|
|
343
|
-
// Return nil if paperView is not accessible
|
|
344
|
-
return nil;
|
|
345
|
-
}
|
|
346
416
|
|
|
347
417
|
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index{
|
|
348
|
-
id<RCTComponent> paperView = [
|
|
418
|
+
id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
|
|
349
419
|
if (paperView){
|
|
350
|
-
[_view
|
|
420
|
+
if(_view && [_view isReady]){
|
|
421
|
+
[_view insertReactSubview:paperView atIndex:index];
|
|
422
|
+
} else {
|
|
423
|
+
[_pendingInsertsSubviews setObject:paperView forKey:[NSNumber numberWithInteger:index]];
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
426
|
+
[_view insertReactSubview:childComponentView atIndex:index];
|
|
427
|
+
if ([childComponentView isKindOfClass:[RNMapsGooglePolygonView class]]){
|
|
428
|
+
RNMapsGooglePolygonView* polygon = (RNMapsGooglePolygonView *) childComponentView;
|
|
429
|
+
[_polygons addObject:childComponentView];
|
|
430
|
+
[polygon didInsertInMap:_view];
|
|
431
|
+
}
|
|
351
432
|
}
|
|
352
433
|
}
|
|
434
|
+
|
|
353
435
|
- (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
354
436
|
{
|
|
355
|
-
id<RCTComponent> paperView = [
|
|
437
|
+
id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
|
|
356
438
|
if (paperView){
|
|
357
|
-
[_view
|
|
439
|
+
if(_view && [_view isReady]){
|
|
440
|
+
[_view removeReactSubview:paperView];
|
|
441
|
+
} else {
|
|
442
|
+
[_pendingInsertsSubviews removeObjectForKey:[NSNumber numberWithInteger:index]];
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
[_view removeReactSubview:childComponentView];
|
|
446
|
+
if ([childComponentView isKindOfClass:[RNMapsGooglePolygonView class]]){
|
|
447
|
+
RNMapsGooglePolygonView* polygon = (RNMapsGooglePolygonView *) childComponentView;
|
|
448
|
+
[_polygons removeObject:childComponentView];
|
|
449
|
+
[polygon didRemoveFromMap];
|
|
450
|
+
}
|
|
358
451
|
}
|
|
359
452
|
}
|
|
453
|
+
- (void) prepareForRecycle
|
|
454
|
+
{
|
|
455
|
+
[super prepareForRecycle];
|
|
456
|
+
static const auto defaultProps = std::make_shared<const RNMapsGoogleMapViewProps>();
|
|
457
|
+
_props = defaultProps;
|
|
458
|
+
_legacyMapManager = [[AIRGoogleMapManager alloc] init];
|
|
459
|
+
_pendingInsertsSubviews = [NSMutableDictionary new];
|
|
460
|
+
[_view removeFromSuperview];
|
|
461
|
+
_view = nil;
|
|
462
|
+
}
|
|
360
463
|
|
|
361
464
|
|
|
362
465
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
363
466
|
{
|
|
364
467
|
const auto &oldViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(_props);
|
|
365
468
|
const auto &newViewProps = *std::static_pointer_cast<RNMapsGoogleMapViewProps const>(props);
|
|
366
|
-
|
|
469
|
+
|
|
367
470
|
|
|
368
471
|
if (oldViewProps.googleMapId != newViewProps.googleMapId) {
|
|
369
472
|
NSString* mapID = RCTNSStringFromString(newViewProps.googleMapId);
|
|
@@ -379,8 +482,6 @@ using namespace facebook::react;
|
|
|
379
482
|
if (oldViewProps.loadingBackgroundColor != newViewProps.loadingBackgroundColor){
|
|
380
483
|
_legacyMapManager.backgroundColor = RCTUIColorFromSharedColor(newViewProps.backgroundColor);
|
|
381
484
|
}
|
|
382
|
-
|
|
383
|
-
NSLog(@"initialCamera lat:%f lng:%f pitch:%f zoom:%f heading: %f", newViewProps.initialCamera.center.latitude, newViewProps.initialCamera.center.longitude, newViewProps.initialCamera.pitch, newViewProps.initialCamera.zoom, newViewProps.initialCamera.heading);
|
|
384
485
|
|
|
385
486
|
// bug with zoom / pitch / heading where value is not 0 even though
|
|
386
487
|
// nothing is passed from JS so we depend on lat / lng comparison for now
|
|
@@ -397,7 +498,7 @@ using namespace facebook::react;
|
|
|
397
498
|
_legacyMapManager.camera = camera;
|
|
398
499
|
}
|
|
399
500
|
|
|
400
|
-
|
|
501
|
+
|
|
401
502
|
|
|
402
503
|
if (!_view){
|
|
403
504
|
[self prepareContentView];
|
|
@@ -431,20 +532,6 @@ using namespace facebook::react;
|
|
|
431
532
|
_view.name = region; \
|
|
432
533
|
}
|
|
433
534
|
|
|
434
|
-
#define REMAP_GOOGLEMAPVIEW_CAMERA_PROP(name) \
|
|
435
|
-
if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
|
|
436
|
-
newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
|
|
437
|
-
newViewProps.name.heading != oldViewProps.name.heading || \
|
|
438
|
-
newViewProps.name.pitch != oldViewProps.name.pitch || \
|
|
439
|
-
newViewProps.name.zoom != oldViewProps.name.zoom) { \
|
|
440
|
-
GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.name.center.latitude \
|
|
441
|
-
longitude:newViewProps.name.center.longitude \
|
|
442
|
-
zoom:newViewProps.name.zoom \
|
|
443
|
-
bearing:newViewProps.name.heading \
|
|
444
|
-
viewingAngle:newViewProps.name.pitch]; \
|
|
445
|
-
_view.name = camera; \
|
|
446
|
-
}
|
|
447
|
-
|
|
448
535
|
|
|
449
536
|
#define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
|
|
450
537
|
if (newViewProps.name.top != oldViewProps.name.top || \
|
|
@@ -459,16 +546,16 @@ using namespace facebook::react;
|
|
|
459
546
|
|
|
460
547
|
|
|
461
548
|
REMAP_MAPVIEW_PROP(pitchEnabled)
|
|
462
|
-
|
|
463
549
|
REMAP_MAPVIEW_PROP(zoomTapEnabled)
|
|
464
|
-
|
|
465
550
|
REMAP_MAPVIEW_PROP(scrollEnabled)
|
|
466
|
-
|
|
551
|
+
|
|
552
|
+
REMAP_MAPVIEW_STRING_PROP(kmlSrc)
|
|
553
|
+
|
|
467
554
|
if (newViewProps.minZoom != oldViewProps.minZoom || newViewProps.maxZoom != oldViewProps.maxZoom){
|
|
468
555
|
[_view setMinZoom:newViewProps.minZoom maxZoom:newViewProps.maxZoom];
|
|
469
556
|
}
|
|
470
557
|
|
|
471
|
-
|
|
558
|
+
[_view setShowsCompass:newViewProps.showsCompass];
|
|
472
559
|
REMAP_MAPVIEW_PROP(showsTraffic)
|
|
473
560
|
REMAP_MAPVIEW_PROP(showsUserLocation)
|
|
474
561
|
REMAP_MAPVIEW_PROP(zoomEnabled)
|
|
@@ -477,9 +564,20 @@ using namespace facebook::react;
|
|
|
477
564
|
REMAP_MAPVIEW_REGION_PROP(region)
|
|
478
565
|
REMAP_MAPVIEW_REGION_PROP(initialRegion)
|
|
479
566
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
567
|
+
if (newViewProps.camera.center.latitude != oldViewProps.camera.center.latitude ||
|
|
568
|
+
newViewProps.camera.center.longitude != oldViewProps.camera.center.longitude ||
|
|
569
|
+
newViewProps.camera.heading != oldViewProps.camera.heading ||
|
|
570
|
+
newViewProps.camera.pitch != oldViewProps.camera.pitch ||
|
|
571
|
+
newViewProps.camera.zoom != oldViewProps.camera.zoom) {
|
|
572
|
+
GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude:newViewProps.camera.center.latitude
|
|
573
|
+
longitude:newViewProps.camera.center.longitude
|
|
574
|
+
zoom:newViewProps.camera.zoom
|
|
575
|
+
bearing:newViewProps.camera.heading
|
|
576
|
+
viewingAngle:newViewProps.camera.pitch];
|
|
577
|
+
_view.cameraProp = camera;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
|
|
483
581
|
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
484
582
|
|
|
485
583
|
|
|
@@ -493,14 +591,16 @@ using namespace facebook::react;
|
|
|
493
591
|
break;
|
|
494
592
|
case RNMapsGoogleMapViewMapType::Terrain:
|
|
495
593
|
_view.mapType = kGMSTypeTerrain;
|
|
594
|
+
break;
|
|
496
595
|
case RNMapsGoogleMapViewMapType::Hybrid:
|
|
497
596
|
_view.mapType = kGMSTypeHybrid;
|
|
597
|
+
break;
|
|
498
598
|
default:
|
|
499
599
|
_view.mapType = kGMSTypeNormal;
|
|
500
600
|
break;
|
|
501
601
|
}
|
|
502
602
|
}
|
|
503
|
-
|
|
603
|
+
|
|
504
604
|
if (oldViewProps.userInterfaceStyle != newViewProps.userInterfaceStyle){
|
|
505
605
|
switch (newViewProps.userInterfaceStyle) {
|
|
506
606
|
case RNMapsGoogleMapViewUserInterfaceStyle::Light:
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMapsGoogleMapView.h
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Salah Ghanim on 23.11.24.
|
|
6
|
+
// Copyright © 2024 react-native-maps. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
9
|
+
#ifdef HAVE_GOOGLE_MAPS
|
|
10
|
+
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <UIKit/UIKit.h>
|
|
13
|
+
|
|
14
|
+
@class AIRGoogleMap;
|
|
15
|
+
@class AIRGMSPolygon;
|
|
16
|
+
|
|
17
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
18
|
+
@interface RNMapsGooglePolygonView : RCTViewComponentView
|
|
19
|
+
- (void) didInsertInMap:(AIRGoogleMap*) map;
|
|
20
|
+
- (void) didRemoveFromMap;
|
|
21
|
+
@end
|
|
22
|
+
|
|
23
|
+
NS_ASSUME_NONNULL_END
|
|
24
|
+
|
|
25
|
+
#endif
|
|
26
|
+
#endif
|