react-native-maps 1.21.0-alpha.99 → 1.22.0

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 (234) hide show
  1. package/README.md +9 -4
  2. package/android/build.gradle +65 -72
  3. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  4. package/android/src/main/RCTAppDependencyProvider.h +25 -0
  5. package/android/src/main/RCTAppDependencyProvider.mm +55 -0
  6. package/android/src/main/RCTModulesConformingToProtocolsProvider.h +18 -0
  7. package/android/src/main/RCTModulesConformingToProtocolsProvider.mm +33 -0
  8. package/android/src/main/RCTThirdPartyComponentsProvider.h +16 -0
  9. package/android/src/main/RCTThirdPartyComponentsProvider.mm +28 -0
  10. package/android/src/main/ReactAppDependencyProvider.podspec +34 -0
  11. package/android/src/main/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
  12. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerDelegate.java +35 -0
  13. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerInterface.java +17 -0
  14. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java +49 -0
  15. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerInterface.java +23 -0
  16. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerDelegate.java +49 -0
  17. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerInterface.java +23 -0
  18. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +209 -0
  19. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +74 -0
  20. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
  21. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
  22. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java +45 -0
  23. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java +22 -0
  24. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerDelegate.java +58 -0
  25. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerInterface.java +26 -0
  26. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsUrlTileManagerDelegate.java +62 -0
  27. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsUrlTileManagerInterface.java +27 -0
  28. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsWMSTileManagerDelegate.java +56 -0
  29. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsWMSTileManagerInterface.java +25 -0
  30. package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +5 -1
  31. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +1 -1
  32. package/android/src/main/java/com/rnmaps/fabric/OverlayManager.java +9 -3
  33. package/android/src/main/java/com/rnmaps/fabric/UrlTileManager.java +124 -0
  34. package/android/src/main/java/com/rnmaps/fabric/WMSTileManager.java +114 -0
  35. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +19 -3
  36. package/android/src/main/java/com/rnmaps/maps/MapMarker.java +608 -603
  37. package/android/src/main/java/com/rnmaps/maps/MapMarkerManager.java +3 -3
  38. package/android/src/main/java/com/rnmaps/maps/MapOverlay.java +2 -22
  39. package/android/src/main/java/com/rnmaps/maps/MapOverlayManager.java +23 -1
  40. package/android/src/main/java/com/rnmaps/maps/MapUrlTile.java +18 -18
  41. package/android/src/main/java/com/rnmaps/maps/MapUrlTileManager.java +10 -14
  42. package/android/src/main/java/com/rnmaps/maps/MapView.java +58 -49
  43. package/android/src/main/java/com/rnmaps/maps/MapWMSTile.java +3 -3
  44. package/android/src/main/java/com/rnmaps/maps/MapWMSTileManager.java +10 -10
  45. package/android/src/main/jni/CMakeLists.txt +36 -0
  46. package/android/src/main/jni/RNMapsSpecs-generated.cpp +68 -0
  47. package/android/src/main/jni/RNMapsSpecs.h +31 -0
  48. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +31 -0
  49. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +33 -0
  50. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +979 -0
  51. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +860 -0
  52. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.cpp +227 -0
  53. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +1297 -0
  54. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
  55. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +268 -0
  56. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +26 -0
  57. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +131 -0
  58. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
  59. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/States.h +137 -0
  60. package/app.plugin.js +1 -0
  61. package/ios/AirGoogleMaps/AIRGoogleMap.h +13 -13
  62. package/ios/AirGoogleMaps/{AIRGoogleMap.m → AIRGoogleMap.mm} +32 -34
  63. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +1 -0
  64. package/ios/AirGoogleMaps/AIRGoogleMapManager.mm +543 -0
  65. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +3 -3
  66. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +1 -1
  67. package/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m +2 -2
  68. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  69. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +5 -2
  70. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +41 -33
  71. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +16 -1
  72. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +23 -14
  73. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +1 -0
  74. package/ios/AirMaps/AIRMap.h +8 -9
  75. package/ios/AirMaps/{AIRMap.m → AIRMap.mm} +18 -14
  76. package/ios/AirMaps/AIRMapManager.m +8 -19
  77. package/ios/AirMaps/AIRMapMarker.m +57 -44
  78. package/ios/AirMaps/AIRMapOverlay.m +2 -2
  79. package/ios/AirMaps/AIRMapWMSTile.m +8 -8
  80. package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.h +25 -0
  81. package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.mm +77 -0
  82. package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.h +25 -0
  83. package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.mm +51 -0
  84. package/ios/AirMaps/RNMapsAirModule.h +2 -3
  85. package/ios/AirMaps/RNMapsAirModule.mm +14 -0
  86. package/ios/AirMaps/RNMapsDefines.h +1 -0
  87. package/ios/AirMaps/RNMapsMapView.h +5 -2
  88. package/ios/AirMaps/RNMapsMapView.mm +16 -6
  89. package/ios/AirMaps/RNMapsMapViewManager.mm +19 -1
  90. package/ios/AirMaps/RNMapsMarkerView.mm +12 -4
  91. package/ios/AirMaps/RNMapsMarkerViewManager.mm +7 -0
  92. package/ios/AirMaps/module.modulemap +6 -0
  93. package/ios/AirMaps.xcodeproj/project.pbxproj +15 -55
  94. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  95. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  96. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  97. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  98. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  99. package/ios/generated/RCTThirdPartyComponentsProvider.mm +26 -0
  100. package/ios/{AirMaps → generated}/RNMapsAirModuleDelegate.h +1 -1
  101. package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +29 -0
  102. package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +31 -0
  103. package/ios/generated/RNMapsSpecs/EventEmitters.cpp +977 -0
  104. package/ios/generated/RNMapsSpecs/EventEmitters.h +846 -0
  105. package/ios/generated/RNMapsSpecs/Props.cpp +194 -0
  106. package/ios/generated/RNMapsSpecs/Props.h +1224 -0
  107. package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +591 -0
  108. package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
  109. package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
  110. package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +24 -0
  111. package/ios/generated/RNMapsSpecs/ShadowNodes.h +109 -0
  112. package/ios/generated/RNMapsSpecs/States.cpp +16 -0
  113. package/ios/generated/RNMapsSpecs/States.h +113 -0
  114. package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
  115. package/ios/generated/RNMapsSpecsJSI.h +268 -0
  116. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  117. package/ios/generated/module.modulemap +15 -0
  118. package/package.json +34 -27
  119. package/plugin/build/android.js +58 -0
  120. package/plugin/build/index.js +10 -0
  121. package/plugin/build/ios.js +172 -0
  122. package/react-native-google-maps.podspec +27 -0
  123. package/react-native-maps-generated.podspec +31 -0
  124. package/react-native-maps.podspec +52 -46
  125. package/react-native.config.js +16 -0
  126. package/src/AnimatedRegion.ts +169 -0
  127. package/src/Geojson.tsx +541 -0
  128. package/src/MapCallout.tsx +77 -0
  129. package/src/MapCalloutSubview.tsx +64 -0
  130. package/src/MapCircle.tsx +162 -0
  131. package/src/MapHeatmap.tsx +125 -0
  132. package/src/MapLocalTile.tsx +60 -0
  133. package/src/MapMarker.tsx +531 -0
  134. package/src/MapMarkerNativeComponent.ts +51 -0
  135. package/src/MapOverlay.tsx +178 -0
  136. package/src/MapPolygon.tsx +188 -0
  137. package/src/MapPolygon.types.ts +25 -0
  138. package/src/MapPolyline.tsx +215 -0
  139. package/src/MapUrlTile.tsx +169 -0
  140. package/src/MapView.tsx +1230 -0
  141. package/src/MapView.types.ts +212 -0
  142. package/src/MapView.web.ts +2 -0
  143. package/src/MapViewNativeComponent.ts +86 -0
  144. package/src/MapWMSTile.tsx +148 -0
  145. package/src/ProviderConstants.ts +2 -0
  146. package/src/createFabricMap.tsx +253 -0
  147. package/src/decorateMapComponent.ts +229 -0
  148. package/src/fixImageProp.ts +17 -0
  149. package/src/index.ts +52 -0
  150. package/src/sharedTypes.ts +101 -0
  151. package/{specs → src/specs}/NativeComponentCircle.ts +3 -4
  152. package/{specs → src/specs}/NativeComponentGoogleMapView.ts +15 -9
  153. package/{specs → src/specs}/NativeComponentMapView.ts +61 -32
  154. package/{specs → src/specs}/NativeComponentOverlay.ts +11 -2
  155. package/{specs → src/specs}/NativeComponentPolyline.ts +1 -1
  156. package/src/specs/NativeComponentUrlTile.ts +128 -0
  157. package/src/specs/NativeComponentWMSTile.ts +107 -0
  158. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -533
  159. package/lib/AnimatedRegion.d.ts +0 -19
  160. package/lib/AnimatedRegion.js +0 -134
  161. package/lib/Geojson.d.ts +0 -204
  162. package/lib/Geojson.js +0 -166
  163. package/lib/MapCallout.d.ts +0 -40
  164. package/lib/MapCallout.js +0 -51
  165. package/lib/MapCalloutSubview.d.ts +0 -34
  166. package/lib/MapCalloutSubview.js +0 -48
  167. package/lib/MapCircle.d.ts +0 -117
  168. package/lib/MapCircle.js +0 -53
  169. package/lib/MapHeatmap.d.ts +0 -78
  170. package/lib/MapHeatmap.js +0 -59
  171. package/lib/MapLocalTile.d.ts +0 -35
  172. package/lib/MapLocalTile.js +0 -44
  173. package/lib/MapMarker.d.ts +0 -322
  174. package/lib/MapMarker.js +0 -158
  175. package/lib/MapMarkerNativeComponent.d.ts +0 -15
  176. package/lib/MapMarkerNativeComponent.js +0 -15
  177. package/lib/MapOverlay.d.ts +0 -88
  178. package/lib/MapOverlay.js +0 -65
  179. package/lib/MapPolygon.d.ts +0 -140
  180. package/lib/MapPolygon.js +0 -53
  181. package/lib/MapPolygon.types.d.ts +0 -18
  182. package/lib/MapPolyline.d.ts +0 -156
  183. package/lib/MapPolyline.js +0 -53
  184. package/lib/MapUrlTile.d.ts +0 -134
  185. package/lib/MapUrlTile.js +0 -44
  186. package/lib/MapView.d.ts +0 -703
  187. package/lib/MapView.js +0 -427
  188. package/lib/MapView.types.d.ts +0 -161
  189. package/lib/MapView.types.js +0 -2
  190. package/lib/MapView.web.d.ts +0 -1
  191. package/lib/MapView.web.js +0 -9
  192. package/lib/MapViewNativeComponent.d.ts +0 -18
  193. package/lib/MapViewNativeComponent.js +0 -19
  194. package/lib/MapWMSTile.d.ts +0 -116
  195. package/lib/MapWMSTile.js +0 -44
  196. package/lib/ProviderConstants.d.ts +0 -2
  197. package/lib/ProviderConstants.js +0 -5
  198. package/lib/createFabricMap.d.ts +0 -24
  199. package/lib/createFabricMap.js +0 -188
  200. package/lib/decorateMapComponent.d.ts +0 -36
  201. package/lib/decorateMapComponent.js +0 -120
  202. package/lib/fixImageProp.d.ts +0 -4
  203. package/lib/fixImageProp.js +0 -16
  204. package/lib/index.d.ts +0 -38
  205. package/lib/index.js +0 -81
  206. package/lib/sharedTypes.d.ts +0 -81
  207. package/lib/sharedTypes.js +0 -2
  208. package/lib/sharedTypesInternal.js +0 -2
  209. package/lib/specs/NativeAirMapsModule.d.ts +0 -31
  210. package/lib/specs/NativeAirMapsModule.js +0 -4
  211. package/lib/specs/NativeComponentCallout.d.ts +0 -46
  212. package/lib/specs/NativeComponentCallout.js +0 -9
  213. package/lib/specs/NativeComponentCircle.d.ts +0 -74
  214. package/lib/specs/NativeComponentCircle.js +0 -7
  215. package/lib/specs/NativeComponentGoogleMapView.d.ts +0 -713
  216. package/lib/specs/NativeComponentGoogleMapView.js +0 -22
  217. package/lib/specs/NativeComponentGooglePolygon.d.ts +0 -75
  218. package/lib/specs/NativeComponentGooglePolygon.js +0 -7
  219. package/lib/specs/NativeComponentMapView.d.ts +0 -847
  220. package/lib/specs/NativeComponentMapView.js +0 -20
  221. package/lib/specs/NativeComponentMarker.d.ts +0 -258
  222. package/lib/specs/NativeComponentMarker.js +0 -19
  223. package/lib/specs/NativeComponentOverlay.d.ts +0 -67
  224. package/lib/specs/NativeComponentOverlay.js +0 -7
  225. package/lib/specs/NativeComponentPolyline.d.ts +0 -101
  226. package/lib/specs/NativeComponentPolyline.js +0 -7
  227. /package/ios/AirMaps/{UIView +AirMap.m → UIView+AirMap.m} +0 -0
  228. /package/ios/{AirMaps → generated}/RNMapsHostVewDelegate.h +0 -0
  229. /package/{lib/MapPolygon.types.js → plugin/build/types.js} +0 -0
  230. /package/{lib/sharedTypesInternal.d.ts → src/sharedTypesInternal.ts} +0 -0
  231. /package/{specs → src/specs}/NativeAirMapsModule.ts +0 -0
  232. /package/{specs → src/specs}/NativeComponentCallout.ts +0 -0
  233. /package/{specs → src/specs}/NativeComponentGooglePolygon.ts +0 -0
  234. /package/{specs → src/specs}/NativeComponentMarker.ts +0 -0
