react-native-maps 1.20.1 → 1.21.0-alpha.10

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 (50) hide show
  1. package/README.md +13 -6
  2. package/android/build.gradle +19 -4
  3. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
  4. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
  5. package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
  6. package/ios/AirGoogleMaps/AIRGoogleMap.m +151 -7
  7. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  8. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
  9. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
  10. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
  11. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +28 -119
  12. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
  13. package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
  14. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +3 -3
  15. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +2 -2
  16. package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
  17. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
  18. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
  19. package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
  20. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  21. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +16 -0
  22. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
  23. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +581 -0
  24. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  25. package/ios/AirMaps/AIRMap.h +8 -5
  26. package/ios/AirMaps/AIRMap.m +180 -27
  27. package/ios/AirMaps/AIRMapManager.m +24 -39
  28. package/ios/AirMaps/AIRMapMarker.m +11 -3
  29. package/ios/AirMaps/RCTConvert+AirMap.h +6 -1
  30. package/ios/AirMaps/RCTConvert+AirMap.m +18 -0
  31. package/ios/AirMaps/RNMapsAirModule.h +16 -0
  32. package/ios/AirMaps/RNMapsAirModule.mm +149 -0
  33. package/ios/AirMaps/RNMapsMapView.h +24 -0
  34. package/ios/AirMaps/RNMapsMapView.mm +535 -0
  35. package/ios/AirMaps/RNMapsMapViewManager.mm +24 -0
  36. package/ios/AirMaps.xcodeproj/project.pbxproj +10 -0
  37. package/lib/MapOverlay.d.ts +1 -1
  38. package/lib/MapView.d.ts +8 -4
  39. package/lib/MapView.js +148 -73
  40. package/lib/createFabricMap.d.ts +23 -0
  41. package/lib/createFabricMap.js +175 -0
  42. package/lib/specs/NativeAirMapsModule.d.ts +31 -0
  43. package/lib/specs/NativeAirMapsModule.js +4 -0
  44. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  45. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  46. package/lib/specs/NativeComponentMapView.d.ts +855 -0
  47. package/lib/specs/NativeComponentMapView.js +21 -0
  48. package/package.json +14 -7
  49. package/react-native-maps.podspec +3 -1
  50. package/react-native-google-maps.podspec +0 -25
package/lib/MapView.js CHANGED
@@ -22,13 +22,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.AnimatedMapView = exports.MAP_TYPES = void 0;
27
30
  const React = __importStar(require("react"));
28
31
  const react_native_1 = require("react-native");
29
32
  const decorateMapComponent_1 = require("./decorateMapComponent");
30
- const ProviderConstants = __importStar(require("./ProviderConstants"));
31
33
  const MapViewNativeComponent_1 = require("./MapViewNativeComponent");
