react-native-maps 1.25.0-alpha.8 → 1.25.1

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 (86) hide show
  1. package/README.md +2 -53
  2. package/android/src/main/RCTThirdPartyComponentsProvider.mm +0 -2
  3. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java +1 -1
  4. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerDelegate.java +3 -0
  5. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerInterface.java +1 -0
  6. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +6 -0
  7. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +2 -0
  8. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerDelegate.java +1 -1
  9. package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +1 -1
  10. package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +41 -5
  11. package/android/src/main/java/com/rnmaps/fabric/PolygonManager.java +9 -2
  12. package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +1 -2
  13. package/android/src/main/java/com/rnmaps/maps/MapMarker.java +46 -3
  14. package/android/src/main/java/com/rnmaps/maps/MapPolyline.java +8 -1
  15. package/android/src/main/java/com/rnmaps/maps/MapView.java +104 -51
  16. package/android/src/main/java/com/rnmaps/maps/MapsPackage.java +84 -27
  17. package/android/src/main/java/com/rnmaps/maps/RegionChangeEvent.java +1 -4
  18. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +6 -6
  19. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +6 -6
  20. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.cpp +5 -2
  21. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +27 -2
  22. package/ios/AirGoogleMaps/AIRGoogleMap.mm +13 -12
  23. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +4 -0
  24. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +3 -3
  25. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +6 -6
  26. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +4 -4
  27. package/ios/AirMaps/AIRMap.h +2 -1
  28. package/ios/AirMaps/AIRMapManager.m +34 -18
  29. package/ios/AirMaps/AIRMapMarker.m +7 -1
  30. package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.mm +2 -2
  31. package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.mm +1 -1
  32. package/ios/AirMaps/RNMapsAirModule.mm +3 -3
  33. package/ios/AirMaps/RNMapsMapView.h +4 -4
  34. package/ios/AirMaps/RNMapsMapView.mm +55 -10
  35. package/ios/AirMaps/RNMapsMapViewManager.mm +1 -1
  36. package/ios/AirMaps/RNMapsMarkerView.mm +4 -3
  37. package/ios/generated/RNMapsAirModuleDelegate.h +1 -1
  38. package/ios/generated/{RNMapsHostVewDelegate.h → RNMapsHostViewDelegate.h} +1 -1
  39. package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +2 -0
  40. package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +2 -0
  41. package/ios/generated/RNMapsSpecs/EventEmitters.cpp +8 -6
  42. package/ios/generated/RNMapsSpecs/EventEmitters.h +20 -6
  43. package/ios/generated/RNMapsSpecs/Props.cpp +37 -2
  44. package/ios/generated/RNMapsSpecs/Props.h +110 -13
  45. package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +2 -0
  46. package/ios/generated/RNMapsSpecs/ShadowNodes.h +22 -0
  47. package/ios/generated/RNMapsSpecs/States.h +24 -0
  48. package/ios/generated/module.modulemap +1 -1
  49. package/package.json +9 -3
  50. package/plugin/build/ios.js +3 -3
  51. package/src/AnimatedRegion.ts +3 -1
  52. package/src/Geojson.tsx +5 -5
  53. package/src/MapCallout.tsx +5 -5
  54. package/src/MapCalloutSubview.tsx +9 -5
  55. package/src/MapCircle.tsx +5 -5
  56. package/src/MapHeatmap.tsx +11 -6
  57. package/src/MapLocalTile.tsx +4 -4
  58. package/src/MapMarker.tsx +38 -17
  59. package/src/MapMarkerNativeComponent.ts +3 -2
  60. package/src/MapOverlay.tsx +10 -10
  61. package/src/MapPolygon.tsx +6 -6
  62. package/src/MapPolygon.types.ts +2 -2
  63. package/src/MapPolyline.tsx +5 -5
  64. package/src/MapUrlTile.tsx +4 -4
  65. package/src/MapView.tsx +34 -37
  66. package/src/MapView.types.ts +2 -3
  67. package/src/MapViewNativeComponent.ts +3 -3
  68. package/src/MapWMSTile.tsx +4 -4
  69. package/src/createFabricMap.tsx +39 -37
  70. package/src/decorateMapComponent.ts +9 -3
  71. package/src/fixImageProp.ts +1 -1
  72. package/src/index.ts +1 -1
  73. package/src/sharedTypes.ts +1 -1
  74. package/src/specs/NativeAirMapsModule.ts +1 -1
  75. package/src/specs/NativeComponentCallout.ts +1 -1
  76. package/src/specs/NativeComponentCircle.ts +3 -2
  77. package/src/specs/NativeComponentGoogleMapView.ts +12 -10
  78. package/src/specs/NativeComponentGooglePolygon.ts +12 -1
  79. package/src/specs/NativeComponentMapView.ts +12 -10
  80. package/src/specs/NativeComponentMarker.ts +26 -2
  81. package/src/specs/NativeComponentOverlay.ts +1 -1
  82. package/src/specs/NativeComponentPolyline.ts +2 -2
  83. package/src/specs/NativeComponentUrlTile.ts +4 -1
  84. package/src/specs/NativeComponentWMSTile.ts +4 -1
  85. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +0 -98
  86. package/ios/AirMaps.xcodeproj/project.pbxproj +0 -627
