react-native-maps 1.21.0-alpha.6 → 1.21.0-alpha.60

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 (132) hide show
  1. package/android/build.gradle +32 -8
  2. package/android/generated/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
  3. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +199 -0
  4. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +71 -0
  5. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +103 -0
  6. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
  7. package/android/generated/jni/CMakeLists.txt +36 -0
  8. package/android/generated/jni/RNMapsSpecs-generated.cpp +68 -0
  9. package/android/generated/jni/RNMapsSpecs.h +31 -0
  10. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +25 -0
  11. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +27 -0
  12. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +896 -0
  13. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +765 -0
  14. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +146 -0
  15. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1047 -0
  16. package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
  17. package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +264 -0
  18. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +20 -0
  19. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +65 -0
  20. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
  21. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +65 -0
  22. package/android/src/main/java/com/rnmaps/fabric/JSONUtil.java +86 -0
  23. package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +577 -0
  24. package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +176 -0
  25. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +25 -2
  26. package/android/src/main/java/com/rnmaps/fabric/event/OnCalloutPressEvent.java +25 -0
  27. package/android/src/main/java/com/rnmaps/fabric/event/OnDeselectEvent.java +28 -0
  28. package/android/src/main/java/com/rnmaps/fabric/event/OnDragEndEvent.java +28 -0
  29. package/android/src/main/java/com/rnmaps/fabric/event/OnDragEvent.java +28 -0
  30. package/android/src/main/java/com/rnmaps/fabric/event/OnDragStartEvent.java +28 -0
  31. package/android/src/main/java/com/rnmaps/fabric/event/OnLongPressEvent.java +28 -0
  32. package/android/src/main/java/com/rnmaps/fabric/event/OnMapReadyEvent.java +29 -0
  33. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDeselectEvent.java +28 -0
  34. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEndEvent.java +28 -0
  35. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEvent.java +28 -0
  36. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragStartEvent.java +28 -0
  37. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerPressEvent.java +28 -0
  38. package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerSelectEvent.java +28 -0
  39. package/android/src/main/java/com/rnmaps/fabric/event/OnPoiClickEvent.java +27 -0
  40. package/android/src/main/java/com/rnmaps/fabric/event/OnPressEvent.java +27 -0
  41. package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +48 -0
  42. package/android/src/main/java/com/rnmaps/fabric/event/OnSelectEvent.java +28 -0
  43. package/android/src/main/java/com/rnmaps/fabric/event/OnUserLocationChangeEvent.java +28 -0
  44. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +18 -2
  45. package/android/src/main/java/com/rnmaps/maps/MapManager.java +14 -14
  46. package/android/src/main/java/com/rnmaps/maps/MapMarker.java +53 -1
  47. package/android/src/main/java/com/rnmaps/maps/MapView.java +1613 -1346
  48. package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
  49. package/ios/AirGoogleMaps/AIRGoogleMap.m +243 -55
  50. package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
  51. package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
  52. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
  53. package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
  54. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
  55. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
  56. package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
  57. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
  58. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
  59. package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
  60. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
  61. package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +32 -2
  62. package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
  63. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
  64. package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
  65. package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
  66. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
  67. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  68. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
  69. package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +18 -0
  70. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
  71. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +629 -0
  72. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
  73. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
  74. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
  75. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
  76. package/ios/AirMaps/AIRMap.h +8 -5
  77. package/ios/AirMaps/AIRMap.m +292 -141
  78. package/ios/AirMaps/AIRMapManager.m +12 -21
  79. package/ios/AirMaps/AIRMapMarker.h +1 -0
  80. package/ios/AirMaps/AIRMapMarker.m +165 -103
  81. package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
  82. package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
  83. package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
  84. package/ios/AirMaps/RNMapsAirModule.h +4 -1
  85. package/ios/AirMaps/RNMapsAirModule.mm +42 -172
  86. package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
  87. package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
  88. package/ios/AirMaps/RNMapsMapView.h +6 -3
  89. package/ios/AirMaps/RNMapsMapView.mm +346 -332
  90. package/ios/AirMaps/RNMapsMarkerView.h +24 -0
  91. package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
  92. package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
  93. package/ios/AirMaps/UIView +AirMap.m +20 -0
  94. package/ios/AirMaps/UIView+AirMap.h +11 -0
  95. package/ios/AirMaps.xcodeproj/project.pbxproj +60 -0
  96. package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +25 -0
  97. package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +27 -0
  98. package/ios/generated/RNMapsSpecs/EventEmitters.cpp +896 -0
  99. package/ios/generated/RNMapsSpecs/EventEmitters.h +765 -0
  100. package/ios/generated/RNMapsSpecs/Props.cpp +146 -0
  101. package/ios/generated/RNMapsSpecs/Props.h +1047 -0
  102. package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +549 -0
  103. package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
  104. package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +134 -0
  105. package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +20 -0
  106. package/ios/generated/RNMapsSpecs/ShadowNodes.h +65 -0
  107. package/ios/generated/RNMapsSpecs/States.cpp +16 -0
  108. package/ios/generated/RNMapsSpecs/States.h +65 -0
  109. package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
  110. package/ios/generated/RNMapsSpecsJSI.h +264 -0
  111. package/lib/MapMarker.d.ts +15 -2
  112. package/lib/MapMarker.js +53 -9
  113. package/lib/MapMarkerNativeComponent.js +0 -2
  114. package/lib/MapOverlay.d.ts +1 -1
  115. package/lib/MapOverlay.js +2 -8
  116. package/lib/MapView.d.ts +5 -22
  117. package/lib/MapView.js +61 -80
  118. package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
  119. package/lib/createFabricMap.js +175 -0
  120. package/lib/decorateMapComponent.js +17 -0
  121. package/lib/specs/NativeAirMapsModule.d.ts +2 -2
  122. package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
  123. package/lib/specs/NativeComponentGoogleMapView.js +21 -0
  124. package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
  125. package/lib/specs/NativeComponentGooglePolygon.js +9 -0
  126. package/lib/specs/NativeComponentMapView.d.ts +21 -45
  127. package/lib/specs/NativeComponentMapView.js +1 -3
  128. package/lib/specs/NativeComponentMarker.d.ts +258 -0
  129. package/lib/specs/NativeComponentMarker.js +19 -0
  130. package/package.json +13 -7
  131. package/react-native-maps.podspec +2 -1
  132. package/lib/FabricMapView.js +0 -175