@@ -0,0 +1,1230 @@
1
+ import * as React from 'react';
2
+ import {
3
+ Animated as RNAnimated,
4
+ Animated,
5
+ findNodeHandle,
6
+ HostComponent,
7
+ NativeSyntheticEvent,
8
+ Platform,
9
+ requireNativeComponent,
10
+ ViewProps,
11
+ } from 'react-native';
12
+ import {
13
+ createNotSupportedComponent,
14
+ NativeComponent,
15
+ ProviderContext,
16
+ } from './decorateMapComponent';
17
+ import {
18
+ CalloutPressEvent,
19
+ ClickEvent,
20
+ Frame,
21
+ LatLng,
22
+ MarkerDeselectEvent,
23
+ MarkerDragEvent,
24
+ MarkerDragStartEndEvent,
25
+ MarkerPressEvent,
26
+ MarkerSelectEvent,
27
+ Point,
28
+ Provider,
29
+ Region,
30
+ } from './sharedTypes';
31
+ import {
32
+ ActiveIndoorLevel,
33
+ Address,
34
+ BoundingBox,
35
+ Camera,
36
+ CameraZoomRange,
37
+ ChangeEvent,
38
+ Details,
39
+ EdgePadding,
40
+ FitToOptions,
41
+ IndoorBuilding,
42
+ KmlMapEvent,
43
+ LongPressEvent,
44
+ MapPressEvent,
45
+ MapStyleElement,
46
+ MapType,
47
+ MapTypes,
48
+ PanDragEvent,
49
+ PoiClickEvent,
50
+ SnapshotOptions,
51
+ UserLocationChangeEvent,
52
+ } from './MapView.types';
53
+ import {Modify} from './sharedTypesInternal';
54
+ import {Commands, MapViewNativeComponentType} from './MapViewNativeComponent';
55
+
56
+ import FabricMapView, {
57
+ Commands as FabricCommands,
58
+ MapFabricNativeProps,
59
+ } from './specs/NativeComponentMapView';
60
+ import GoogleMapView, {
61
+ Commands as GoogleCommands,
62
+ } from './specs/NativeComponentGoogleMapView';
63
+ import createFabricMap, {FabricMapHandle} from './createFabricMap';
64
+
65
+ const FabricMap = createFabricMap(FabricMapView, FabricCommands);
66
+ var FabricGoogleMap: any = null;
67
+ if (Platform.OS === 'ios') {
68
+ FabricGoogleMap = createFabricMap(GoogleMapView, GoogleCommands);
69
+ }
70
+ import AnimatedRegion from './AnimatedRegion';
71
+
72
+ export const MAP_TYPES: MapTypes = {
73
+ STANDARD: 'standard',
74
+ SATELLITE: 'satellite',
75
+ HYBRID: 'hybrid',
76
+ TERRAIN: 'terrain',
77
+ NONE: 'none',
78
+ MUTEDSTANDARD: 'mutedStandard',
79
+ SATELLITE_FLYOVER: 'satelliteFlyover',
80
+ HYBRID_FLYOVER: 'hybridFlyover',
81
+ };
82
+
83
+ export type MapViewProps = ViewProps & {
84
+ /**
85
+ * If `true` map will be cached and displayed as an image instead of being interactable, for performance usage.
86
+ *
87
+ * @default false
88
+ * @platform iOS: Apple Maps only
89
+ * @platform Android: Supported
90
+ */
91
+ cacheEnabled?: boolean;
92
+
93
+ /**
94
+ * The camera view the map should display.
95
+ *
96
+ * Use the camera system, instead of the region system, if you need control over
97
+ * the pitch or heading. Using this will ignore the `region` property.
98
+ * @platform iOS: Supported
99
+ * @platform Android: Supported
100
+ */
101
+ camera?: Camera;
102
+
103
+ /**
104
+ * If set, changes the position of the compass.
105
+ *
106
+ * @platform iOS: Apple Maps only
107
+ * @platform Android: Not supported
108
+ */
109
+ compassOffset?: Point;
110
+
111
+ /**
112
+ * Adds custom styling to the map component.
113
+ * See [README](https://github.com/react-native-maps/react-native-maps#customizing-the-map-style) for more information.
114
+ *
115
+ * @platform iOS: Google Maps only
116
+ * @platform Android: Supported
117
+ */
118
+ customMapStyle?: MapStyleElement[];
119
+
120
+ /**
121
+ * If `true` the map will focus on the user's location.
122
+ * This only works if `showsUserLocation` is true and the user has shared their location.
123
+ *
124
+ * @default false
125
+ * @platform iOS: Apple Maps only
126
+ * @platform Android: Not supported
127
+ */
128
+ followsUserLocation?: boolean;
129
+
130
+ /**
131
+ * If `false` the map will not capture PoI clicks
132
+ * This can improve click handling on the map for android
133
+ *
134
+ * @default true
135
+ * @platform iOS: Not supported
136
+ * @platform Android: supported
137
+ */
138
+ poiClickEnabled?: boolean;
139
+
140
+ /**
141
+ * The initial camera view the map should use. Use this prop instead of `camera`
142
+ * only if you don't want to control the camera of the map besides the initial view.
143
+ *
144
+ * Use the camera system, instead of the region system, if you need control over
145
+ * the pitch or heading.
146
+ *
147
+ * Changing this prop after the component has mounted will not result in a camera change.
148
+ *
149
+ * This is similar to the `initialValue` prop of a text input.
150
+ *
151
+ * @platform iOS: Supported
152
+ * @platform Android: Supported
153
+ */
154
+ initialCamera?: Camera;
155
+
156
+ /**
157
+ * The initial region to be displayed by the map. Use this prop instead of `region`
158
+ * only if you don't want to control the viewport of the map besides the initial region.
159
+ *
160
+ * Changing this prop after the component has mounted will not result in a region change.
161
+ *
162
+ * This is similar to the `initialValue` prop of a text input.
163
+ *
164
+ * @platform iOS: Supported
165
+ * @platform Android: Supported
166
+ */
167
+ initialRegion?: Region;
168
+
169
+ /**
170
+ * The URL for KML file.
171
+ *
172
+ * @platform iOS: Google Maps only
173
+ * @platform Android: Supported
174
+ */
175
+ kmlSrc?: string;
176
+
177
+ /**
178
+ * If set, changes the position of the "Legal" label link in Apple Maps.
179
+ *
180
+ * @platform iOS: Apple Maps only
181
+ * @platform Android: Not supported
182
+ */
183
+ legalLabelInsets?: EdgePadding;
184
+
185
+ /**
186
+ * Enables lite mode on Android
187
+ *
188
+ * @platform iOS: Not supported
189
+ * @platform Android: Supported
190
+ */
191
+ liteMode?: boolean;
192
+
193
+ /**
194
+ * https://developers.google.com/maps/documentation/get-map-id
195
+ * google cloud mapId to enable cloud styling and more
196
+ */
197
+ googleMapId?: string;
198
+
199
+ /**
200
+ * https://developers.google.com/maps/documentation/android-sdk/renderer
201
+ * google maps renderer
202
+ * @default `LATEST`
203
+ * @platform iOS: Not supported
204
+ * @platform Android: Supported
205
+ */
206
+ googleRenderer?: 'LATEST' | 'LEGACY';
207
+
208
+ /**
209
+ * Sets loading background color.
210
+ *
211
+ * @default `#FFFFFF`
212
+ * @platform iOS: Supported
213
+ * @platform Android: Supported
214
+ */
215
+ loadingBackgroundColor?: string;
216
+
217
+ /**
218
+ * If `true` a loading indicator will show while the map is loading.
219
+ *
220
+ * @default false
221
+ * @platform iOS: Apple Maps only
222
+ * @platform Android: Supported
223
+ */
224
+ loadingEnabled?: boolean;
225
+
226
+ /**
227
+ * Sets loading indicator color.
228
+ *
229
+ * @default `#606060`
230
+ * @platform iOS: Apple Maps only
231
+ * @platform Android: Supported
232
+ */
233
+ loadingIndicatorColor?: string;
234
+
235
+ /**
236
+ * Adds custom padding to each side of the map. Useful when map elements/markers are obscured.
237
+ *
238
+ * @platform iOS: Supported
239
+ * @platform Android: Supported
240
+ */
241
+ mapPadding?: EdgePadding;
242
+
243
+ /**
244
+ * The map type to be displayed
245
+ *
246
+ * @default `standard`
247
+ * @platform iOS: hybrid | mutedStandard | satellite | standard | terrain | hybridFlyover | satelliteFlyover
248
+ * @platform Android: hybrid | none | satellite | standard | terrain
249
+ */
250
+ mapType?: MapType;
251
+
252
+ /**
253
+ * TODO: Add documentation
254
+ *
255
+ * @platform iOS: Apple Maps only
256
+ * @platform Android: Not supported
257
+ */
258
+ maxDelta?: number;
259
+
260
+ /**
261
+ * Maximum zoom value for the map, must be between 0 and 20
262
+ *
263
+ * @default 20
264
+ * @platform iOS: Supported
265
+ * @platform Android: Supported
266
+ * @deprecated on Apple Maps, use `cameraZoomRange` instead
267
+ */
268
+ maxZoomLevel?: number;
269
+
270
+ /**
271
+ * TODO: Add documentation
272
+ *
273
+ * @platform iOS: Apple Maps only
274
+ * @platform Android: Not supported
275
+ */
276
+ minDelta?: number;
277
+
278
+ /**
279
+ * Minimum zoom value for the map, must be between 0 and 20
280
+ *
281
+ * @default 0
282
+ * @platform iOS: Supported
283
+ * @platform Android: Supported
284
+ * @deprecated on Apple Maps, use `cameraZoomRange` instead
285
+ */
286
+ minZoomLevel?: number;
287
+
288
+ /**
289
+ * If `false` the map won't move to the marker when pressed.
290
+ *
291
+ * @default true
292
+ * @platform iOS: Not supported
293
+ * @platform Android: Supported
294
+ */
295
+ moveOnMarkerPress?: boolean;
296
+
297
+ /**
298
+ * Callback that is called when a callout is tapped by the user.
299
+ *
300
+ * @platform iOS: Apple Maps only
301
+ * @platform Android: Supported
302
+ */
303
+ onCalloutPress?: (event: CalloutPressEvent) => void;
304
+
305
+ /**
306
+ * Callback that is called when user double taps on the map.
307
+ *
308
+ * @platform iOS: Apple Maps only
309
+ * @platform Android: Supported
310
+ */
311
+ onDoublePress?: (event: ClickEvent) => void;
312
+
313
+ /**
314
+ * Callback that is called when an indoor building is focused/unfocused
315
+ *
316
+ * @platform iOS: Google Maps only
317
+ * @platform Android: Supported
318
+ */
319
+ onIndoorBuildingFocused?: (indoorBuilding: IndoorBuilding) => void;
320
+
321
+ /**
322
+ * Callback that is called when a level on indoor building is activated
323
+ *
324
+ * @platform iOS: Google Maps only
325
+ * @platform Android: Supported
326
+ */
327
+ onIndoorLevelActivated?: (indoorLevel: ActiveIndoorLevel) => void;
328
+
329
+ /**
330
+ * Callback that is called once the kml is fully loaded.
331
+ *
332
+ * @platform iOS: Google Maps only
333
+ * @platform Android: Supported
334
+ */
335
+ onKmlReady?: (event: KmlMapEvent) => void;
336
+
337
+ /**
338
+ * Callback that is called when user makes a "long press" somewhere on the map.
339
+ *
340
+ * @platform iOS: Supported
341
+ * @platform Android: Supported
342
+ */
343
+ onLongPress?: (event: LongPressEvent) => void;
344
+
345
+ /**
346
+ * Callback that is called when the map has finished rendering all tiles.
347
+ *
348
+ * @platform iOS: Google Maps only
349
+ * @platform Android: Supported
350
+ */
351
+ onMapLoaded?: (event: NativeSyntheticEvent<null>) => void;
352
+
353
+ /**
354
+ * Callback that is called once the map is ready.
355
+ *
356
+ * Event is optional, as the first onMapReady callback is intercepted
357
+ * on Android, and the event is not passed on.
358
+ *
359
+ * @platform iOS: Supported
360
+ * @platform Android: Supported
361
+ */
362
+ onMapReady?: (event?: NativeSyntheticEvent<null>) => void;
363
+
364
+ /**
365
+ * Callback that is called when a marker on the map becomes deselected.
366
+ * This will be called when the callout for that marker is about to be hidden.
367
+ *
368
+ * @platform iOS: Supported
369
+ * @platform Android: Supported
370
+ */
371
+ onMarkerDeselect?: (event: MarkerDeselectEvent) => void;
372
+
373
+ /**
374
+ * Callback called continuously as a marker is dragged
375
+ *
376
+ * @platform iOS: Apple Maps only
377
+ * @platform Android: Supported
378
+ */
379
+ onMarkerDrag?: (event: MarkerDragEvent) => void;
380
+
381
+ /**
382
+ * Callback that is called when a drag on a marker finishes.
383
+ * This is usually the point you will want to setState on the marker's coordinate again
384
+ *
385
+ * @platform iOS: Apple Maps only
386
+ * @platform Android: Supported
387
+ */
388
+ onMarkerDragEnd?: (event: MarkerDragStartEndEvent) => void;
389
+
390
+ /**
391
+ * Callback that is called when the user initiates a drag on a marker (if it is draggable)
392
+ *
393
+ * @platform iOS: Apple Maps only
394
+ * @platform Android: Supported
395
+ */
396
+ onMarkerDragStart?: (event: MarkerDragStartEndEvent) => void;
397
+
398
+ /**
399
+ * Callback that is called when a marker on the map is tapped by the user.
400
+ *
401
+ * @platform iOS: Supported
402
+ * @platform Android: Supported
403
+ */
404
+ onMarkerPress?: (event: MarkerPressEvent) => void;
405
+
406
+ /**
407
+ * Callback that is called when a marker on the map becomes selected.
408
+ * This will be called when the callout for that marker is about to be shown.
409
+ *
410
+ * @platform iOS: Supported.
411
+ * @platform Android: Supported
412
+ */
413
+ onMarkerSelect?: (event: MarkerSelectEvent) => void;
414
+
415
+ /**
416
+ * Callback that is called when user presses and drags the map.
417
+ * **NOTE**: for iOS `scrollEnabled` should be set to false to trigger the event
418
+ *
419
+ * @platform iOS: Supported
420
+ * @platform Android: Supported
421
+ */
422
+ onPanDrag?: (event: PanDragEvent) => void;
423
+
424
+ /**
425
+ * Callback that is called when user click on a POI.
426
+ *
427
+ * @platform iOS: Google Maps only
428
+ * @platform Android: Supported
429
+ */
430
+ onPoiClick?: (event: PoiClickEvent) => void;
431
+
432
+ /**
433
+ * Callback that is called when user taps on the map.
434
+ *
435
+ * @platform iOS: Supported
436
+ * @platform Android: Supported
437
+ */
438
+ onPress?: (event: MapPressEvent) => void;
439
+
440
+ /**
441
+ * Callback that is called once before the region changes, such as when the user starts moving the map.
442
+ * `isGesture` property indicates if the move was from the user (true) or an animation (false).
443
+ * **Note**: `isGesture` is supported by Google Maps only.
444
+ *
445
+ * @platform iOS: Supported
446
+ * @platform Android: Supported
447
+ */
448
+ onRegionChangeStart?: (event: NativeSyntheticEvent<Details>) => void;
449
+
450
+ /**
451
+ * Callback that is called continuously when the region changes, such as when a user is dragging the map.
452
+ * `isGesture` property indicates if the move was from the user (true) or an animation (false).
453
+ * **Note**: `isGesture` is supported by Google Maps only.
454
+ *
455
+ * @platform iOS: Supported
456
+ * @platform Android: Supported
457
+ */
458
+ onRegionChange?: (region: Region, details: Details) => void;
459
+
460
+ /**
461
+ * Callback that is called once when the region changes, such as when the user is done moving the map.
462
+ * `isGesture` property indicates if the move was from the user (true) or an animation (false).
463
+ * **Note**: `isGesture` is supported by Google Maps only.
464
+ *
465
+ * @platform iOS: Supported
466
+ * @platform Android: Supported
467
+ */
468
+ onRegionChangeComplete?: (region: Region, details: Details) => void;
469
+
470
+ /**
471
+ * Callback that is called when the underlying map figures our users current location
472
+ * (coordinate also includes isFromMockProvider value for Android API 18 and above).
473
+ * Make sure **showsUserLocation** is set to *true*.
474
+ *
475
+ * @platform iOS: Supported
476
+ * @platform Android: Supported
477
+ */
478
+ onUserLocationChange?: (event: UserLocationChangeEvent) => void;
479
+
480
+ /**
481
+ * Indicates how/when to affect padding with safe area insets
482
+ *
483
+ * @platform iOS: Google Maps only
484
+ * @platform Android: Not supported
485
+ */
486
+ paddingAdjustmentBehavior?: 'always' | 'automatic' | 'never';
487
+
488
+ /**
489
+ * If `false` the user won't be able to adjust the camera’s pitch angle.
490
+ *
491
+ * @default true
492
+ * @platform iOS: Google Maps only
493
+ * @platform Android: Supported
494
+ */
495
+ pitchEnabled?: boolean;
496
+
497
+ /**
498
+ * The map framework to use.
499
+ * Either `"google"` for GoogleMaps, otherwise `undefined` to use the native map framework (`MapKit` in iOS and `GoogleMaps` in android).
500
+ *
501
+ * @platform iOS: Supported
502
+ * @platform Android: Supported
503
+ */
504
+ provider?: Provider;
505
+
506
+ /**
507
+ * The region to be displayed by the map.
508
+ * The region is defined by the center coordinates and the span of coordinates to display.
509
+ *
510
+ * @platform iOS: Supported
511
+ * @platform Android: Supported
512
+ */
513
+ region?: Region | AnimatedRegion;
514
+
515
+ /**
516
+ * If `false` the user won't be able to adjust the camera’s pitch angle.
517
+ *
518
+ * @default true
519
+ * @platform iOS: Google Maps only
520
+ * @platform Android: Supported
521
+ */
522
+ rotateEnabled?: boolean;
523
+
524
+ /**
525
+ * If `false` the map will stay centered while rotating or zooming.
526
+ *
527
+ * @default true
528
+ * @platform iOS: Google Maps only
529
+ * @platform Android: Supported
530
+ */
531
+ scrollDuringRotateOrZoomEnabled?: boolean;
532
+
533
+ /**
534
+ * If `false` the user won't be able to change the map region being displayed.
535
+ *
536
+ * @default true
537
+ * @platform iOS: Supported
538
+ * @platform Android: Supported
539
+ */
540
+ scrollEnabled?: boolean;
541
+
542
+ /**
543
+ * A Boolean indicating whether the map displays extruded building information.
544
+ *
545
+ * @default true
546
+ * @platform iOS: Not supported
547
+ * @platform Android: Supported
548
+ */
549
+ showsBuildings?: boolean;
550
+
551
+ /**
552
+ * If `false` compass won't be displayed on the map.
553
+ *
554
+ * @default true
555
+ * @platform iOS: Supported (adaptive on Apple Maps, visible only if map is not pointing north)
556
+ * @platform Android: Supported
557
+ */
558
+ showsCompass?: boolean;
559
+
560
+ /**
561
+ * A Boolean indicating whether indoor level picker should be enabled.
562
+ *
563
+ * @default false
564
+ * @platform iOS: Google Maps only
565
+ * @platform Android: Supported
566
+ */
567
+ showsIndoorLevelPicker?: boolean;
568
+
569
+ /**
570
+ * A Boolean indicating whether indoor maps should be enabled.
571
+ *
572
+ * @default true
573
+ * @platform iOS: Google Maps only
574
+ * @platform Android: Supported
575
+ */
576
+ showsIndoors?: boolean;
577
+
578
+ /**
579
+ * If `false` hide the button to move map to the current user's location.
580
+ *
581
+ * @default true
582
+ * @platform iOS: Google Maps only
583
+ * @platform Android: Supported
584
+ */
585
+ showsMyLocationButton?: boolean;
586
+
587
+ /**
588
+ * A Boolean indicating whether the map shows scale information.
589
+ *
590
+ * @default false
591
+ * @platform iOS: Apple Maps only
592
+ * @platform Android: Not supported
593
+ */
594
+ showsScale?: boolean;
595
+
596
+ /**
597
+ * If `true` the users location will be displayed on the map.
598
+ *
599
+ * This will cause iOS to ask for location permissions.
600
+ * For iOS see: [DOCS](https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md#set-the-usage-description-property)
601
+ * @default false
602
+ * @platform iOS: Supported
603
+ * @platform Android: Supported
604
+ */
605
+ showsUserLocation?: boolean;
606
+
607
+ /**
608
+ * Sets the tint color of the map. (Changes the color of the position indicator)
609
+ *
610
+ * @default System Blue
611
+ * @platform iOS: Apple Maps only
612
+ * @platform Android: Not supported
613
+ */
614
+ tintColor?: string;
615
+
616
+ /**
617
+ * If `false` will hide 'Navigate' and 'Open in Maps' buttons on marker press
618
+ *
619
+ * @default true
620
+ * @platform iOS: Not supported
621
+ * @platform Android: Supported
622
+ */
623
+ toolbarEnabled?: boolean;
624
+
625
+ /**
626
+ * Sets the map to the style selected.
627
+ *
628
+ * @default System setting
629
+ * @platform iOS: Supported
630
+ * @platform Android: Supported
631
+ */
632
+ userInterfaceStyle?: 'light' | 'dark';
633
+
634
+ /**
635
+ * The title of the annotation for current user location.
636
+ *
637
+ * This only works if `showsUserLocation` is true.
638
+ *
639
+ * @default `My Location`
640
+ * @platform iOS: Apple Maps only
641
+ * @platform Android: Not supported
642
+ */
643
+ userLocationAnnotationTitle?: string;
644
+
645
+ /**
646
+ * If `true` clicking user location will show the default callout for userLocation annotation.
647
+ *
648
+ * @default false
649
+ * @platform iOS: Apple Maps only
650
+ * @platform Android: Not supported
651
+ */
652
+ userLocationCalloutEnabled?: boolean;
653
+
654
+ /**
655
+ * Fastest interval the application will actively acquire locations.
656
+ *
657
+ * See [Google APIs documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html)
658
+ *
659
+ * @default 5000
660
+ * @platform iOS: Not supported
661
+ * @platform Android: Supported
662
+ */
663
+ userLocationFastestInterval?: number;
664
+
665
+ /**
666
+ * Set power priority of user location tracking.
667
+ *
668
+ * See [Google APIs documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html)
669
+ *
670
+ * @default `high`
671
+ * @platform iOS: Not supported
672
+ * @platform Android: Supported
673
+ */
674
+ userLocationPriority?: 'balanced' | 'high' | 'low' | 'passive';
675
+
676
+ /**
677
+ * Interval of user location updates in milliseconds.
678
+ *
679
+ * See [Google APIs documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html)
680
+ *
681
+ * @default 5000
682
+ * @platform iOS: Not supported
683
+ * @platform Android: Supported
684
+ */
685
+ userLocationUpdateInterval?: number;
686
+
687
+ /**
688
+ * If `false` the zoom control at the bottom right of the map won't be visible.
689
+ *
690
+ * @default true
691
+ * @platform iOS: Not supported
692
+ * @platform Android: Supported
693
+ */
694
+ zoomControlEnabled?: boolean;
695
+
696
+ /**
697
+ * If `false` the user won't be able to pinch/zoom the map.
698
+ *
699
+ * TODO: Why is the Android reactprop defaultvalue set to false?
700
+ *
701
+ * @default true
702
+ * @platform iOS: Supported
703
+ * @platform Android: Supported
704
+ */
705
+ zoomEnabled?: boolean;
706
+
707
+ /**
708
+ * If `false` the user won't be able to double tap to zoom the map.
709
+ * **Note:** But it will greatly decrease delay of tap gesture recognition.
710
+ *
711
+ * @default true
712
+ * @platform iOS: Google Maps only
713
+ * @platform Android: Not supported
714
+ */
715
+ zoomTapEnabled?: boolean;
716
+
717
+ /**
718
+ * Map camera distance limits. `minCenterCoordinateDistance` for minimum distance, `maxCenterCoordinateDistance` for maximum.
719
+ * `animated` for animated zoom changes.
720
+ * Takes precedence if conflicting with `minZoomLevel`, `maxZoomLevel`.
721
+ *
722
+ * @platform iOS: 13.0+
723
+ * @platform Android: Not supported
724
+ */
725
+ cameraZoomRange?: CameraZoomRange;
726
+ };
727
+
728
+ type ModifiedProps = Modify<
729
+ MapViewProps,
730
+ {
731
+ region?: MapViewProps['region'] | null;
732
+ initialRegion?: MapViewProps['initialRegion'] | null;
733
+ }
734
+ >;
735
+
736
+ export type NativeProps = Omit<
737
+ ModifiedProps,
738
+ 'customMapStyle' | 'onRegionChange' | 'onRegionChangeComplete'
739
+ > & {
740
+ ref: React.RefObject<MapViewNativeComponentType | null>;
741
+ customMapStyleString?: string;
742
+ handlePanDrag?: boolean;
743
+ onChange?: (e: ChangeEvent) => void;
744
+ };
745
+
746
+ type State = {
747
+ isReady: boolean;
748
+ };
749
+
750
+ class MapView extends React.Component<MapViewProps, State> {
751
+ static Animated: Animated.AnimatedComponent<typeof MapView>;
752
+ private map: NativeProps['ref'];
753
+
754
+ private fabricMap =
755
+ React.createRef<FabricMapHandle | null>() as React.RefObject<FabricMapHandle>;
756
+
757
+ constructor(props: MapViewProps) {
758
+ super(props);
759
+
760
+ this.map = React.createRef<MapViewNativeComponentType>();
761
+ this.fabricMap = React.createRef<FabricMapHandle>();
762
+ this.state = {
763
+ isReady: false,
764
+ };
765
+
766
+ this._onMapReady = this._onMapReady.bind(this);
767
+ this._onChange = this._onChange.bind(this);
768
+ }
769
+
770
+ setNativeProps(props: Partial<NativeProps>) {
771
+ // @ts-ignore
772
+ this.map.current?.setNativeProps(props);
773
+ }
774
+
775
+ private _onMapReady() {
776
+ const {onMapReady} = this.props;
777
+ this.setState({isReady: true}, () => {
778
+ if (onMapReady) {
779
+ onMapReady();
780
+ }
781
+ });
782
+ }
783
+
784
+ private _onChange({nativeEvent}: ChangeEvent) {
785
+ const isGesture = nativeEvent.isGesture;
786
+ const details = {isGesture};
787
+
788
+ if (nativeEvent.continuous) {
789
+ if (this.props.onRegionChange) {
790
+ this.props.onRegionChange(nativeEvent.region, details);
791
+ }
792
+ } else if (this.props.onRegionChangeComplete) {
793
+ this.props.onRegionChangeComplete(nativeEvent.region, details);
794
+ }
795
+ }
796
+
797
+ getCamera(): Promise<Camera> {
798
+ if (this.fabricMap.current) {
799
+ return this.fabricMap.current.getCamera();
800
+ }
801
+ return Promise.reject('getCamera not supported on this platform');
802
+ }
803
+
804
+ setCamera(camera: Partial<Camera>) {
805
+ if (this.fabricMap.current) {
806
+ this.fabricMap.current.setCamera(camera);
807
+ } else if (this.map.current) {
808
+ Commands.setCamera(this.map.current, camera);
809
+ }
810
+ }
811
+
812
+ animateCamera(camera: Partial<Camera>, opts?: {duration?: number}) {
813
+ if (this.fabricMap.current) {
814
+ this.fabricMap.current.animateCamera(
815
+ camera,
816
+ opts?.duration ? opts.duration : 500,
817
+ );
818
+ } else if (this.map.current) {
819
+ Commands.animateCamera(
820
+ this.map.current,
821
+ camera,
822
+ opts?.duration ? opts.duration : 500,
823
+ );
824
+ }
825
+ }
826
+
827
+ animateToRegion(region: Region, duration: number = 500) {
828
+ if (this.fabricMap.current) {
829
+ this.fabricMap.current.animateToRegion(region, duration);
830
+ } else if (this.map.current) {
831
+ Commands.animateToRegion(this.map.current, region, duration);
832
+ }
833
+ }
834
+ setRegion(region: Region) {
835
+ if (this.fabricMap.current) {
836
+ this.fabricMap.current.animateToRegion(region, 0);
837
+ }
838
+ //TODO fix for android
839
+ }
840
+
841
+ fitToElements(options: FitToOptions = {}) {
842
+ const {
843
+ edgePadding = {top: 0, right: 0, bottom: 0, left: 0},
844
+ animated = true,
845
+ } = options;
846
+ if (this.fabricMap.current) {
847
+ this.fabricMap.current.fitToElements(edgePadding, animated);
848
+ } else if (this.map.current) {
849
+ Commands.fitToElements(this.map.current, edgePadding, animated);
850
+ }
851
+ }
852
+
853
+ fitToSuppliedMarkers(markers: string[], options: FitToOptions = {}) {
854
+ const {
855
+ edgePadding = {top: 0, right: 0, bottom: 0, left: 0},
856
+ animated = true,
857
+ } = options;
858
+ if (this.fabricMap.current) {
859
+ this.fabricMap.current.fitToSuppliedMarkers(
860
+ markers,
861
+ edgePadding,
862
+ animated,
863
+ );
864
+ } else if (this.map.current) {
865
+ Commands.fitToSuppliedMarkers(
866
+ this.map.current,
867
+ markers,
868
+ edgePadding,
869
+ animated,
870
+ );
871
+ }
872
+ }
873
+
874
+ fitToCoordinates(coordinates: LatLng[] = [], options: FitToOptions = {}) {
875
+ const {
876
+ edgePadding = {top: 0, right: 0, bottom: 0, left: 0},
877
+ animated = true,
878
+ } = options;
879
+ if (this.fabricMap.current) {
880
+ this.fabricMap.current.fitToCoordinates(
881
+ coordinates,
882
+ edgePadding,
883
+ animated,
884
+ );
885
+ } else if (this.map.current) {
886
+ Commands.fitToCoordinates(
887
+ this.map.current,
888
+ coordinates,
889
+ edgePadding,
890
+ animated,
891
+ );
892
+ }
893
+ }
894
+
895
+ /**
896
+ * Get visible boudaries
897
+ *
898
+ * @return Promise Promise with the bounding box ({ northEast: <LatLng>, southWest: <LatLng> })
899
+ */
900
+ async getMapBoundaries(): Promise<BoundingBox> {
901
+ if (this.fabricMap.current) {
902
+ return this.fabricMap.current.getMapBoundaries();
903
+ }
904
+ return Promise.reject('getMapBoundaries not supported on this platform');
905
+ }
906
+
907
+ setMapBoundaries(northEast: LatLng, southWest: LatLng) {
908
+ if (this.map.current) {
909
+ Commands.setMapBoundaries(this.map.current, northEast, southWest);
910
+ }
911
+ }
912
+
913
+ setIndoorActiveLevelIndex(activeLevelIndex: number) {
914
+ if (this.fabricMap.current) {
915
+ return this.fabricMap.current.setIndoorActiveLevelIndex(activeLevelIndex);
916
+ }
917
+ return Promise.reject('getMapBoundaries not supported on this platform');
918
+ }
919
+
920
+ /**
921
+ * Takes a snapshot of the map and saves it to a picture
922
+ * file or returns the image as a base64 encoded string.
923
+ *
924
+ * @param args Configuration options
925
+ * @param [args.width] Width of the rendered map-view (when omitted actual view width is used).
926
+ * @param [args.height] Height of the rendered map-view (when omitted actual height is used).
927
+ * @param [args.region] Region to render (Only supported on iOS).
928
+ * @param [args.format] Encoding format ('png', 'jpg') (default: 'png').
929
+ * @param [args.quality] Compression quality (only used for jpg) (default: 1.0).
930
+ * @param [args.result] Result format ('file', 'base64') (default: 'file').
931
+ *
932
+ * @return Promise Promise with either the file-uri or base64 encoded string
933
+ */
934
+ takeSnapshot(args: SnapshotOptions): Promise<string> {
935
+ // Sanitize inputs
936
+ const config = {
937
+ width: args.width || 0,
938
+ height: args.height || 0,
939
+ region: args.region || {},
940
+ format: args.format || 'png',
941
+ quality: args.quality || 1.0,
942
+ result: args.result || 'file',
943
+ };
944
+ if (config.format !== 'png' && config.format !== 'jpg') {
945
+ throw new Error('Invalid format specified');
946
+ }
947
+ if (config.result !== 'file' && config.result !== 'base64') {
948
+ throw new Error('Invalid result specified');
949
+ }
950
+
951
+ if (this.fabricMap.current) {
952
+ // @ts-ignore
953
+ return this.fabricMap.current.takeSnapshot(config);
954
+ }
955
+ return Promise.reject('takeSnapshot not supported on this platform');
956
+ }
957
+
958
+ /**
959
+ * Convert a coordinate to address by using default Geocoder
960
+ *
961
+ * @param coordinate Coordinate
962
+ * @param [coordinate.latitude] Latitude
963
+ * @param [coordinate.longitude] Longitude
964
+ *
965
+ * @return Promise with return type Address
966
+ */
967
+ addressForCoordinate(coordinate: LatLng): Promise<Address> {
968
+ if (this.fabricMap.current) {
969
+ return this.fabricMap.current.getAddressFromCoordinates(coordinate);
970
+ }
971
+ return Promise.reject('getAddress not supported on this platform');
972
+ }
973
+
974
+ /**
975
+ * Convert a map coordinate to user-space point
976
+ *
977
+ * @param coordinate Coordinate
978
+ * @param [coordinate.latitude] Latitude
979
+ * @param [coordinate.longitude] Longitude
980
+ *
981
+ * @return Promise Promise with the point ({ x: Number, y: Number })
982
+ */
983
+ pointForCoordinate(coordinate: LatLng): Promise<Point> {
984
+ if (this.fabricMap.current) {
985
+ return this.fabricMap.current.getPointForCoordinate(coordinate);
986
+ }
987
+ return Promise.reject('pointForCoordinate not supported on this platform');
988
+ }
989
+
990
+ /**
991
+ * Convert a user-space point to a map coordinate
992
+ *
993
+ * @param point Point
994
+ * @param [point.x] X
995
+ * @param [point.x] Y
996
+ *
997
+ * @return Promise Promise with the coordinate ({ latitude: Number, longitude: Number })
998
+ */
999
+ coordinateForPoint(point: Point): Promise<LatLng> {
1000
+ if (this.fabricMap.current) {
1001
+ return this.fabricMap.current.getCoordinateForPoint(point);
1002
+ }
1003
+ return Promise.reject('coordinateForPoint not supported on this platform');
1004
+ }
1005
+
1006
+ /**
1007
+ * Get markers' centers and frames in user-space coordinates
1008
+ *
1009
+ * @param onlyVisible boolean true to include only visible markers, false to include all
1010
+ *
1011
+ * @return Promise Promise with { <identifier>: { point: Point, frame: Frame } }
1012
+ */
1013
+ getMarkersFrames(onlyVisible: boolean = false): Promise<{
1014
+ [key: string]: {point: Point; frame: Frame};
1015
+ }> {
1016
+ if (this.fabricMap.current) {
1017
+ // @ts-ignore
1018
+ return this.fabricMap.current.getMarkersFrames(onlyVisible);
1019
+ }
1020
+ return Promise.reject('getMarkersFrames not supported on this platform');
1021
+ }
1022
+
1023
+ /**
1024
+ * Get bounding box from region
1025
+ *
1026
+ * @param region Region
1027
+ *
1028
+ * @return Object Object bounding box ({ northEast: <LatLng>, southWest: <LatLng> })
1029
+ */
1030
+ boundingBoxForRegion(region: Region): BoundingBox {
1031
+ return {
1032
+ northEast: {
1033
+ latitude: region.latitude + region.latitudeDelta / 2,
1034
+ longitude: region.longitude + region.longitudeDelta / 2,
1035
+ },
1036
+ southWest: {
1037
+ latitude: region.latitude - region.latitudeDelta / 2,
1038
+ longitude: region.longitude - region.longitudeDelta / 2,
1039
+ },
1040
+ };
1041
+ }
1042
+
1043
+ private _getHandle() {
1044
+ return findNodeHandle(this.map.current);
1045
+ }
1046
+
1047
+ private handleMapPress = (event: any) => {
1048
+ if (this.props.onPress) {
1049
+ this.props.onPress(event);
1050
+ }
1051
+ };
1052
+
1053
+ private handleMarkerPress = (event: NativeSyntheticEvent<any>) => {
1054
+ if (this.props.onMarkerPress) {
1055
+ this.props.onMarkerPress(event);
1056
+ }
1057
+ };
1058
+
1059
+ private handleMarkerSelect = (event: NativeSyntheticEvent<any>) => {
1060
+ if (this.props.onMarkerSelect) {
1061
+ this.props.onMarkerSelect(event);
1062
+ }
1063
+ };
1064
+
1065
+ private handleKmlReady = (event: NativeSyntheticEvent<any>) => {
1066
+ if (this.props.onKmlReady) {
1067
+ this.props.onKmlReady(event);
1068
+ }
1069
+ };
1070
+
1071
+ private handleMarkerDeselect = (event: NativeSyntheticEvent<any>) => {
1072
+ if (this.props.onMarkerDeselect) {
1073
+ this.props.onMarkerDeselect(event);
1074
+ }
1075
+ };
1076
+ private handleRegionChange = (event: NativeSyntheticEvent<any>) => {
1077
+ const isGesture = event.nativeEvent.isGesture;
1078
+ const details = {isGesture};
1079
+ if (event.nativeEvent.continuous) {
1080
+ if (this.props.onRegionChange) {
1081
+ this.props.onRegionChange(event.nativeEvent.region, details);
1082
+ }
1083
+ } else if (this.props.onRegionChangeComplete) {
1084
+ this.props.onRegionChangeComplete(event.nativeEvent.region, details);
1085
+ }
1086
+ };
1087
+ private handleRegionChangeStarted = (event: NativeSyntheticEvent<any>) => {
1088
+ if (this.props.onRegionChangeStart) {
1089
+ this.props.onRegionChangeStart(event);
1090
+ }
1091
+ };
1092
+
1093
+ private handleIndoorBuildingFocused = (event: any) => {
1094
+ if (this.props.onIndoorBuildingFocused) {
1095
+ if (typeof event.nativeEvent.levels === 'string') {
1096
+ event.nativeEvent.levels = JSON.parse(event.nativeEvent.levels);
1097
+ }
1098
+ this.props.onIndoorBuildingFocused(event);
1099
+ }
1100
+ };
1101
+
1102
+ private handleIndoorLevelActivated = (event: any) => {
1103
+ if (this.props.onIndoorLevelActivated) {
1104
+ this.props.onIndoorLevelActivated(event);
1105
+ }
1106
+ };
1107
+
1108
+ private handleRegionChangeComplete = (event: NativeSyntheticEvent<any>) => {
1109
+ const isGesture = event.nativeEvent.isGesture;
1110
+ const details = {isGesture};
1111
+ if (this.props.onRegionChangeComplete) {
1112
+ this.props.onRegionChangeComplete(event.nativeEvent.region, details);
1113
+ }
1114
+ };
1115
+
1116
+ render() {
1117
+ // Define props specifically for MapFabricNativeProps
1118
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1119
+ const {
1120
+ onCalloutPress,
1121
+ onIndoorBuildingFocused,
1122
+ onKmlReady,
1123
+ onLongPress,
1124
+ onMarkerDeselect,
1125
+ onMarkerPress,
1126
+ onMarkerSelect,
1127
+ onRegionChangeStart,
1128
+ onRegionChange,
1129
+ onRegionChangeComplete,
1130
+ onPress,
1131
+ onMapReady,
1132
+ minZoomLevel,
1133
+ maxZoomLevel,
1134
+ region,
1135
+ provider,
1136
+ children,
1137
+ customMapStyle,
1138
+ ...restProps
1139
+ } = this.props;
1140
+
1141
+ /* eslint-enable @typescript-eslint/no-unused-vars */
1142
+ const userInterfaceStyle = this.props.userInterfaceStyle || 'system';
1143
+ const customMapStyleString = customMapStyle
1144
+ ? JSON.stringify(this.props.customMapStyle)
1145
+ : undefined;
1146
+
1147
+ const props: MapFabricNativeProps = {
1148
+ onMapReady: this._onMapReady,
1149
+ liteMode: this.props.liteMode,
1150
+ googleMapId: this.props.googleMapId,
1151
+ googleRenderer: this.props.googleRenderer,
1152
+ onPress: this.handleMapPress,
1153
+ onMarkerPress: this.handleMarkerPress,
1154
+ onMarkerSelect: this.handleMarkerSelect,
1155
+ onMarkerDeselect: this.handleMarkerDeselect,
1156
+ onKmlReady: this.handleKmlReady,
1157
+ userInterfaceStyle: userInterfaceStyle,
1158
+ customMapStyleString,
1159
+ minZoom: minZoomLevel,
1160
+ maxZoom: maxZoomLevel,
1161
+ onRegionChange: this.handleRegionChange,
1162
+ onRegionChangeStart: this.handleRegionChangeStarted,
1163
+ onRegionChangeComplete: this.handleRegionChangeComplete,
1164
+ onIndoorBuildingFocused: this.handleIndoorBuildingFocused,
1165
+ // @ts-ignore
1166
+ onIndoorLevelActivated: this.handleIndoorLevelActivated,
1167
+ ...restProps,
1168
+ };
1169
+ if (this.props.region) {
1170
+ props.region = {
1171
+ latitude: this.props.region.latitude,
1172
+ longitude: this.props.region.longitude,
1173
+ latitudeDelta: this.props.region.latitudeDelta,
1174
+ longitudeDelta: this.props.region.longitudeDelta,
1175
+ };
1176
+ }
1177
+
1178
+ if (this.state.isReady) {
1179
+ if (props.onPanDrag) {
1180
+ props.handlePanDrag = !!props.onPanDrag;
1181
+ }
1182
+ } else {
1183
+ props.style = this.props.style;
1184
+ props.initialCamera = this.props.initialCamera;
1185
+ props.onLayout = this.props.onLayout;
1186
+ }
1187
+
1188
+ const childrenNodes = this.state.isReady ? children : null;
1189
+
1190
+ if (provider === 'google' && Platform.OS === 'ios') {
1191
+ return (
1192
+ <ProviderContext.Provider value={this.props.provider}>
1193
+ <FabricGoogleMap {...props} ref={this.fabricMap}>
1194
+ {childrenNodes}
1195
+ </FabricGoogleMap>
1196
+ </ProviderContext.Provider>
1197
+ );
1198
+ } else {
1199
+ return (
1200
+ <ProviderContext.Provider value={this.props.provider}>
1201
+ <FabricMap {...props} ref={this.fabricMap}>
1202
+ {childrenNodes}
1203
+ </FabricMap>
1204
+ </ProviderContext.Provider>
1205
+ );
1206
+ }
1207
+ }
1208
+ }
1209
+
1210
+ const airMaps: {
1211
+ default: HostComponent<NativeProps>;
1212
+ google: NativeComponent<NativeProps>;
1213
+ } = {
1214
+ default: requireNativeComponent<NativeProps>('AIRMap'),
1215
+ google: () => null,
1216
+ };
1217
+
1218
+ if (Platform.OS === 'android') {
1219
+ airMaps.google = airMaps.default;
1220
+ } else {
1221
+ airMaps.google = createNotSupportedComponent(
1222
+ 'react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS.',
1223
+ );
1224
+ }
1225
+
1226
+ export const AnimatedMapView = RNAnimated.createAnimatedComponent(MapView);
1227
+
1228
+ MapView.Animated = AnimatedMapView;
1229
+
1230
+ export default MapView;