MCPcopy Create free account
hub / github.com/react-native-maps/react-native-maps / createFabricMap

Function createFabricMap

src/createFabricMap.tsx:51–253  ·  view source on GitHub ↗
(
  ViewComponent: typeof GoogleMapView | typeof FabricMapView,
  Commands: typeof FabricCommands | typeof GoogleCommands,
)

Source from the content-addressed store, hash-verified

49}
50
51const 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;
61
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 },

Callers 1

MapView.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…