package/lib/MapMarker.js CHANGED
@@ -28,12 +28,15 @@ const React = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
29
  const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
30
30
  const MapMarkerNativeComponent_1 = require("./MapMarkerNativeComponent");
31
+ const NativeComponentMarker_1 = require("./specs/NativeComponentMarker");
32
+ const ProviderConstants_1 = require("./ProviderConstants");
31
33
  class MapMarker extends React.Component {
32
34
  getNativeComponent;
33
35
  getMapManagerCommand;
34
36
  getUIManagerCommand;
35
37
  static Animated;
36
38
  marker;
39
+ fabricMarker = undefined;
37
40
  constructor(props) {
38
41
  super(props);
39
42
  this.marker = React.createRef();
@@ -49,27 +52,59 @@ class MapMarker extends React.Component {
49
52
  }
50
53
  showCallout() {
51
54
  if (this.marker.current) {
52
- MapMarkerNativeComponent_1.Commands.showCallout(this.marker.current);
55
+ if (this.fabricMarker) {
56
+ // @ts-ignore
57
+ NativeComponentMarker_1.Commands.showCallout(this.marker.current);
58
+ }
59
+ else {
60
+ MapMarkerNativeComponent_1.Commands.showCallout(this.marker.current);
61
+ }
53
62
  }
54
63
  }
55
64
  hideCallout() {
56
65
  if (this.marker.current) {
57
- MapMarkerNativeComponent_1.Commands.hideCallout(this.marker.current);
66
+ if (this.fabricMarker) {
67
+ // @ts-ignore
68
+ NativeComponentMarker_1.Commands.hideCallout(this.marker.current);
69
+ }
70
+ else {
71
+ MapMarkerNativeComponent_1.Commands.hideCallout(this.marker.current);
72
+ }
58
73
  }
59
74
  }
60
75
  setCoordinates(coordinate) {
61
76
  if (this.marker.current) {
62
- MapMarkerNativeComponent_1.Commands.setCoordinates(this.marker.current, coordinate);
77
+ if (this.fabricMarker) {
78
+ NativeComponentMarker_1.Commands.setCoordinates(
79
+ // @ts-ignore
80
+ this.marker.current, coordinate.latitude, coordinate.longitude);
81
+ }
82
+ else {
83
+ MapMarkerNativeComponent_1.Commands.setCoordinates(this.marker.current, coordinate);
84
+ }
63
85
  }
64
86
  }
65
87
  redrawCallout() {
66
88
  if (this.marker.current) {
67
- MapMarkerNativeComponent_1.Commands.redrawCallout(this.marker.current);
89
+ if (this.fabricMarker) {
90
+ // @ts-ignore
91
+ NativeComponentMarker_1.Commands.redrawCallout(this.marker.current);
92
+ }
93
+ else {
94
+ MapMarkerNativeComponent_1.Commands.redrawCallout(this.marker.current);
95
+ }
68
96
  }
69
97
  }
70
98
  animateMarkerToCoordinate(coordinate, duration = 500) {
71
99
  if (this.marker.current) {
72
- MapMarkerNativeComponent_1.Commands.animateMarkerToCoordinate(this.marker.current, coordinate, duration);
100
+ if (this.fabricMarker) {
101
+ NativeComponentMarker_1.Commands.animateToCoordinates(
102
+ // @ts-ignore
103
+ this.marker.current, coordinate.latitude, coordinate.longitude, duration);
104
+ }
105
+ else {
106
+ MapMarkerNativeComponent_1.Commands.animateMarkerToCoordinate(this.marker.current, coordinate, duration);
107
+ }
73
108
  }
74
109
  }
75
110
  redraw() {
@@ -79,10 +114,9 @@ class MapMarker extends React.Component {
79
114
  }
80
115
  render() {
81
116
  const { stopPropagation = false } = this.props;
82
- let image;
83
- if (this.props.image) {
84
- image = react_native_1.Image.resolveAssetSource(this.props.image) || {};
85
- image = image.uri || this.props.image;
117
+ if (this.fabricMarker === undefined) {
118
+ const provider = this.context;
119
+ this.fabricMarker = !(react_native_1.Platform.OS === 'ios' && provider !== ProviderConstants_1.PROVIDER_GOOGLE);
86
120
  }
87
121
  let icon;
88
122
  if (this.props.icon) {
@@ -90,6 +124,16 @@ class MapMarker extends React.Component {
90
124
  icon = icon.uri;
91
125
  }
92
126
  const AIRMapMarker = this.getNativeComponent();
127
+ let image;
128
+ if (this.props.image) {
129
+ if (this.fabricMarker) {
130
+ image = this.props.image;
131
+ }
132
+ else {
133
+ const resolvedImage = react_native_1.Image.resolveAssetSource(this.props.image) || {};
134
+ image = resolvedImage.uri || this.props.image;
135
+ }
136
+ }
93
137
  return (<AIRMapMarker {...this.props} ref={this.marker} image={image} icon={icon} style={[styles.marker, this.props.style]} onPress={event => {
94
138
  if (stopPropagation) {
95
139
  event.stopPropagation();
@@ -9,9 +9,7 @@ exports.Commands = (0, codegenNativeCommands_1.default)({
9
9
  supportedCommands: [
10
10
  'showCallout',
11
11
  'hideCallout',
12
- 'redrawCallout',
13
12
  'animateMarkerToCoordinate',
14
- 'redraw',
15
13
  'setCoordinates',
16
14
  ],
17
15
  });
@@ -70,7 +70,7 @@ type OverlayPressEvent = NativeSyntheticEvent<{
70
70
  */
71
71
  action: 'overlay-press' | 'image-overlay-press';
72
72
  /**
73
- * @platform iOS: Apple maps
73
+ * @platform iOS: Apple Maps
74
74
  */
75
75
  name?: string;
76
76
  /**
package/lib/MapOverlay.js CHANGED
@@ -35,14 +35,8 @@ class MapOverlay extends React.Component {
35
35
  render() {
36
36
  const { opacity = 1.0 } = this.props;
37
37
  let image;
38
- if (typeof this.props.image !== 'number' &&
39
- this.props.image.uri?.startsWith('http')) {
40
- image = this.props.image.uri;
41
- }
42
- else {
43
- const sourceAsset = react_native_1.Image.resolveAssetSource(this.props.image) || {};
44
- image = sourceAsset.uri;
45
- }
38
+ const resolvedImage = react_native_1.Image.resolveAssetSource(this.props.image) || {};
39
+ image = resolvedImage.uri || this.props.image;
46
40
  const AIRMapOverlay = this.getNativeComponent();
47
41
  return (<AIRMapOverlay {...this.props} opacity={opacity} image={image} style={[styles.overlay, this.props.style]}/>);
48
42
  }
package/lib/MapView.d.ts CHANGED
@@ -11,7 +11,7 @@ export type MapViewProps = ViewProps & {
11
11
  * If `true` map will be cached and displayed as an image instead of being interactable, for performance usage.
12
12
  *
13
13
  * @default false
14
- * @platform iOS: Apple maps only
14
+ * @platform iOS: Apple Maps only
15
15
  * @platform Android: Supported
16
16
  */
17
17
  cacheEnabled?: boolean;
@@ -92,7 +92,7 @@ export type MapViewProps = ViewProps & {
92
92
  */
93
93
  kmlSrc?: string;
94
94
  /**
95
- * If set, changes the position of the "Legal" label link in Apple maps.
95
+ * If set, changes the position of the "Legal" label link in Apple Maps.
96
96
  *
97
97
  * @platform iOS: Apple Maps only
98
98
  * @platform Android: Not supported
@@ -426,7 +426,7 @@ export type MapViewProps = ViewProps & {
426
426
  * If `false` compass won't be displayed on the map.
427
427
  *
428
428
  * @default true
429
- * @platform iOS: Supported
429
+ * @platform iOS: Supported (adaptive on Apple Maps, visible only if map is not pointing north)
430
430
  * @platform Android: Supported
431
431
  */
432
432
  showsCompass?: boolean;
@@ -454,32 +454,14 @@ export type MapViewProps = ViewProps & {
454
454
  * @platform Android: Supported
455
455
  */
456
456
  showsMyLocationButton?: boolean;
457
- /**
458
- * If `false` points of interest won't be displayed on the map.
459
- * TODO: DEPRECATED? Doesn't seem to do anything
460
- *
461
- * @default true
462
- * @platform iOS: Maybe Apple Maps?
463
- * @platform Android: Not supported
464
- */
465
- showsPointsOfInterest?: boolean;
466
457
  /**
467
458
  * A Boolean indicating whether the map shows scale information.
468
459
  *
469
- * @default true
460
+ * @default false
470
461
  * @platform iOS: Apple Maps only
471
462
  * @platform Android: Not supported
472
463
  */
473
464
  showsScale?: boolean;
474
- /**
475
- * A Boolean value indicating whether the map displays traffic information.
476
- * TODO: Look into android support
477
- *
478
- * @default false
479
- * @platform iOS: Supported
480
- * @platform Android: Not supported?
481
- */
482
- showsTraffic?: boolean;
483
465
  /**
484
466
  * If `true` the users location will be displayed on the map.
485
467
  *
@@ -626,6 +608,7 @@ declare class MapView extends React.Component<MapViewProps, State> {
626
608
  duration?: number;
627
609
  }): void;
628
610
  animateToRegion(region: Region, duration?: number): void;
611
+ setRegion(region: Region): void;
629
612
  fitToElements(options?: FitToOptions): void;
630
613
  fitToSuppliedMarkers(markers: string[], options?: FitToOptions): void;
631
614
  fitToCoordinates(coordinates?: LatLng[], options?: FitToOptions): void;
package/lib/MapView.js CHANGED
@@ -30,9 +30,15 @@ exports.AnimatedMapView = exports.MAP_TYPES = void 0;
30
30
  const React = __importStar(require("react"));
31
31
  const react_native_1 = require("react-native");
32
32
  const decorateMapComponent_1 = require("./decorateMapComponent");
33
- const ProviderConstants = __importStar(require("./ProviderConstants"));
34
33
  const MapViewNativeComponent_1 = require("./MapViewNativeComponent");
35
- const FabricMapView_1 = __importDefault(require("./FabricMapView"));
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
+ var FabricGoogleMap = null;
39
+ if (react_native_1.Platform.OS === 'ios') {
40
+ FabricGoogleMap = (0, createFabricMap_1.default)(NativeComponentGoogleMapView_1.default, NativeComponentGoogleMapView_1.Commands);
41
+ }
36
42
  exports.MAP_TYPES = {
37
43
  STANDARD: 'standard',
38
44
  SATELLITE: 'satellite',
@@ -43,7 +49,6 @@ exports.MAP_TYPES = {
43
49
  SATELLITE_FLYOVER: 'satelliteFlyover',
44
50
  HYBRID_FLYOVER: 'hybridFlyover',
45
51
  };
46
- const GOOGLE_MAPS_ONLY_TYPES = [exports.MAP_TYPES.TERRAIN, exports.MAP_TYPES.NONE];
47
52
  class MapView extends React.Component {
48
53
  static Animated;
49
54
  map;
@@ -53,7 +58,7 @@ class MapView extends React.Component {
53
58
  this.map = React.createRef();
54
59
  this.fabricMap = React.createRef();
55
60
  this.state = {
56
- isReady: react_native_1.Platform.OS === 'ios',
61
+ isReady: false,
57
62
  };
58
63
  this._onMapReady = this._onMapReady.bind(this);
59
64
  this._onChange = this._onChange.bind(this);
@@ -83,13 +88,8 @@ class MapView extends React.Component {
83
88
  }
84
89
  }
85
90
  getCamera() {
86
- if (react_native_1.Platform.OS === 'android') {
87
- return react_native_1.NativeModules.AirMapModule.getCamera(this._getHandle());
88
- }
89
- else if (react_native_1.Platform.OS === 'ios') {
90
- if (this.fabricMap.current) {
91
- return this.fabricMap.current.getCamera();
92
- }
91
+ if (this.fabricMap.current) {
92
+ return this.fabricMap.current.getCamera();
93
93
  }
94
94
  return Promise.reject('getCamera not supported on this platform');
95
95
  }
@@ -117,6 +117,12 @@ class MapView extends React.Component {
117
117
  MapViewNativeComponent_1.Commands.animateToRegion(this.map.current, region, duration);
118
118
  }
119
119
  }
120
+ setRegion(region) {
121
+ if (this.fabricMap.current) {
122
+ this.fabricMap.current.animateToRegion(region, 0);
123
+ }
124
+ //TODO fix for android
125
+ }
120
126
  fitToElements(options = {}) {
121
127
  const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
122
128
  if (this.fabricMap.current) {
@@ -343,81 +349,57 @@ class MapView extends React.Component {
343
349
  }
344
350
  };
345
351
  render() {
346
- if (react_native_1.Platform.OS === 'ios' &&
347
- this.props.provider === ProviderConstants.PROVIDER_DEFAULT) {
348
- const AIRMap = FabricMapView_1.default;
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, region, ...restProps } = this.props;
352
- /* eslint-enable @typescript-eslint/no-unused-vars */
353
- const userInterfaceStyle = this.props.userInterfaceStyle || 'system';
354
- const props = {
355
- onMapReady: this._onMapReady,
356
- liteMode: this.props.liteMode,
357
- googleMapId: this.props.googleMapId,
358
- googleRenderer: this.props.googleRenderer,
359
- onPress: this.handleMapPress,
360
- onMarkerPress: this.handleMarkerPress,
361
- onMarkerSelect: this.handleMarkerSelect,
362
- onMarkerDeselect: this.handleMarkerDeselect,
363
- userInterfaceStyle: userInterfaceStyle,
364
- onRegionChange: this.handleRegionChange,
365
- ...restProps,
352
+ // Define props specifically for MapFabricNativeProps
353
+ /* eslint-disable @typescript-eslint/no-unused-vars */
354
+ const { onCalloutPress, onIndoorBuildingFocused, onKmlReady, onLongPress, onMarkerDeselect, onMarkerPress, onMarkerSelect, onRegionChangeStart, onRegionChange, onRegionChangeComplete, onPress, minZoomLevel, maxZoomLevel, region, provider, children, ...restProps } = this.props;
355
+ /* eslint-enable @typescript-eslint/no-unused-vars */
356
+ const userInterfaceStyle = this.props.userInterfaceStyle || 'system';
357
+ const props = {
358
+ onMapReady: this._onMapReady,
359
+ liteMode: this.props.liteMode,
360
+ googleMapId: this.props.googleMapId,
361
+ googleRenderer: this.props.googleRenderer,
362
+ onPress: this.handleMapPress,
363
+ onMarkerPress: this.handleMarkerPress,
364
+ onMarkerSelect: this.handleMarkerSelect,
365
+ onMarkerDeselect: this.handleMarkerDeselect,
366
+ userInterfaceStyle: userInterfaceStyle,
367
+ minZoom: minZoomLevel,
368
+ maxZoom: maxZoomLevel,
369
+ onRegionChange: this.handleRegionChange,
370
+ ...restProps,
371
+ };
372
+ if (this.props.region) {
373
+ props.region = {
374
+ latitude: this.props.region.latitude,
375
+ longitude: this.props.region.longitude,
376
+ latitudeDelta: this.props.region.latitudeDelta,
377
+ longitudeDelta: this.props.region.longitudeDelta,
366
378
  };
367
- if (this.props.region) {
368
- props.region = {
369
- latitude: this.props.region.latitude,
370
- longitude: this.props.region.longitude,
371
- latitudeDelta: this.props.region.latitudeDelta,
372
- longitudeDelta: this.props.region.longitudeDelta,
373
- };
374
- }
375
- if (this.state.isReady) {
376
- if (props.mapType && GOOGLE_MAPS_ONLY_TYPES.includes(props.mapType)) {
377
- props.mapType = exports.MAP_TYPES.STANDARD;
378
- console.log('ready');
379
- }
380
- }
381
- else {
382
- props.style = this.props.style;
383
- props.initialCamera = this.props.initialCamera;
384
- props.onLayout = this.props.onLayout;
379
+ }
380
+ if (this.state.isReady) {
381
+ if (props.onPanDrag) {
382
+ props.handlePanDrag = !!props.onPanDrag;
385
383
  }
386
- // Render AIRMap with MapFabricNativeProps
384
+ }
385
+ else {
386
+ props.style = this.props.style;
387
+ props.initialCamera = this.props.initialCamera;
388
+ props.onLayout = this.props.onLayout;
389
+ }
390
+ const childrenNodes = this.state.isReady ? children : null;
391
+ if (provider === 'google' && react_native_1.Platform.OS === 'ios') {
387
392
  return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
388
- <AIRMap {...props} ref={this.fabricMap}/>
393
+ <FabricGoogleMap {...props} ref={this.fabricMap}>
394
+ {childrenNodes}
395
+ </FabricGoogleMap>
389
396
  </decorateMapComponent_1.ProviderContext.Provider>);
390
397
  }
391
398
  else {
392
- const AIRMap = getNativeMapComponent(this.props.provider);
393
- // Define props specifically for NativeProps
394
- const props = {
395
- region: null,
396
- initialRegion: null,
397
- onChange: this._onChange,
398
- onMapReady: this._onMapReady,
399
- liteMode: this.props.liteMode,
400
- googleMapId: this.props.googleMapId,
401
- googleRenderer: this.props.googleRenderer,
402
- ref: this.map,
403
- customMapStyleString: this.props.customMapStyle
404
- ? JSON.stringify(this.props.customMapStyle)
405
- : undefined,
406
- ...this.props,
407
- };
408
- if (this.state.isReady) {
409
- if (props.onPanDrag) {
410
- props.handlePanDrag = !!props.onPanDrag;
411
- }
412
- }
413
- else {
414
- props.style = this.props.style;
415
- props.initialCamera = this.props.initialCamera;
416
- props.onLayout = this.props.onLayout;
417
- }
418
- // Render AIRMap with NativeProps
419
399
  return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
420
- <AIRMap {...props}/>
400
+ <FabricMap {...props} ref={this.fabricMap}>
401
+ {childrenNodes}
402
+ </FabricMap>
421
403
  </decorateMapComponent_1.ProviderContext.Provider>);
422
404
  }
423
405
  }
@@ -434,7 +416,6 @@ else {
434
416
  ? (0, react_native_1.requireNativeComponent)('AIRGoogleMap')
435
417
  : (0, decorateMapComponent_1.createNotSupportedComponent)('react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS.');
436
418
  }
437
- const getNativeMapComponent = (provider) => airMaps[provider || 'default'];
438
419
  exports.AnimatedMapView = react_native_1.Animated.createAnimatedComponent(MapView);
439
420
  MapView.Animated = exports.AnimatedMapView;
440
421
  exports.default = MapView;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import type { MapBoundaries } from './specs/NativeAirMapsModule';
3
- import type { MapFabricNativeProps, Camera, Point } from './specs/NativeComponentMapView';
4
- import { LatLng, Region } from './sharedTypes';
5
- import { Address, EdgePadding, SnapshotOptions } from './MapView.types';
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;
6
7
  export interface FabricMapHandle {
7
8
  getCamera: () => Promise<Camera>;
8
9
  setCamera: (camera: Partial<Camera>) => void;
@@ -18,5 +19,5 @@ export interface FabricMapHandle {
18
19
  getPointForCoordinate: (coordinate: LatLng) => Promise<Point>;
19
20
  getCoordinateForPoint: (point: Point) => Promise<LatLng>;
20
21
  }
21
- export declare const FabricMap: React.ForwardRefExoticComponent<MapFabricNativeProps & React.RefAttributes<FabricMapHandle>>;
22
- export default FabricMap;
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, JSON.stringify(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;
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.googleMapIsInstalled = exports.createNotSupportedComponent = exports.getNativeMapName = exports.ProviderContext = exports.NOT_SUPPORTED = exports.USES_DEFAULT_IMPLEMENTATION = exports.SUPPORTED = void 0;
4
7
  const react_1 = require("react");
5
8
  const react_native_1 = require("react-native");
6
9
  const ProviderConstants_1 = require("./ProviderConstants");
10
+ const NativeComponentGooglePolygon_1 = __importDefault(require("./specs/NativeComponentGooglePolygon"));
11
+ const NativeComponentMarker_1 = __importDefault(require("./specs/NativeComponentMarker"));
7
12
  exports.SUPPORTED = 'SUPPORTED';
8
13
  exports.USES_DEFAULT_IMPLEMENTATION = 'USES_DEFAULT_IMPLEMENTATION';
9
14
  exports.NOT_SUPPORTED = 'NOT_SUPPORTED';
@@ -34,6 +39,11 @@ function decorateMapComponent(Component, componentName, providers) {
34
39
  Component.prototype.getNativeComponent =
35
40
  function getNativeComponent() {
36
41
  const provider = this.context;
42
+ if (componentName === 'Marker' &&
43
+ (react_native_1.Platform.OS !== 'ios' || provider !== ProviderConstants_1.PROVIDER_GOOGLE)) {
44
+ // @ts-ignore
45
+ return NativeComponentMarker_1.default;
46
+ }
37
47
  const key = provider || 'default';
38
48
  if (components[key]) {
39
49
  return components[key];
@@ -47,6 +57,13 @@ function decorateMapComponent(Component, componentName, providers) {
47
57
  if (react_native_1.Platform.OS !== 'android' && react_native_1.Platform.OS !== 'ios') {
48
58
  throw new Error(`react-native-maps doesn't support ${react_native_1.Platform.OS}`);
49
59
  }
60
+ if (componentName === 'Polygon' &&
61
+ provider === ProviderConstants_1.PROVIDER_GOOGLE &&
62
+ react_native_1.Platform.OS === 'ios' &&
63
+ exports.googleMapIsInstalled) {
64
+ // @ts-ignore
65
+ return NativeComponentGooglePolygon_1.default;
66
+ }
50
67
  const platformSupport = providerInfo[react_native_1.Platform.OS];
51
68
  const nativeComponentName = getNativeComponentName(provider, componentName);
52
69
  if (platformSupport === exports.NOT_SUPPORTED) {