react-native-maps 1.24.11 → 1.24.12

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.
@@ -24,8 +24,6 @@ import android.widget.RelativeLayout;
24
24
  import androidx.annotation.NonNull;
25
25
  import androidx.annotation.Nullable;
26
26
  import androidx.core.content.PermissionChecker;
27
- import androidx.core.view.GestureDetectorCompat;
28
- import androidx.core.view.MotionEventCompat;
29
27
 
30
28
  import com.facebook.react.common.MapBuilder;
31
29
 
@@ -144,7 +142,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
144
142
  private final Map<GroundOverlay, MapOverlay> overlayMap = new HashMap<>();
145
143
  private final Map<TileOverlay, MapHeatmap> heatmapMap = new HashMap<>();
146
144
  private final Map<TileOverlay, MapGradientPolyline> gradientPolylineMap = new HashMap<>();
147
- private final GestureDetectorCompat gestureDetector;
145
+ private final GestureDetector gestureDetector;
148
146
  private boolean paused = false;
149
147
  private boolean destroyed = false;
150
148
  private final ThemedReactContext context;
@@ -259,7 +257,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
259
257
  fusedLocationSource = new FusedLocationSource(context);
260
258
 
261
259
  gestureDetector =
262
- new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
260
+ new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
263
261
 
264
262
  @Override
265
263
  public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
@@ -1512,7 +1510,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
1512
1510
  tapLocation = map.getProjection().fromScreenLocation(new Point(X, Y));
1513
1511
  }
1514
1512
 
1515
- int action = MotionEventCompat.getActionMasked(ev);
1513
+ int action = ev.getActionMasked();
1516
1514
 
