react-native-maps 1.24.6 → 1.24.7
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/package.json +1 -1
- package/src/createFabricMap.tsx +21 -8
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.
|
|
8
|
+
"version": "1.24.7",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|
package/src/createFabricMap.tsx
CHANGED
|
@@ -42,16 +42,29 @@ export interface FabricMapHandle {
|
|
|
42
42
|
setIndoorActiveLevelIndex: (activeLevelIndex: number) => void;
|
|
43
43
|
}
|
|
44
44
|
|
|
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
|
+
|
|
45
58
|
const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
|
|
46
59
|
return forwardRef<FabricMapHandle | null, FabricMapViewProps>(
|
|
47
60
|
(props, ref) => {
|
|
48
|
-
const fabricRef = useRef<React.
|
|
61
|
+
const fabricRef = useRef<React.ComponentRef<typeof ViewComponent>>(null);
|
|
49
62
|
|
|
50
63
|
useImperativeHandle(ref, () => ({
|
|
51
64
|
async getMarkersFrames(onlyVisible: boolean) {
|
|
52
65
|
if (fabricRef.current) {
|
|
53
66
|
return NativeAirMapsModule.getMarkersFrames(
|
|
54
|
-
|
|
67
|
+
getNodeHandle(fabricRef.current) ?? -1,
|
|
55
68
|
onlyVisible,
|
|
56
69
|
);
|
|
57
70
|
} else {
|
|
@@ -63,7 +76,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
|
|
|
63
76
|
async getCoordinateForPoint(point: Point) {
|
|
64
77
|
if (fabricRef.current) {
|
|
65
78
|
return NativeAirMapsModule.getCoordinateForPoint(
|
|
66
|
-
|
|
79
|
+
getNodeHandle(fabricRef.current) ?? -1,
|
|
67
80
|
point,
|
|
68
81
|
);
|
|
69
82
|
} else {
|
|
@@ -75,7 +88,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
|
|
|
75
88
|
async getPointForCoordinate(coordinate: LatLng) {
|
|
76
89
|
if (fabricRef.current) {
|
|
77
90
|
return NativeAirMapsModule.getPointForCoordinate(
|
|
78
|
-
|
|
91
|
+
getNodeHandle(fabricRef.current) ?? -1,
|
|
79
92
|
coordinate,
|
|
80
93
|
);
|
|
81
94
|
} else {
|
|
@@ -87,7 +100,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
|
|
|
87
100
|
async getAddressFromCoordinates(coordinate: LatLng) {
|
|
88
101
|
if (fabricRef.current) {
|
|
89
102
|
return NativeAirMapsModule.getAddressFromCoordinates(
|
|
90
|
-
|
|
103
|
+
getNodeHandle(fabricRef.current) ?? -1,
|
|
91
104
|
coordinate,
|
|
92
105
|
);
|
|
93
106
|
} else {
|
|
@@ -99,7 +112,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
|
|
|
99
112
|
async takeSnapshot(config: SnapshotOptions) {
|
|
100
113
|
if (fabricRef.current) {
|
|
101
114
|
return NativeAirMapsModule.takeSnapshot(
|
|
102
|
-
|
|
115
|
+
getNodeHandle(fabricRef.current) ?? -1,
|
|
103
116
|
JSON.stringify(config),
|
|
104
117
|
);
|
|
105
118
|
} else {
|
|
@@ -111,7 +124,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
|
|
|
111
124
|
async getCamera() {
|
|
112
125
|
if (fabricRef.current) {
|
|
113
126
|
return NativeAirMapsModule.getCamera(
|
|
114
|
-
|
|
127
|
+
getNodeHandle(fabricRef.current) ?? -1,
|
|
115
128
|
);
|
|
116
129
|
} else {
|
|
117
130
|
throw new Error('getCamera is only supported on iOS with Fabric.');
|
|
@@ -120,7 +133,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
|
|
|
120
133
|
async getMapBoundaries() {
|
|
121
134
|
if (fabricRef.current) {
|
|
122
135
|
return NativeAirMapsModule.getMapBoundaries(
|
|
123
|
-
|
|
136
|
+
getNodeHandle(fabricRef.current) ?? -1,
|
|
124
137
|
);
|
|
125
138
|
} else {
|
|
126
139
|
throw new Error(
|