34
+ const NativeComponentMapView_1 = __importStar(require("./specs/NativeComponentMapView"));
35
+ const NativeComponentGoogleMapView_1 = __importStar(require("./specs/NativeComponentGoogleMapView"));
36
+ const createFabricMap_1 = __importDefault(require("./createFabricMap"));
37
+ const FabricMap = (0, createFabricMap_1.default)(NativeComponentMapView_1.default, NativeComponentMapView_1.Commands);
38
+ const FabricGoogleMap = (0, createFabricMap_1.default)(NativeComponentGoogleMapView_1.default, NativeComponentGoogleMapView_1.Commands);
32
39
  exports.MAP_TYPES = {
33
40
  STANDARD: 'standard',
34
41
  SATELLITE: 'satellite',
@@ -39,13 +46,14 @@ exports.MAP_TYPES = {
39
46
  SATELLITE_FLYOVER: 'satelliteFlyover',
40
47
  HYBRID_FLYOVER: 'hybridFlyover',
41
48
  };
42
- const GOOGLE_MAPS_ONLY_TYPES = [exports.MAP_TYPES.TERRAIN, exports.MAP_TYPES.NONE];
43
49
  class MapView extends React.Component {
44
50
  static Animated;
45
51
  map;
52
+ fabricMap;
46
53
  constructor(props) {
47
54
  super(props);
48
55
  this.map = React.createRef();
56
+ this.fabricMap = React.createRef();
49
57
  this.state = {
50
58
  isReady: react_native_1.Platform.OS === 'ios',
51
59
  };
@@ -81,40 +89,60 @@ class MapView extends React.Component {
81
89
  return react_native_1.NativeModules.AirMapModule.getCamera(this._getHandle());
82
90
  }
83
91
  else if (react_native_1.Platform.OS === 'ios') {
84
- return this._runCommand('getCamera', []);
92
+ if (this.fabricMap.current) {
93
+ return this.fabricMap.current.getCamera();
94
+ }
85
95
  }
86
96
  return Promise.reject('getCamera not supported on this platform');
87
97
  }
88
98
  setCamera(camera) {
89
- if (this.map.current) {
99
+ if (this.fabricMap.current) {
100
+ this.fabricMap.current.setCamera(camera);
101
+ }
102
+ else if (this.map.current) {
90
103
  MapViewNativeComponent_1.Commands.setCamera(this.map.current, camera);
91
104
  }
92
105
  }
93
106
  animateCamera(camera, opts) {
94
- if (this.map.current) {
107
+ if (this.fabricMap.current) {
108
+ this.fabricMap.current.animateCamera(camera, opts?.duration ? opts.duration : 500);
109
+ }
110
+ else if (this.map.current) {
95
111
  MapViewNativeComponent_1.Commands.animateCamera(this.map.current, camera, opts?.duration ? opts.duration : 500);
96
112
  }
97
113
  }
98
114
  animateToRegion(region, duration = 500) {
99
- if (this.map.current) {
115
+ if (this.fabricMap.current) {
116
+ this.fabricMap.current.animateToRegion(region, duration);
117
+ }
118
+ else if (this.map.current) {
100
119
  MapViewNativeComponent_1.Commands.animateToRegion(this.map.current, region, duration);
101
120
  }
102
121
  }
103
122
  fitToElements(options = {}) {
104
- if (this.map.current) {
105
- const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
123
+ const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
124
+ if (this.fabricMap.current) {
125
+ this.fabricMap.current.fitToElements(edgePadding, animated);
126
+ }
127
+ else if (this.map.current) {
106
128
  MapViewNativeComponent_1.Commands.fitToElements(this.map.current, edgePadding, animated);
107
129
  }
108
130
  }
109
131
  fitToSuppliedMarkers(markers, options = {}) {
110
- if (this.map.current) {
111
- const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
132
+ const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
133
+ if (this.fabricMap.current) {
134
+ this.fabricMap.current.fitToSuppliedMarkers(markers, edgePadding, animated);
135
+ }
136
+ else if (this.map.current) {
112
137
  MapViewNativeComponent_1.Commands.fitToSuppliedMarkers(this.map.current, markers, edgePadding, animated);
113
138
  }
114
139
  }
115
140
  fitToCoordinates(coordinates = [], options = {}) {
116
- if (this.map.current) {
117
- const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
141
+ const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
142
+ if (this.fabricMap.current) {
143
+ this.fabricMap.current.fitToCoordinates(coordinates, edgePadding, animated);
144
+ }
145
+ else if (this.map.current) {
118
146
  MapViewNativeComponent_1.Commands.fitToCoordinates(this.map.current, coordinates, edgePadding, animated);
119
147
  }
120
148
  }
@@ -128,7 +156,9 @@ class MapView extends React.Component {
128
156
  return await react_native_1.NativeModules.AirMapModule.getMapBoundaries(this._getHandle());
129
157
  }
130
158
  else if (react_native_1.Platform.OS === 'ios') {
131
- return await this._runCommand('getMapBoundaries', []);
159
+ if (this.fabricMap.current) {
160
+ return this.fabricMap.current.getMapBoundaries();
161
+ }
132
162
  }
133
163
  return Promise.reject('getMapBoundaries not supported on this platform');
134
164
  }
@@ -177,24 +207,10 @@ class MapView extends React.Component {
177
207
  return react_native_1.NativeModules.AirMapModule.takeSnapshot(this._getHandle(), config);
178
208
  }
179
209
  else if (react_native_1.Platform.OS === 'ios') {
180
- return new Promise((resolve, reject) => {
181
- this._runCommand('takeSnapshot', [
182
- config.width,
183
- config.height,
184
- config.region,
185
- config.format,
186
- config.quality,
187
- config.result,
188
- (err, snapshot) => {
189
- if (err) {
190
- reject(err);
191
- }
192
- else {
193
- resolve(snapshot);
194
- }
195
- },
196
- ]);
197
- });
210
+ if (this.fabricMap.current) {
211
+ // @ts-ignore
212
+ return this.fabricMap.current.takeSnapshot(config);
213
+ }
198
214
  }
199
215
  return Promise.reject('takeSnapshot not supported on this platform');
200
216
  }
@@ -212,7 +228,9 @@ class MapView extends React.Component {
212
228
  return react_native_1.NativeModules.AirMapModule.getAddressFromCoordinates(this._getHandle(), coordinate);
213
229
  }
214
230
  else if (react_native_1.Platform.OS === 'ios') {
215
- return this._runCommand('getAddressFromCoordinates', [coordinate]);
231
+ if (this.fabricMap.current) {
232
+ return this.fabricMap.current.getAddressFromCoordinates(coordinate);
233
+ }
216
234
  }
217
235
  return Promise.reject('getAddress not supported on this platform');
218
236
  }
@@ -230,7 +248,9 @@ class MapView extends React.Component {
230
248
  return react_native_1.NativeModules.AirMapModule.pointForCoordinate(this._getHandle(), coordinate);
231
249
  }
232
250
  else if (react_native_1.Platform.OS === 'ios') {
233
- return this._runCommand('pointForCoordinate', [coordinate]);
251
+ if (this.fabricMap.current) {
252
+ return this.fabricMap.current.getPointForCoordinate(coordinate);
253
+ }
234
254
  }
235
255
  return Promise.reject('pointForCoordinate not supported on this platform');
236
256
  }
@@ -248,7 +268,9 @@ class MapView extends React.Component {
248
268
  return react_native_1.NativeModules.AirMapModule.coordinateForPoint(this._getHandle(), point);
249
269
  }
250
270
  else if (react_native_1.Platform.OS === 'ios') {
251
- return this._runCommand('coordinateForPoint', [point]);
271
+ if (this.fabricMap.current) {
272
+ return this.fabricMap.current.getCoordinateForPoint(point);
273
+ }
252
274
  }
253
275
  return Promise.reject('coordinateForPoint not supported on this platform');
254
276
  }
@@ -261,7 +283,10 @@ class MapView extends React.Component {
261
283
  */
262
284
  getMarkersFrames(onlyVisible = false) {
263
285
  if (react_native_1.Platform.OS === 'ios') {
264
- return this._runCommand('getMarkersFrames', [onlyVisible]);
286
+ if (this.fabricMap.current) {
287
+ // @ts-ignore
288
+ return this.fabricMap.current.getMarkersFrames(onlyVisible);
289
+ }
265
290
  }
266
291
  return Promise.reject('getMarkersFrames not supported on this platform');
267
292
  }
@@ -284,69 +309,119 @@ class MapView extends React.Component {
284
309
  },
285
310
  };
286
311
  }
287
- _mapManagerCommand(name) {
288
- return react_native_1.NativeModules[`${(0, decorateMapComponent_1.getNativeMapName)(this.props.provider)}Manager`][name];
289
- }
290
312
  _getHandle() {
291
313
  return (0, react_native_1.findNodeHandle)(this.map.current);
292
314
  }
293
- _runCommand(name, args) {
294
- if (react_native_1.Platform.OS === 'ios') {
295
- return this._mapManagerCommand(name)(this._getHandle(), ...args);
315
+ handleMapPress = (event) => {
316
+ if (this.props.onPress) {
317
+ this.props.onPress(event);
296
318
  }
297
- else {
298
- return Promise.reject(`Invalid platform was passed: ${react_native_1.Platform.OS}`);
319
+ };
320
+ handleMarkerPress = (event) => {
321
+ if (this.props.onMarkerPress) {
322
+ this.props.onMarkerPress(event);
299
323
  }
300
- }
324
+ };
325
+ handleMarkerSelect = (event) => {
326
+ if (this.props.onMarkerSelect) {
327
+ this.props.onMarkerSelect(event);
328
+ }
329
+ };
330
+ handleMarkerDeselect = (event) => {
331
+ if (this.props.onMarkerDeselect) {
332
+ this.props.onMarkerDeselect(event);
333
+ }
334
+ };
335
+ handleRegionChange = (event) => {
336
+ const isGesture = event.nativeEvent.isGesture;
337
+ const details = { isGesture };
338
+ if (event.nativeEvent.continuous) {
339
+ if (this.props.onRegionChange) {
340
+ this.props.onRegionChange(event.nativeEvent.region, details);
341
+ }
342
+ }
343
+ else if (this.props.onRegionChangeComplete) {
344
+ this.props.onRegionChangeComplete(event.nativeEvent.region, details);
345
+ }
346
+ };
301
347
  render() {
302
- let props;
303
- if (this.state.isReady) {
304
- props = {
305
- region: null,
306
- initialRegion: null,
307
- onChange: this._onChange,
348
+ if (react_native_1.Platform.OS === 'ios') {
349
+ // Define props specifically for MapFabricNativeProps
350
+ /* eslint-disable @typescript-eslint/no-unused-vars */
351
+ const { onCalloutPress, onIndoorBuildingFocused, onKmlReady, onLongPress, onMarkerDeselect, onMarkerPress, onMarkerSelect, onRegionChangeStart, onRegionChange, onRegionChangeComplete, onPress, minZoomLevel, maxZoomLevel, region, provider, ...restProps } = this.props;
352
+ /* eslint-enable @typescript-eslint/no-unused-vars */
353
+ const userInterfaceStyle = this.props.userInterfaceStyle || 'system';
354
+ const props = {
308
355
  onMapReady: this._onMapReady,
309
356
  liteMode: this.props.liteMode,
310
357
  googleMapId: this.props.googleMapId,
311
358
  googleRenderer: this.props.googleRenderer,
312
- ref: this.map,
313
- customMapStyleString: this.props.customMapStyle
314
- ? JSON.stringify(this.props.customMapStyle)
315
- : undefined,
316
- ...this.props,
359
+ onPress: this.handleMapPress,
360
+ onMarkerPress: this.handleMarkerPress,
361
+ onMarkerSelect: this.handleMarkerSelect,
362
+ onMarkerDeselect: this.handleMarkerDeselect,
363
+ userInterfaceStyle: userInterfaceStyle,
364
+ minZoom: minZoomLevel,
365
+ maxZoom: maxZoomLevel,
366
+ onRegionChange: this.handleRegionChange,
367
+ ...restProps,
317
368
  };
318
- if (react_native_1.Platform.OS === 'ios' &&
319
- props.provider === ProviderConstants.PROVIDER_DEFAULT &&
320
- props.mapType &&
321
- GOOGLE_MAPS_ONLY_TYPES.includes(props.mapType)) {
322
- props.mapType = exports.MAP_TYPES.STANDARD;
369
+ if (this.props.region) {
370
+ props.region = {
371
+ latitude: this.props.region.latitude,
372
+ longitude: this.props.region.longitude,
373
+ latitudeDelta: this.props.region.latitudeDelta,
374
+ longitudeDelta: this.props.region.longitudeDelta,
375
+ };
376
+ }
377
+ if (!this.state.isReady) {
378
+ props.style = this.props.style;
379
+ props.initialCamera = this.props.initialCamera;
380
+ props.onLayout = this.props.onLayout;
323
381
  }
324
- if (props.onPanDrag) {
325
- props.handlePanDrag = !!props.onPanDrag;
382
+ if (provider === 'google') {
383
+ return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
384
+ <FabricGoogleMap {...props} ref={this.fabricMap}/>
385
+ </decorateMapComponent_1.ProviderContext.Provider>);
386
+ }
387
+ else {
388
+ return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
389
+ <FabricMap {...props} ref={this.fabricMap}/>
390
+ </decorateMapComponent_1.ProviderContext.Provider>);
326
391
  }
327
392
  }
328
393
  else {
329
- props = {
330
- style: this.props.style,
394
+ const AIRMap = getNativeMapComponent(this.props.provider);
395
+ // Define props specifically for NativeProps
396
+ const props = {
331
397
  region: null,
398
+ initialRegion: null,
399
+ onChange: this._onChange,
400
+ onMapReady: this._onMapReady,
332
401
  liteMode: this.props.liteMode,
333
402
  googleMapId: this.props.googleMapId,
334
403
  googleRenderer: this.props.googleRenderer,
335
- initialRegion: this.props.initialRegion || null,
336
- initialCamera: this.props.initialCamera,
337
404
  ref: this.map,
338
- onChange: this._onChange,
339
- onMapReady: this._onMapReady,
340
- onLayout: this.props.onLayout,
341
405
  customMapStyleString: this.props.customMapStyle
342
406
  ? JSON.stringify(this.props.customMapStyle)
343
407
  : undefined,
408
+ ...this.props,
344
409
  };
410
+ if (this.state.isReady) {
411
+ if (props.onPanDrag) {
412
+ props.handlePanDrag = !!props.onPanDrag;
413
+ }
414
+ }
415
+ else {
416
+ props.style = this.props.style;
417
+ props.initialCamera = this.props.initialCamera;
418
+ props.onLayout = this.props.onLayout;
419
+ }
420
+ // Render AIRMap with NativeProps
421
+ return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
422
+ <AIRMap {...props}/>
423
+ </decorateMapComponent_1.ProviderContext.Provider>);
345
424
  }
346
- const AIRMap = getNativeMapComponent(this.props.provider);
347
- return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
348
- <AIRMap {...props}/>
349
- </decorateMapComponent_1.ProviderContext.Provider>);
350
425
  }
351
426
  }
352
427
  const airMaps = {
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { LatLng, Point, Region } from './sharedTypes';
3
+ import type { Address, Camera, EdgePadding, SnapshotOptions } from './MapView.types';
4
+ import { MapBoundaries } from './specs/NativeAirMapsModule';
5
+ import { MapFabricNativeProps } from './specs/NativeComponentMapView';
6
+ export type FabricMapViewProps = MapFabricNativeProps;
7
+ export interface FabricMapHandle {
8
+ getCamera: () => Promise<Camera>;
9
+ setCamera: (camera: Partial<Camera>) => void;
10
+ animateToRegion: (region: Region, duration: number) => void;
11
+ animateCamera: (camera: Partial<Camera>, duration: number) => void;
12
+ getMarkersFrames: (onlyVisible: boolean) => Promise<unknown>;
13
+ fitToElements: (edgePadding: EdgePadding, animated: boolean) => void;
14
+ fitToSuppliedMarkers: (markers: string[], edgePadding: EdgePadding, animated: boolean) => void;
15
+ fitToCoordinates: (coordinates: LatLng[], edgePadding: EdgePadding, animated: boolean) => void;
16
+ getMapBoundaries: () => Promise<MapBoundaries>;
17
+ takeSnapshot: (config: SnapshotOptions) => Promise<string>;
18
+ getAddressFromCoordinates: (coordinate: LatLng) => Promise<Address>;
19
+ getPointForCoordinate: (coordinate: LatLng) => Promise<Point>;
20
+ getCoordinateForPoint: (point: Point) => Promise<LatLng>;
21
+ }
22
+ declare const createFabricMap: (ViewComponent: React.ComponentType, Commands: any) => React.ForwardRefExoticComponent<MapFabricNativeProps & React.RefAttributes<FabricMapHandle>>;
23
+ export default createFabricMap;
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importStar(require("react"));
30
+ const react_native_1 = require("react-native");
31
+ const NativeAirMapsModule_1 = __importDefault(require("./specs/NativeAirMapsModule"));
32
+ const createFabricMap = (ViewComponent, Commands) => {
33
+ return (0, react_1.forwardRef)((props, ref) => {
34
+ const fabricRef = (0, react_1.useRef)(null);
35
+ (0, react_1.useImperativeHandle)(ref, () => ({
36
+ async getMarkersFrames(onlyVisible) {
37
+ if (fabricRef.current) {
38
+ return NativeAirMapsModule_1.default.getMarkersFrames((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, onlyVisible);
39
+ }
40
+ else {
41
+ throw new Error('getMarkersFrames is only supported on iOS with Fabric.');
42
+ }
43
+ },
44
+ async getCoordinateForPoint(point) {
45
+ if (fabricRef.current) {
46
+ return NativeAirMapsModule_1.default.getCoordinateForPoint((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, point);
47
+ }
48
+ else {
49
+ throw new Error('getCoordinateForPoint is only supported on iOS with Fabric.');
50
+ }
51
+ },
52
+ async getPointForCoordinate(coordinate) {
53
+ if (fabricRef.current) {
54
+ return NativeAirMapsModule_1.default.getPointForCoordinate((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, coordinate);
55
+ }
56
+ else {
57
+ throw new Error('getPointForCoordinate is only supported on iOS with Fabric.');
58
+ }
59
+ },
60
+ async getAddressFromCoordinates(coordinate) {
61
+ if (fabricRef.current) {
62
+ return NativeAirMapsModule_1.default.getAddressFromCoordinates((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, coordinate);
63
+ }
64
+ else {
65
+ throw new Error('getAddressFromCoordinates is only supported on iOS with Fabric.');
66
+ }
67
+ },
68
+ async takeSnapshot(config) {
69
+ if (fabricRef.current) {
70
+ return NativeAirMapsModule_1.default.takeSnapshot((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, config);
71
+ }
72
+ else {
73
+ throw new Error('takeSnapshot is only supported on iOS with Fabric.');
74
+ }
75
+ },
76
+ async getCamera() {
77
+ if (fabricRef.current) {
78
+ return NativeAirMapsModule_1.default.getCamera((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1);
79
+ }
80
+ else {
81
+ throw new Error('getCamera is only supported on iOS with Fabric.');
82
+ }
83
+ },
84
+ async getMapBoundaries() {
85
+ if (fabricRef.current) {
86
+ return NativeAirMapsModule_1.default.getMapBoundaries((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1);
87
+ }
88
+ else {
89
+ throw new Error('getMapBoundaries is only supported on iOS with Fabric.');
90
+ }
91
+ },
92
+ animateToRegion(region, duration) {
93
+ if (fabricRef.current) {
94
+ try {
95
+ Commands.animateToRegion(fabricRef.current, JSON.stringify(region), duration);
96
+ }
97
+ catch (error) {
98
+ throw new Error('Failed to animateToRegion');
99
+ }
100
+ }
101
+ else {
102
+ throw new Error('animateToRegion is only supported on iOS with Fabric.');
103
+ }
104
+ },
105
+ fitToElements(edgePadding, animated) {
106
+ if (fabricRef.current) {
107
+ try {
108
+ Commands.fitToElements(fabricRef.current, JSON.stringify(edgePadding), animated);
109
+ }
110
+ catch (error) {
111
+ throw new Error('Failed to fitToElements');
112
+ }
113
+ }
114
+ else {
115
+ throw new Error('fitToElements is only supported on iOS with Fabric.');
116
+ }
117
+ },
118
+ fitToSuppliedMarkers(markers, edgePadding, animated) {
119
+ if (fabricRef.current) {
120
+ try {
121
+ Commands.fitToSuppliedMarkers(fabricRef.current, JSON.stringify(markers), JSON.stringify(edgePadding), animated);
122
+ }
123
+ catch (error) {
124
+ throw new Error('Failed to fitToSuppliedMarkers');
125
+ }
126
+ }
127
+ else {
128
+ throw new Error('fitToSuppliedMarkers is only supported on iOS with Fabric.');
129
+ }
130
+ },
131
+ animateCamera(camera, duration) {
132
+ if (fabricRef.current) {
133
+ try {
134
+ Commands.animateCamera(fabricRef.current, JSON.stringify(camera), duration);
135
+ }
136
+ catch (error) {
137
+ throw new Error('Failed to animateCamera');
138
+ }
139
+ }
140
+ else {
141
+ throw new Error('animateCamera is only supported on iOS with Fabric.');
142
+ }
143
+ },
144
+ fitToCoordinates(coordinates, edgePadding, animated) {
145
+ if (fabricRef.current) {
146
+ try {
147
+ Commands.fitToCoordinates(fabricRef.current, JSON.stringify(coordinates), JSON.stringify(edgePadding), animated);
148
+ }
149
+ catch (error) {
150
+ throw new Error('Failed to fitToCoordinates');
151
+ }
152
+ }
153
+ else {
154
+ throw new Error('fitToCoordinates is only supported on iOS with Fabric.');
155
+ }
156
+ },
157
+ setCamera(camera) {
158
+ if (fabricRef.current) {
159
+ try {
160
+ Commands.setCamera(fabricRef.current, JSON.stringify(camera));
161
+ }
162
+ catch (error) {
163
+ console.error('Failed to set camera:', error);
164
+ }
165
+ }
166
+ else {
167
+ console.warn('setCamera is only supported on iOS with Fabric.');
168
+ }
169
+ },
170
+ }));
171
+ // @ts-ignore
172
+ return <ViewComponent {...props} ref={fabricRef}/>;
173
+ });
174
+ };
175
+ exports.default = createFabricMap;
@@ -0,0 +1,31 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import type { Double, UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
3
+ import type { Camera } from './NativeComponentMapView';
4
+ import { Address } from 'react-native-maps';
5
+ type LatLng = {
6
+ latitude: Double;
7
+ longitude: Double;
8
+ };
9
+ type Point = Readonly<{
10
+ x: Double;
11
+ y: Double;
12
+ }>;
13
+ export type Region = Readonly<LatLng & {
14
+ latitudeDelta: Double;
15
+ longitudeDelta: Double;
16
+ }>;
17
+ export type MapBoundaries = {
18
+ northEast: LatLng;
19
+ southWest: LatLng;
20
+ };
21
+ export interface Spec extends TurboModule {
22
+ getCamera(tag: Double): Promise<Camera>;
23
+ getMarkersFrames(tag: Double, onlyVisible: boolean): Promise<unknown>;
24
+ getMapBoundaries(tag: Double): Promise<MapBoundaries>;
25
+ takeSnapshot(tag: Double, config: UnsafeObject): Promise<string>;
26
+ getAddressFromCoordinates(tag: Double, coordinate: LatLng): Promise<Address>;
27
+ getPointForCoordinate(tag: Double, coordinate: LatLng): Promise<Point>;
28
+ getCoordinateForPoint(tag: Double, point: Point): Promise<LatLng>;
29
+ }
30
+ declare const _default: Spec;
31
+ export default _default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_native_1 = require("react-native");
4
+ exports.default = react_native_1.TurboModuleRegistry.getEnforcing('RNMapsAirModule');