1517
1515
  switch (action) {
1518
1516
  case (MotionEvent.ACTION_DOWN):
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.24.11",
8
+ "version": "1.24.12",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",
@@ -10,9 +10,15 @@ import type {
10
10
  import NativeAirMapsModule, {
11
11
  type MapBoundaries,
12
12
  } from './specs/NativeAirMapsModule';
13
- import type {MapFabricNativeProps} from './specs/NativeComponentMapView';
14
-
15
- export type FabricMapViewProps = MapFabricNativeProps;
13
+ import FabricMapView, {
14
+ Commands as FabricCommands,
15
+ type MapFabricNativeProps,
16
+ } from './specs/NativeComponentMapView';
17
+ import GoogleMapView, {
18
+ Commands as GoogleCommands,
19
+ type MapFabricNativeProps as GoogleMapFabricNativeProps,
20
+ } from './specs/NativeComponentGoogleMapView';
21
+ export type MapViewProps = MapFabricNativeProps | GoogleMapFabricNativeProps;
16
22
 
17
23
  export interface FabricMapHandle {
18
24
  getCamera: () => Promise<Camera>;
@@ -42,231 +48,208 @@ export interface FabricMapHandle {
42
48
  setIndoorActiveLevelIndex: (activeLevelIndex: number) => void;
43
49
  }
44
50
 
45
- // Helper to safely get a node handle for supported types
46
- function getNodeHandle(ref: unknown): null | number {
47
- if (
48
- ref === null ||
49
- typeof ref === 'number' ||
50
- (typeof ref === 'object' && ref !== null && '_reactInternals' in ref)
51
- ) {
52
- // @ts-expect-error: safe for findNodeHandle
53
- return findNodeHandle(ref);
54
- }
55
- return null;
56
- }
57
-
58
- const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
59
- return forwardRef<FabricMapHandle | null, FabricMapViewProps>(
60
- (props, ref) => {
61
- const fabricRef = useRef<React.ComponentRef<typeof ViewComponent>>(null);
51
+ const createFabricMap = (
52
+ ViewComponent: typeof GoogleMapView | typeof FabricMapView,
53
+ Commands: typeof FabricCommands | typeof GoogleCommands,
54
+ ) => {
55
+ return forwardRef<FabricMapHandle | null, MapViewProps>((props, ref) => {
56
+ const fabricRef =
57
+ useRef<React.ElementRef<typeof GoogleMapView | typeof FabricMapView>>(
58
+ null,
59
+ );
60
+ const node = findNodeHandle(fabricRef.current) ?? -1;
62
61
 
63
- useImperativeHandle(ref, () => ({
64
- async getMarkersFrames(onlyVisible: boolean) {
65
- if (fabricRef.current) {
66
- return NativeAirMapsModule.getMarkersFrames(
67
- getNodeHandle(fabricRef.current) ?? -1,
68
- onlyVisible,
69
- );
70
- } else {
71
- throw new Error(
72
- 'getMarkersFrames is only supported on iOS with Fabric.',
73
- );
74
- }
75
- },
76
- async getCoordinateForPoint(point: Point) {
77
- if (fabricRef.current) {
78
- return NativeAirMapsModule.getCoordinateForPoint(
79
- getNodeHandle(fabricRef.current) ?? -1,
80
- point,
81
- );
82
- } else {
83
- throw new Error(
84
- 'getCoordinateForPoint is only supported on iOS with Fabric.',
85
- );
86
- }
87
- },
88
- async getPointForCoordinate(coordinate: LatLng) {
89
- if (fabricRef.current) {
90
- return NativeAirMapsModule.getPointForCoordinate(
91
- getNodeHandle(fabricRef.current) ?? -1,
92
- coordinate,
93
- );
94
- } else {
95
- throw new Error(
96
- 'getPointForCoordinate is not supported on this platform.',
97
- );
98
- }
99
- },
100
- async getAddressFromCoordinates(coordinate: LatLng) {
101
- if (fabricRef.current) {
102
- return NativeAirMapsModule.getAddressFromCoordinates(
103
- getNodeHandle(fabricRef.current) ?? -1,
104
- coordinate,
105
- );
106
- } else {
107
- throw new Error(
108
- 'getAddressFromCoordinates is not supported on this platform',
109
- );
62
+ useImperativeHandle(ref, () => ({
63
+ async getMarkersFrames(onlyVisible: boolean) {
64
+ if (fabricRef.current) {
65
+ return NativeAirMapsModule.getMarkersFrames(node, onlyVisible);
66
+ } else {
67
+ throw new Error(
68
+ 'getMarkersFrames is only supported on iOS with Fabric.',
69
+ );
70
+ }
71
+ },
72
+ async getCoordinateForPoint(point: Point) {
73
+ if (fabricRef.current) {
74
+ return NativeAirMapsModule.getCoordinateForPoint(node, point);
75
+ } else {
76
+ throw new Error(
77
+ 'getCoordinateForPoint is only supported on iOS with Fabric.',
78
+ );
79
+ }
80
+ },
81
+ async getPointForCoordinate(coordinate: LatLng) {
82
+ if (fabricRef.current) {
83
+ return NativeAirMapsModule.getPointForCoordinate(node, coordinate);
84
+ } else {
85
+ throw new Error(
86
+ 'getPointForCoordinate is not supported on this platform.',
87
+ );
88
+ }
89
+ },
90
+ async getAddressFromCoordinates(coordinate: LatLng) {
91
+ if (fabricRef.current) {
92
+ return NativeAirMapsModule.getAddressFromCoordinates(
93
+ node,
94
+ coordinate,
95
+ );
96
+ } else {
97
+ throw new Error(
98
+ 'getAddressFromCoordinates is not supported on this platform',
99
+ );
100
+ }
101
+ },
102
+ async takeSnapshot(config: SnapshotOptions) {
103
+ if (fabricRef.current) {
104
+ return NativeAirMapsModule.takeSnapshot(node, JSON.stringify(config));
105
+ } else {
106
+ throw new Error('takeSnapshot is only supported on iOS with Fabric.');
107
+ }
108
+ },
109
+ async getCamera() {
110
+ if (fabricRef.current) {
111
+ return NativeAirMapsModule.getCamera(node);
112
+ } else {
113
+ throw new Error('getCamera is only supported on iOS with Fabric.');
114
+ }
115
+ },
116
+ async getMapBoundaries() {
117
+ if (fabricRef.current) {
118
+ return NativeAirMapsModule.getMapBoundaries(node);
119
+ } else {
120
+ throw new Error(
121
+ 'getMapBoundaries is only supported on iOS with Fabric.',
122
+ );
123
+ }
124
+ },
125
+ animateToRegion(region: Region, duration: number) {
126
+ if (fabricRef.current) {
127
+ try {
128
+ (Commands as any).animateToRegion(
129
+ fabricRef.current,
130
+ JSON.stringify(region),
131
+ duration,
132
+ );
133
+ } catch (error) {
134
+ throw new Error('Failed to animateToRegion');
110
135
  }
111
- },
112
- async takeSnapshot(config: SnapshotOptions) {
113
- if (fabricRef.current) {
114
- return NativeAirMapsModule.takeSnapshot(
115
- getNodeHandle(fabricRef.current) ?? -1,
116
- JSON.stringify(config),
117
- );
118
- } else {
119
- throw new Error(
120
- 'takeSnapshot is only supported on iOS with Fabric.',
121
- );
122
- }
123
- },
124
- async getCamera() {
125
- if (fabricRef.current) {
126
- return NativeAirMapsModule.getCamera(
127
- getNodeHandle(fabricRef.current) ?? -1,
128
- );
129
- } else {
130
- throw new Error('getCamera is only supported on iOS with Fabric.');
131
- }
132
- },
133
- async getMapBoundaries() {
134
- if (fabricRef.current) {
135
- return NativeAirMapsModule.getMapBoundaries(
136
- getNodeHandle(fabricRef.current) ?? -1,
137
- );
138
- } else {
139
- throw new Error(
140
- 'getMapBoundaries is only supported on iOS with Fabric.',
141
- );
136
+ } else {
137
+ throw new Error(
138
+ 'animateToRegion is only supported on iOS with Fabric.',
139
+ );
140
+ }
141
+ },
142
+ fitToElements(edgePadding: EdgePadding, animated: boolean) {
143
+ if (fabricRef.current) {
144
+ try {
145
+ (Commands as any).fitToElements(
146
+ fabricRef.current,
147
+ JSON.stringify(edgePadding),
148
+ animated,
149
+ );
150
+ } catch (error) {
151
+ throw new Error('Failed to fitToElements');
142
152
  }
143
- },
144
- animateToRegion(region: Region, duration: number) {
145
- if (fabricRef.current) {
146
- try {
147
- Commands.animateToRegion(
148
- fabricRef.current,
149
- JSON.stringify(region),
150
- duration,
151
- );
152
- } catch (error) {
153
- throw new Error('Failed to animateToRegion');
154
- }
155
- } else {
156
- throw new Error(
157
- 'animateToRegion is only supported on iOS with Fabric.',
158
- );
159
- }
160
- },
161
- fitToElements(edgePadding: EdgePadding, animated: boolean) {
162
- if (fabricRef.current) {
163
- try {
164
- Commands.fitToElements(
165
- fabricRef.current,
166
- JSON.stringify(edgePadding),
167
- animated,
168
- );
169
- } catch (error) {
170
- throw new Error('Failed to fitToElements');
171
- }
172
- } else {
173
- throw new Error(
174
- 'fitToElements is only supported on iOS with Fabric.',
175
- );
153
+ } else {
154
+ throw new Error(
155
+ 'fitToElements is only supported on iOS with Fabric.',
156
+ );
157
+ }
158
+ },
159
+ fitToSuppliedMarkers(
160
+ markers: string[],
161
+ edgePadding: EdgePadding,
162
+ animated: boolean,
163
+ ) {
164
+ if (fabricRef.current) {
165
+ try {
166
+ (Commands as any).fitToSuppliedMarkers(
167
+ fabricRef.current,
168
+ JSON.stringify(markers),
169
+ JSON.stringify(edgePadding),
170
+ animated,
171
+ );
172
+ } catch (error) {
173
+ throw new Error('Failed to fitToSuppliedMarkers');
176
174
  }
177
- },
178
- fitToSuppliedMarkers(
179
- markers: string[],
180
- edgePadding: EdgePadding,
181
- animated: boolean,
182
- ) {
183
- if (fabricRef.current) {
184
- try {
185
- Commands.fitToSuppliedMarkers(
186
- fabricRef.current,
187
- JSON.stringify(markers),
188
- JSON.stringify(edgePadding),
189
- animated,
190
- );
191
- } catch (error) {
192
- throw new Error('Failed to fitToSuppliedMarkers');
193
- }
194
- } else {
195
- throw new Error(
196
- 'fitToSuppliedMarkers is only supported on iOS with Fabric.',
197
- );
175
+ } else {
176
+ throw new Error(
177
+ 'fitToSuppliedMarkers is only supported on iOS with Fabric.',
178
+ );
179
+ }
180
+ },
181
+ animateCamera(camera: Partial<Camera>, duration: number) {
182
+ if (fabricRef.current) {
183
+ try {
184
+ (Commands as any).animateCamera(
185
+ fabricRef.current,
186
+ JSON.stringify(camera),
187
+ duration,
188
+ );
189
+ } catch (error) {
190
+ throw new Error('Failed to animateCamera');
198
191
  }
199
- },
200
- animateCamera(camera: Partial<Camera>, duration: number) {
201
- if (fabricRef.current) {
202
- try {
203
- Commands.animateCamera(
204
- fabricRef.current,
205
- JSON.stringify(camera),
206
- duration,
207
- );
208
- } catch (error) {
209
- throw new Error('Failed to animateCamera');
210
- }
211
- } else {
212
- throw new Error(
213
- 'animateCamera is only supported on iOS with Fabric.',
214
- );
215
- }
216
- },
217
- fitToCoordinates(
218
- coordinates: LatLng[],
219
- edgePadding: EdgePadding,
220
- animated: boolean,
221
- ) {
222
- if (fabricRef.current) {
223
- try {
224
- Commands.fitToCoordinates(
225
- fabricRef.current,
226
- JSON.stringify(coordinates),
227
- JSON.stringify(edgePadding),
228
- animated,
229
- );
230
- } catch (error) {
231
- throw new Error('Failed to fitToCoordinates');
232
- }
233
- } else {
234
- throw new Error(
235
- 'fitToCoordinates is only supported on iOS with Fabric.',
236
- );
192
+ } else {
193
+ throw new Error(
194
+ 'animateCamera is only supported on iOS with Fabric.',
195
+ );
196
+ }
197
+ },
198
+ fitToCoordinates(
199
+ coordinates: LatLng[],
200
+ edgePadding: EdgePadding,
201
+ animated: boolean,
202
+ ) {
203
+ if (fabricRef.current) {
204
+ try {
205
+ (Commands as any).fitToCoordinates(
206
+ fabricRef.current,
207
+ JSON.stringify(coordinates),
208
+ JSON.stringify(edgePadding),
209
+ animated,
210
+ );
211
+ } catch (error) {
212
+ throw new Error('Failed to fitToCoordinates');
237
213
  }
238
- },
239
- setIndoorActiveLevelIndex(activeLevelIndex: number) {
240
- if (fabricRef.current) {
241
- try {
242
- Commands.setIndoorActiveLevelIndex(
243
- fabricRef.current,
244
- activeLevelIndex,
245
- );
246
- } catch (error) {
247
- console.error('Failed to set camera:', error);
248
- }
249
- } else {
250
- console.warn('setIndoorActiveLevelIndex is not supported.');
214
+ } else {
215
+ throw new Error(
216
+ 'fitToCoordinates is only supported on iOS with Fabric.',
217
+ );
218
+ }
219
+ },
220
+ setIndoorActiveLevelIndex(activeLevelIndex: number) {
221
+ if (fabricRef.current) {
222
+ try {
223
+ (Commands as any).setIndoorActiveLevelIndex(
224
+ fabricRef.current,
225
+ activeLevelIndex,
226
+ );
227
+ } catch (error) {
228
+ console.error('Failed to set camera:', error);
251
229
  }
252
- },
253
- setCamera(camera: Partial<Camera>) {
254
- if (fabricRef.current) {
255
- try {
256
- Commands.setCamera(fabricRef.current, JSON.stringify(camera));
257
- } catch (error) {
258
- console.error('Failed to set camera:', error);
259
- }
260
- } else {
261
- console.warn('setCamera is not supported');
230
+ } else {
231
+ console.warn('setIndoorActiveLevelIndex is not supported.');
232
+ }
233
+ },
234
+ setCamera(camera: Partial<Camera>) {
235
+ if (fabricRef.current) {
236
+ try {
237
+ (Commands as any).setCamera(
238
+ fabricRef.current,
239
+ JSON.stringify(camera),
240
+ );
241
+ } catch (error) {
242
+ console.error('Failed to set camera:', error);
262
243
  }
263
- },
264
- }));
244
+ } else {
245
+ console.warn('setCamera is not supported');
246
+ }
247
+ },
248
+ }));
265
249
 
266
- // @ts-ignore
267
- return <ViewComponent {...props} ref={fabricRef} />;
268
- },
269
- );
250
+ // @ts-ignore
251
+ return <ViewComponent {...props} ref={fabricRef} />;
252
+ });
270
253
  };
271
254
 
272
255
  export default createFabricMap;
@@ -11,6 +11,7 @@ import type {
11
11
  DirectEventHandler,
12
12
  BubblingEventHandler,
13
13
  } from 'react-native/Libraries/Types/CodegenTypes';
14
+ import GoogleMapView from './NativeComponentGoogleMapView';
14
15
 
15
16
  export type EdgePadding = Readonly<{
16
17
  top: Double; // Non-nullable Double for top
@@ -860,45 +861,45 @@ export interface MapFabricNativeProps extends ViewProps {
860
861
  zoomTapEnabled?: WithDefault<boolean, true>;
861
862
  }
862
863
 
863
- export interface NativeCommands {
864
+ interface NativeCommands {
864
865
  animateToRegion: (
865
- viewRef: React.ElementRef<React.ComponentType>,
866
+ viewRef: React.ElementRef<typeof GoogleMapView>,
866
867
  regionJSON: string,
867
868
  duration: Int32,
868
869
  ) => void;
869
870
 
870
871
  setCamera: (
871
- viewRef: React.ElementRef<React.ComponentType>,
872
+ viewRef: React.ElementRef<typeof GoogleMapView>,
872
873
  cameraJSON: string,
873
874
  ) => void;
874
875
 
875
876
  animateCamera: (
876
- viewRef: React.ElementRef<React.ComponentType>,
877
+ viewRef: React.ElementRef<typeof GoogleMapView>,
877
878
  cameraJSON: string,
878
879
  duration: Int32,
879
880
  ) => void;
880
881
 
881
882
  fitToElements: (
882
- viewRef: React.ElementRef<React.ComponentType>,
883
+ viewRef: React.ElementRef<typeof GoogleMapView>,
883
884
  edgePaddingJSON: string,
884
885
  animated: boolean,
885
886
  ) => void;
886
887
 
887
888
  fitToSuppliedMarkers: (
888
- viewRef: React.ElementRef<React.ComponentType>,
889
+ viewRef: React.ElementRef<typeof GoogleMapView>,
889
890
  markersJSON: string,
890
891
  edgePaddingJSON: string,
891
892
  animated: boolean,
892
893
  ) => void;
893
894
 
894
895
  fitToCoordinates: (
895
- viewRef: React.ElementRef<React.ComponentType>,
896
+ viewRef: React.ElementRef<typeof GoogleMapView>,
896
897
  coordinatesJSON: string,
897
898
  edgePaddingJSON: string,
898
899
  animated: boolean,
899
900
  ) => void;
900
901
  setIndoorActiveLevelIndex: (
901
- viewRef: React.ElementRef<React.ComponentType>,
902
+ viewRef: React.ElementRef<typeof GoogleMapView>,
902
903
  activeLevelIndex: Int32,
903
904
  ) => void;
904
905
  }
@@ -11,6 +11,7 @@ import type {
11
11
  DirectEventHandler,
12
12
  BubblingEventHandler,
13
13
  } from 'react-native/Libraries/Types/CodegenTypes';
14
+ import FabricMapView from './NativeComponentMapView';
14
15
 
15
16
  export type EdgePadding = Readonly<{
16
17
  top: Double; // Non-nullable Double for top
@@ -1039,46 +1040,46 @@ export interface MapFabricNativeProps extends ViewProps {
1039
1040
  cameraZoomRange?: CameraZoomRange;
1040
1041
  }
1041
1042
 
1042
- export interface NativeCommands {
1043
+ interface NativeCommands {
1043
1044
  animateToRegion: (
1044
- viewRef: React.ElementRef<React.ComponentType>,
1045
+ viewRef: React.ElementRef<typeof FabricMapView>,
1045
1046
  regionJSON: string,
1046
1047
  duration: Int32,
1047
1048
  ) => void;
1048
1049
 
1049
1050
  setCamera: (
1050
- viewRef: React.ElementRef<React.ComponentType>,
1051
+ viewRef: React.ElementRef<typeof FabricMapView>,
1051
1052
  cameraJSON: string,
1052
1053
  ) => void;
1053
1054
 
1054
1055
  animateCamera: (
1055
- viewRef: React.ElementRef<React.ComponentType>,
1056
+ viewRef: React.ElementRef<typeof FabricMapView>,
1056
1057
  cameraJSON: string,
1057
1058
  duration: Int32,
1058
1059
  ) => void;
1059
1060
 
1060
1061
  fitToElements: (
1061
- viewRef: React.ElementRef<React.ComponentType>,
1062
+ viewRef: React.ElementRef<typeof FabricMapView>,
1062
1063
  edgePaddingJSON: string,
1063
1064
  animated: boolean,
1064
1065
  ) => void;
1065
1066
 
1066
1067
  fitToSuppliedMarkers: (
1067
- viewRef: React.ElementRef<React.ComponentType>,
1068
+ viewRef: React.ElementRef<typeof FabricMapView>,
1068
1069
  markersJSON: string,
1069
1070
  edgePaddingJSON: string,
1070
1071
  animated: boolean,
1071
1072
  ) => void;
1072
1073
 
1073
1074
  fitToCoordinates: (
1074
- viewRef: React.ElementRef<React.ComponentType>,
1075
+ viewRef: React.ElementRef<typeof FabricMapView>,
1075
1076
  coordinatesJSON: string,
1076
1077
  edgePaddingJSON: string,
1077
1078
  animated: boolean,
1078
1079
  ) => void;
1079
1080
 
1080
1081
  setIndoorActiveLevelIndex: (
1081
- viewRef: React.ElementRef<React.ComponentType>,
1082
+ viewRef: React.ElementRef<typeof FabricMapView>,
1082
1083
  activeLevelIndex: Int32,
1083
1084
  ) => void;
1084
1085
  }