@@ -1,15 +1,20 @@
1
1
  import * as React from 'react';
2
- import {processColor, ProcessedColorValue, View, ViewProps} from 'react-native';
2
+ import {
3
+ processColor,
4
+ View,
5
+ type ProcessedColorValue,
6
+ type ViewProps,
7
+ } from 'react-native';
3
8
  import decorateMapComponent, {
4
- MapManagerCommand,
5
- NativeComponent,
6
9
  ProviderContext,
7
10
  SUPPORTED,
8
- UIManagerCommand,
9
11
  USES_DEFAULT_IMPLEMENTATION,
12
+ type MapManagerCommand,
13
+ type NativeComponent,
14
+ type UIManagerCommand,
10
15
  } from './decorateMapComponent';
11
- import {LatLng} from './sharedTypes';
12
- import {Modify} from './sharedTypesInternal';
16
+ import type {LatLng} from './sharedTypes';
17
+ import type {Modify} from './sharedTypesInternal';
13
18
 
14
19
  export type MapHeatmapProps = ViewProps & {
15
20
  gradient?: {
@@ -1,13 +1,13 @@
1
1
  import * as React from 'react';
2
- import {ViewProps} from 'react-native';
2
+ import type {ViewProps} from 'react-native';
3
3
 
4
4
  import decorateMapComponent, {
5
5
  USES_DEFAULT_IMPLEMENTATION,
6
6
  SUPPORTED,
7
7
  ProviderContext,
8
- NativeComponent,
9
- MapManagerCommand,
10
- UIManagerCommand,
8
+ type NativeComponent,
9
+ type MapManagerCommand,
10
+ type UIManagerCommand,
11
11
  } from './decorateMapComponent';
12
12
 
13
13
  export type MapLocalTileProps = ViewProps & {
package/src/MapMarker.tsx CHANGED
@@ -2,29 +2,29 @@ import * as React from 'react';
2
2
  import {
3
3
  StyleSheet,
4
4
  Animated,
5
- ViewProps,
6
- ImageURISource,
7
- ImageRequireSource,
8
5
  Platform,
6
+ type ViewProps,
7
+ type ImageURISource,
8
+ type ImageRequireSource,
9
9
  } from 'react-native';
10
10
 
11
11
  import decorateMapComponent, {
12
- MapManagerCommand,
13
- NativeComponent,
14
12
  ProviderContext,
15
13
  SUPPORTED,
16
- UIManagerCommand,
17
14
  USES_DEFAULT_IMPLEMENTATION,
15
+ type MapManagerCommand,
16
+ type NativeComponent,
17
+ type UIManagerCommand,
18
18
  } from './decorateMapComponent';
19
19
  import {
20
20
  Commands,
21
- MapMarkerNativeComponentType,
21
+ type MapMarkerNativeComponentType,
22
22
  } from './MapMarkerNativeComponent';
23
23
 
24
24
  import {Commands as FabricCommands} from './specs/NativeComponentMarker';
25
25
  import type {AppleMarkerPriority} from './specs/NativeComponentMarker';
26
26
 
27
- import {
27
+ import type {
28
28
  CalloutPressEvent,
29
29
  LatLng,
30
30
  MarkerDeselectEvent,
@@ -34,7 +34,7 @@ import {
34
34
  MarkerSelectEvent,
35
35
  Point,
36
36
  } from './sharedTypes';
37
- import {Modify} from './sharedTypesInternal';
37
+ import type {Modify} from './sharedTypesInternal';
38
38
 
39
39
  import {PROVIDER_GOOGLE} from './ProviderConstants';
40
40
  import {fixImageProp} from './fixImageProp';
@@ -468,7 +468,12 @@ export class MapMarker extends React.Component<MapMarkerProps> {
468
468
 
469
469
  redraw() {
470
470
  if (this.marker.current) {
471
- Commands.redraw(this.marker.current);
471
+ if (this.fabricMarker) {
472
+ // @ts-ignore
473
+ FabricCommands.redraw(this.marker.current);
474
+ } else {
475
+ Commands.redraw(this.marker.current);
476
+ }
472
477
  }
473
478
  }
474
479
 
@@ -481,13 +486,29 @@ export class MapMarker extends React.Component<MapMarkerProps> {
481
486
  );
482
487
  }
483
488
 
484
- let icon;
485
- if (this.props.icon && this.fabricMarker) {
486
- icon = fixImageProp(this.props.icon);
487
- }
488
- let image;
489
- if (this.props.image && this.fabricMarker) {
490
- image = fixImageProp(this.props.image);
489
+ let icon: any = this.props.icon;
490
+ let image: any = this.props.image;
491
+
492
+ if (this.fabricMarker) {
493
+ if (this.props.image) {
494
+ image = fixImageProp(this.props.image);
495
+ }
496
+ if (this.props.icon) {
497
+ icon = fixImageProp(this.props.icon);
498
+ }
499
+ } else {
500
+ if (this.props.image) {
501
+ image = fixImageProp(this.props.image);
502
+ if (image.uri) {
503
+ image = image.uri;
504
+ }
505
+ }
506
+ if (this.props.icon) {
507
+ icon = fixImageProp(this.props.icon);
508
+ if (icon.uri) {
509
+ icon = icon.uri;
510
+ }
511
+ }
491
512
  }
492
513
 
493
514
  const AIRMapMarker = this.getNativeComponent();
@@ -1,7 +1,7 @@
1
1
  import type {HostComponent} from 'react-native';
2
2
  import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
3
- import {NativeProps} from './MapMarker';
4
- import {LatLng} from './sharedTypes';
3
+ import type {NativeProps} from './MapMarker';
4
+ import type {LatLng} from './sharedTypes';
5
5
 
6
6
  export type MapMarkerNativeComponentType = HostComponent<NativeProps>;
7
7
 
@@ -47,5 +47,6 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
47
47
  'hideCallout',
48
48
  'animateMarkerToCoordinate',
49
49
  'setCoordinates',
50
+ 'redraw',
50
51
  ],
51
52
  });
@@ -2,23 +2,23 @@ import * as React from 'react';
2
2
  import {
3
3
  StyleSheet,
4
4
  Animated,
5
- ViewProps,
6
- ImageURISource,
7
- ImageRequireSource,
8
- NativeSyntheticEvent,
9
5
  Platform,
6
+ type ViewProps,
7
+ type ImageURISource,
8
+ type ImageRequireSource,
9
+ type NativeSyntheticEvent,
10
10
  } from 'react-native';
11
11
 
12
12
  import decorateMapComponent, {
13
- MapManagerCommand,
14
- NativeComponent,
15
13
  ProviderContext,
16
14
  SUPPORTED,
17
- UIManagerCommand,
18
15
  USES_DEFAULT_IMPLEMENTATION,
16
+ type MapManagerCommand,
17
+ type NativeComponent,
18
+ type UIManagerCommand,
19
19
  } from './decorateMapComponent';
20
- import {LatLng, Point} from './sharedTypes';
21
- import {Modify} from './sharedTypesInternal';
20
+ import type {LatLng, Point} from './sharedTypes';
21
+ import type {Modify} from './sharedTypesInternal';
22
22
  import {fixImageProp} from './fixImageProp';
23
23
 
24
24
  export type MapOverlayProps = ViewProps & {
@@ -32,7 +32,7 @@ export type MapOverlayProps = ViewProps & {
32
32
  bearing?: number;
33
33
 
34
34
  /**
35
- * The coordinates for the image (left-top corner, right-bottom corner). ie.```[[lat, long], [lat, long]]```
35
+ * The coordinates for the image (right-top corner, left-bottom corner). ie.```[[lat, long], [lat, long]]```
36
36
  *
37
37
  * @platform iOS: Supported
38
38
  * @platform Android: Supported
@@ -1,15 +1,15 @@
1
1
  import * as React from 'react';
2
- import {View, ViewProps} from 'react-native';
2
+ import {View, type ViewProps} from 'react-native';
3
3
  import decorateMapComponent, {
4
4
  USES_DEFAULT_IMPLEMENTATION,
5
5
  SUPPORTED,
6
6
  ProviderContext,
7
- NativeComponent,
8
- MapManagerCommand,
9
- UIManagerCommand,
7
+ type NativeComponent,
8
+ type MapManagerCommand,
9
+ type UIManagerCommand,
10
10
  } from './decorateMapComponent';
11
- import {PolygonPressEvent} from './MapPolygon.types';
12
- import {LatLng, LineCapType, LineJoinType} from './sharedTypes';
11
+ import type {PolygonPressEvent} from './MapPolygon.types';
12
+ import type {LatLng, LineCapType, LineJoinType} from './sharedTypes';
13
13
 
14
14
  export type MapPolygonProps = ViewProps & {
15
15
  /**
@@ -1,5 +1,5 @@
1
- import {NativeSyntheticEvent} from 'react-native';
2
- import {LatLng, Point} from './sharedTypes';
1
+ import type {NativeSyntheticEvent} from 'react-native';
2
+ import type {LatLng, Point} from './sharedTypes';
3
3
 
4
4
  // All types in this file are directly exported with the package for external
5
5
  // use.
@@ -1,14 +1,14 @@
1
1
  import * as React from 'react';
2
- import {NativeSyntheticEvent, View, ViewProps} from 'react-native';
2
+ import {View, type NativeSyntheticEvent, type ViewProps} from 'react-native';
3
3
  import decorateMapComponent, {
4
4
  USES_DEFAULT_IMPLEMENTATION,
5
5
  SUPPORTED,
6
6
  ProviderContext,
7
- NativeComponent,
8
- MapManagerCommand,
9
- UIManagerCommand,
7
+ type NativeComponent,
8
+ type MapManagerCommand,
9
+ type UIManagerCommand,
10
10
  } from './decorateMapComponent';
11
- import {LatLng, LineCapType, LineJoinType, Point} from './sharedTypes';
11
+ import type {LatLng, LineCapType, LineJoinType, Point} from './sharedTypes';
12
12
 
13
13
  export type MapPolylineProps = ViewProps & {
14
14
  /**
@@ -4,11 +4,11 @@ import decorateMapComponent, {
4
4
  USES_DEFAULT_IMPLEMENTATION,
5
5
  SUPPORTED,
6
6
  ProviderContext,
7
- NativeComponent,
8
- MapManagerCommand,
9
- UIManagerCommand,
7
+ type NativeComponent,
8
+ type MapManagerCommand,
9
+ type UIManagerCommand,
10
10
  } from './decorateMapComponent';
11
- import {ViewProps} from 'react-native';
11
+ import type {ViewProps} from 'react-native';
12
12
 
13
13
  export type MapUrlTileProps = ViewProps & {
14
14
  /**
package/src/MapView.tsx CHANGED
@@ -3,18 +3,18 @@ import {
3
3
  Animated as RNAnimated,
4
4
  Animated,
5
5
  findNodeHandle,
6
- HostComponent,
7
- NativeSyntheticEvent,
8
6
  Platform,
9
7
  requireNativeComponent,
10
- ViewProps,
8
+ type HostComponent,
9
+ type NativeSyntheticEvent,
10
+ type ViewProps,
11
11
  } from 'react-native';
12
12
  import {
13
13
  createNotSupportedComponent,
14
- NativeComponent,
15
14
  ProviderContext,
15
+ type NativeComponent,
16
16
  } from './decorateMapComponent';
17
- import {
17
+ import type {
18
18
  CalloutPressEvent,
19
19
  ClickEvent,
20
20
  Frame,
@@ -28,7 +28,7 @@ import {
28
28
  Provider,
29
29
  Region,
30
30
  } from './sharedTypes';
31
- import {
31
+ import type {
32
32
  ActiveIndoorLevel,
33
33
  Address,
34
34
  BoundingBox,
@@ -50,17 +50,20 @@ import {
50
50
  SnapshotOptions,
51
51
  UserLocationChangeEvent,
52
52
  } from './MapView.types';
53
- import {Modify} from './sharedTypesInternal';
54
- import {Commands, MapViewNativeComponentType} from './MapViewNativeComponent';
53
+ import type {Modify} from './sharedTypesInternal';
54
+ import {
55
+ Commands,
56
+ type MapViewNativeComponentType,
57
+ } from './MapViewNativeComponent';
55
58
 
56
59
  import FabricMapView, {
57
60
  Commands as FabricCommands,
58
- MapFabricNativeProps,
61
+ type MapFabricNativeProps,
59
62
  } from './specs/NativeComponentMapView';
60
63
  import GoogleMapView, {
61
64
  Commands as GoogleCommands,
62
65
  } from './specs/NativeComponentGoogleMapView';
63
- import createFabricMap, {FabricMapHandle} from './createFabricMap';
66
+ import createFabricMap, {type FabricMapHandle} from './createFabricMap';
64
67
 
65
68
  const FabricMap = createFabricMap(FabricMapView, FabricCommands);
66
69
  var FabricGoogleMap: any = null;
@@ -445,7 +448,7 @@ export type MapViewProps = ViewProps & {
445
448
  * @platform iOS: Supported
446
449
  * @platform Android: Supported
447
450
  */
448
- onRegionChangeStart?: (event: NativeSyntheticEvent<Details>) => void;
451
+ onRegionChangeStart?: (region: Region, details: Details) => void;
449
452
 
450
453
  /**
451
454
  * Callback that is called continuously when the region changes, such as when a user is dragging the map.
@@ -593,6 +596,15 @@ export type MapViewProps = ViewProps & {
593
596
  */
594
597
  showsScale?: boolean;
595
598
 
599
+ /**
600
+ * A Boolean value indicating whether the map displays traffic information.
601
+ *
602
+ * @default false
603
+ * @platform iOS: Supported
604
+ * @platform Android: Supported
605
+ */
606
+ showsTraffic?: boolean;
607
+
596
608
  /**
597
609
  * If `true` the users location will be displayed on the map.
598
610
  *
@@ -762,7 +774,6 @@ class MapView extends React.Component<MapViewProps, State> {
762
774
  };
763
775
 
764
776
  this._onMapReady = this._onMapReady.bind(this);
765
- this._onChange = this._onChange.bind(this);
766
777
  }
767
778
 
768
779
  setNativeProps(props: Partial<NativeProps>) {
@@ -779,19 +790,6 @@ class MapView extends React.Component<MapViewProps, State> {
779
790
  });
780
791
  }
781
792
 
782
- private _onChange({nativeEvent}: ChangeEvent) {
783
- const isGesture = nativeEvent.isGesture;
784
- const details = {isGesture};
785
-
786
- if (nativeEvent.continuous) {
787
- if (this.props.onRegionChange) {
788
- this.props.onRegionChange(nativeEvent.region, details);
789
- }
790
- } else if (this.props.onRegionChangeComplete) {
791
- this.props.onRegionChangeComplete(nativeEvent.region, details);
792
- }
793
- }
794
-
795
793
  getCamera(): Promise<Camera> {
796
794
  if (this.fabricMap.current) {
797
795
  return this.fabricMap.current.getCamera();
@@ -1038,6 +1036,7 @@ class MapView extends React.Component<MapViewProps, State> {
1038
1036
  };
1039
1037
  }
1040
1038
 
1039
+ // @ts-ignore
1041
1040
  private _getHandle() {
1042
1041
  return findNodeHandle(this.map.current);
1043
1042
  }
@@ -1072,19 +1071,17 @@ class MapView extends React.Component<MapViewProps, State> {
1072
1071
  }
1073
1072
  };
1074
1073
  private handleRegionChange = (event: NativeSyntheticEvent<any>) => {
1075
- const isGesture = event.nativeEvent.isGesture;
1076
- const details = {isGesture};
1077
- if (event.nativeEvent.continuous) {
1078
- if (this.props.onRegionChange) {
1079
- this.props.onRegionChange(event.nativeEvent.region, details);
1080
- }
1081
- } else if (this.props.onRegionChangeComplete) {
1082
- this.props.onRegionChangeComplete(event.nativeEvent.region, details);
1074
+ if (this.props.onRegionChange) {
1075
+ this.props.onRegionChange(event.nativeEvent.region, {
1076
+ isGesture: event.nativeEvent.isGesture,
1077
+ });
1083
1078
  }
1084
1079
  };
1085
1080
  private handleRegionChangeStarted = (event: NativeSyntheticEvent<any>) => {
1086
1081
  if (this.props.onRegionChangeStart) {
1087
- this.props.onRegionChangeStart(event);
1082
+ this.props.onRegionChangeStart(event.nativeEvent.region, {
1083
+ isGesture: event.nativeEvent.isGesture,
1084
+ });
1088
1085
  }
1089
1086
  };
1090
1087
 
@@ -1104,10 +1101,10 @@ class MapView extends React.Component<MapViewProps, State> {
1104
1101
  };
1105
1102
 
1106
1103
  private handleRegionChangeComplete = (event: NativeSyntheticEvent<any>) => {
1107
- const isGesture = event.nativeEvent.isGesture;
1108
- const details = {isGesture};
1109
1104
  if (this.props.onRegionChangeComplete) {
1110
- this.props.onRegionChangeComplete(event.nativeEvent.region, details);
1105
+ this.props.onRegionChangeComplete(event.nativeEvent.region, {
1106
+ isGesture: event.nativeEvent.isGesture,
1107
+ });
1111
1108
  }
1112
1109
  };
1113
1110
 
@@ -1,5 +1,5 @@
1
- import {ClickEvent, LatLng, Point, Region} from './sharedTypes';
2
- import {NativeSyntheticEvent} from 'react-native';
1
+ import type {ClickEvent, LatLng, Point, Region} from './sharedTypes';
2
+ import type {NativeSyntheticEvent} from 'react-native';
3
3
 
4
4
  // All types in this file are directly exported with the package for external
5
5
  // use.
@@ -148,7 +148,6 @@ export type UserLocationChangeEvent = NativeSyntheticEvent<{
148
148
  }>;
149
149
 
150
150
  export type ChangeEvent = NativeSyntheticEvent<{
151
- continuous: boolean;
152
151
  region: Region;
153
152
  isGesture?: boolean;
154
153
  }>;
@@ -1,8 +1,8 @@
1
1
  import type {HostComponent} from 'react-native';
2
2
  import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
3
- import {NativeProps} from './MapView';
4
- import {Camera, EdgePadding} from './MapView.types';
5
- import {LatLng, Region} from './sharedTypes';
3
+ import type {NativeProps} from './MapView';
4
+ import type {Camera, EdgePadding} from './MapView.types';
5
+ import type {LatLng, Region} from './sharedTypes';
6
6
 
7
7
  export type MapViewNativeComponentType = HostComponent<NativeProps>;
8
8
 
@@ -1,13 +1,13 @@
1
1
  import * as React from 'react';
2
- import {ViewProps} from 'react-native';
2
+ import type {ViewProps} from 'react-native';
3
3
 
4
4
  import decorateMapComponent, {
5
5
  USES_DEFAULT_IMPLEMENTATION,
6
6
  SUPPORTED,
7
7
  ProviderContext,
8
- NativeComponent,
9
- MapManagerCommand,
10
- UIManagerCommand,
8
+ type NativeComponent,
9
+ type MapManagerCommand,
10
+ type UIManagerCommand,
11
11
  } from './decorateMapComponent';
12
12
 
13
13
  export type MapWMSTileProps = ViewProps & {
@@ -7,10 +7,18 @@ import type {
7
7
  EdgePadding,
8
8
  SnapshotOptions,
9
9
  } from './MapView.types';
10
- import NativeAirMapsModule, {MapBoundaries} from './specs/NativeAirMapsModule';
11
- import {MapFabricNativeProps} from './specs/NativeComponentMapView';
12
-
13
- export type FabricMapViewProps = MapFabricNativeProps;
10
+ import NativeAirMapsModule, {
11
+ type MapBoundaries,
12
+ } from './specs/NativeAirMapsModule';
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;
14
22
 
15
23
  export interface FabricMapHandle {
16
24
  getCamera: () => Promise<Camera>;
@@ -40,17 +48,21 @@ export interface FabricMapHandle {
40
48
  setIndoorActiveLevelIndex: (activeLevelIndex: number) => void;
41
49
  }
42
50
 
43
- const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
44
- return forwardRef<FabricMapHandle, FabricMapViewProps>((props, ref) => {
45
- const fabricRef = useRef<React.ElementRef<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;
46
61
 
47
62
  useImperativeHandle(ref, () => ({
48
63
  async getMarkersFrames(onlyVisible: boolean) {
49
64
  if (fabricRef.current) {
50
- return NativeAirMapsModule.getMarkersFrames(
51
- findNodeHandle(fabricRef.current) ?? -1,
52
- onlyVisible,
53
- );
65
+ return NativeAirMapsModule.getMarkersFrames(node, onlyVisible);
54
66
  } else {
55
67
  throw new Error(
56
68
  'getMarkersFrames is only supported on iOS with Fabric.',
@@ -59,10 +71,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
59
71
  },
60
72
  async getCoordinateForPoint(point: Point) {
61
73
  if (fabricRef.current) {
62
- return NativeAirMapsModule.getCoordinateForPoint(
63
- findNodeHandle(fabricRef.current) ?? -1,
64
- point,
65
- );
74
+ return NativeAirMapsModule.getCoordinateForPoint(node, point);
66
75
  } else {
67
76
  throw new Error(
68
77
  'getCoordinateForPoint is only supported on iOS with Fabric.',
@@ -71,10 +80,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
71
80
  },
72
81
  async getPointForCoordinate(coordinate: LatLng) {
73
82
  if (fabricRef.current) {
74
- return NativeAirMapsModule.getPointForCoordinate(
75
- findNodeHandle(fabricRef.current) ?? -1,
76
- coordinate,
77
- );
83
+ return NativeAirMapsModule.getPointForCoordinate(node, coordinate);
78
84
  } else {
79
85
  throw new Error(
80
86
  'getPointForCoordinate is not supported on this platform.',
@@ -84,7 +90,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
84
90
  async getAddressFromCoordinates(coordinate: LatLng) {
85
91
  if (fabricRef.current) {
86
92
  return NativeAirMapsModule.getAddressFromCoordinates(
87
- findNodeHandle(fabricRef.current) ?? -1,
93
+ node,
88
94
  coordinate,
89
95
  );
90
96
  } else {
@@ -95,28 +101,21 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
95
101
  },
96
102
  async takeSnapshot(config: SnapshotOptions) {
97
103
  if (fabricRef.current) {
98
- return NativeAirMapsModule.takeSnapshot(
99
- findNodeHandle(fabricRef.current) ?? -1,
100
- JSON.stringify(config),
101
- );
104
+ return NativeAirMapsModule.takeSnapshot(node, JSON.stringify(config));
102
105
  } else {
103
106
  throw new Error('takeSnapshot is only supported on iOS with Fabric.');
104
107
  }
105
108
  },
106
109
  async getCamera() {
107
110
  if (fabricRef.current) {
108
- return NativeAirMapsModule.getCamera(
109
- findNodeHandle(fabricRef.current) ?? -1,
110
- );
111
+ return NativeAirMapsModule.getCamera(node);
111
112
  } else {
112
113
  throw new Error('getCamera is only supported on iOS with Fabric.');
113
114
  }
114
115
  },
115
116
  async getMapBoundaries() {
116
117
  if (fabricRef.current) {
117
- return NativeAirMapsModule.getMapBoundaries(
118
- findNodeHandle(fabricRef.current) ?? -1,
119
- );
118
+ return NativeAirMapsModule.getMapBoundaries(node);
120
119
  } else {
121
120
  throw new Error(
122
121
  'getMapBoundaries is only supported on iOS with Fabric.',
@@ -126,7 +125,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
126
125
  animateToRegion(region: Region, duration: number) {
127
126
  if (fabricRef.current) {
128
127
  try {
129
- Commands.animateToRegion(
128
+ (Commands as any).animateToRegion(
130
129
  fabricRef.current,
131
130
  JSON.stringify(region),
132
131
  duration,
@@ -143,7 +142,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
143
142
  fitToElements(edgePadding: EdgePadding, animated: boolean) {
144
143
  if (fabricRef.current) {
145
144
  try {
146
- Commands.fitToElements(
145
+ (Commands as any).fitToElements(
147
146
  fabricRef.current,
148
147
  JSON.stringify(edgePadding),
149
148
  animated,
@@ -164,7 +163,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
164
163
  ) {
165
164
  if (fabricRef.current) {
166
165
  try {
167
- Commands.fitToSuppliedMarkers(
166
+ (Commands as any).fitToSuppliedMarkers(
168
167
  fabricRef.current,
169
168
  JSON.stringify(markers),
170
169
  JSON.stringify(edgePadding),
@@ -182,7 +181,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
182
181
  animateCamera(camera: Partial<Camera>, duration: number) {
183
182
  if (fabricRef.current) {
184
183
  try {
185
- Commands.animateCamera(
184
+ (Commands as any).animateCamera(
186
185
  fabricRef.current,
187
186
  JSON.stringify(camera),
188
187
  duration,
@@ -203,7 +202,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
203
202
  ) {
204
203
  if (fabricRef.current) {
205
204
  try {
206
- Commands.fitToCoordinates(
205
+ (Commands as any).fitToCoordinates(
207
206
  fabricRef.current,
208
207
  JSON.stringify(coordinates),
209
208
  JSON.stringify(edgePadding),
@@ -221,7 +220,7 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
221
220
  setIndoorActiveLevelIndex(activeLevelIndex: number) {
222
221
  if (fabricRef.current) {
223
222
  try {
224
- Commands.setIndoorActiveLevelIndex(
223
+ (Commands as any).setIndoorActiveLevelIndex(
225
224
  fabricRef.current,
226
225
  activeLevelIndex,
227
226
  );
@@ -235,7 +234,10 @@ const createFabricMap = (ViewComponent: React.ComponentType, Commands: any) => {
235
234
  setCamera(camera: Partial<Camera>) {
236
235
  if (fabricRef.current) {
237
236
  try {
238
- Commands.setCamera(fabricRef.current, JSON.stringify(camera));
237
+ (Commands as any).setCamera(
238
+ fabricRef.current,
239
+ JSON.stringify(camera),
240
+ );
239
241
  } catch (error) {
240
242
  console.error('Failed to set camera:', error);
241
243
  }