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,178 @@
1
+ import * as React from 'react';
2
+ import {
3
+ StyleSheet,
4
+ Animated,
5
+ ViewProps,
6
+ ImageURISource,
7
+ ImageRequireSource,
8
+ NativeSyntheticEvent,
9
+ Platform,
10
+ } from 'react-native';
11
+
12
+ import decorateMapComponent, {
13
+ MapManagerCommand,
14
+ NativeComponent,
15
+ ProviderContext,
16
+ SUPPORTED,
17
+ UIManagerCommand,
18
+ USES_DEFAULT_IMPLEMENTATION,
19
+ } from './decorateMapComponent';
20
+ import {LatLng, Point} from './sharedTypes';
21
+ import {Modify} from './sharedTypesInternal';
22
+ import {fixImageProp} from './fixImageProp';
23
+
24
+ export type MapOverlayProps = ViewProps & {
25
+ /**
26
+ * The bearing in degrees clockwise from north. Values outside the range [0, 360) will be normalized.
27
+ *
28
+ * @default 0
29
+ * @platform iOS: Google Maps only
30
+ * @platform Android: Supported
31
+ */
32
+ bearing?: number;
33
+
34
+ /**
35
+ * The coordinates for the image (left-top corner, right-bottom corner). ie.```[[lat, long], [lat, long]]```
36
+ *
37
+ * @platform iOS: Supported
38
+ * @platform Android: Supported
39
+ */
40
+ bounds: [Coordinate, Coordinate];
41
+
42
+ /**
43
+ * A custom image to be used as the overlay.
44
+ * Only required local image resources and uri (as for images located in the net) are allowed to be used.
45
+ *
46
+ * @platform iOS: Supported
47
+ * @platform Android: Supported
48
+ */
49
+ image: ImageURISource | ImageRequireSource;
50
+
51
+ /**
52
+ * Callback that is called when the user presses on the overlay
53
+ *
54
+ * @platform iOS: Apple Maps only
55
+ * @platform Android: Supported
56
+ */
57
+ onPress?: (event: OverlayPressEvent) => void;
58
+
59
+ /**
60
+ * The opacity of the overlay.
61
+ *
62
+ * @default 1
63
+ * @platform iOS: Google Maps only
64
+ * @platform Android: Supported
65
+ */
66
+ opacity?: number;
67
+
68
+ /**
69
+ * Boolean to allow an overlay to be tappable and use the onPress function.
70
+ *
71
+ * @default false
72
+ * @platform iOS: Not supported
73
+ * @platform Android: Supported
74
+ */
75
+ tappable?: boolean;
76
+ };
77
+
78
+ type NativeProps = Modify<MapOverlayProps, {image?: string}>;
79
+
80
+ function normalizeBounds(bounds: [number, number][]): any {
81
+ return {
82
+ northEast: {latitude: bounds[0][0], longitude: bounds[0][1]},
83
+ southWest: {latitude: bounds[1][0], longitude: bounds[1][1]},
84
+ };
85
+ }
86
+
87
+ export class MapOverlay extends React.Component<MapOverlayProps> {
88
+ // declaration only, as they are set through decorateMap
89
+ /// @ts-ignore
90
+ context!: React.ContextType<typeof ProviderContext>;
91
+ getNativeComponent!: () => NativeComponent<NativeProps>;
92
+ getMapManagerCommand!: (name: string) => MapManagerCommand;
93
+ getUIManagerCommand!: (name: string) => UIManagerCommand;
94
+
95
+ static Animated: Animated.AnimatedComponent<typeof MapOverlay>;
96
+
97
+ private fabricOverlay?: Boolean = undefined;
98
+
99
+ render() {
100
+ const {opacity = 1.0, bounds} = this.props;
101
+
102
+ if (this.fabricOverlay === undefined) {
103
+ this.fabricOverlay = Platform.OS === 'android';
104
+ }
105
+
106
+ const AIRMapOverlay = this.getNativeComponent();
107
+ let image: any = this.props.image;
108
+
109
+ let boundsParam: any = bounds;
110
+ if (this.fabricOverlay) {
111
+ if (this.props.image) {
112
+ image = fixImageProp(this.props.image);
113
+ }
114
+ if (bounds) {
115
+ boundsParam = normalizeBounds(bounds);
116
+ }
117
+ } else {
118
+ if (this.props.image) {
119
+ image = fixImageProp(this.props.image);
120
+ if (image.uri) {
121
+ image = image.uri;
122
+ }
123
+ }
124
+ }
125
+ return (
126
+ <AIRMapOverlay
127
+ // @ts-ignore
128
+ bounds={boundsParam}
129
+ opacity={opacity}
130
+ // @ts-ignore
131
+ image={image}
132
+ style={[styles.overlay, this.props.style]}
133
+ />
134
+ );
135
+ }
136
+ }
137
+
138
+ type Coordinate = [number, number];
139
+
140
+ type OverlayPressEvent = NativeSyntheticEvent<{
141
+ /**
142
+ * @platform iOS: Apple Maps: `image-overlay-press`
143
+ * @platform Android: `overlay-press`
144
+ */
145
+ action: 'overlay-press' | 'image-overlay-press';
146
+
147
+ /**
148
+ * @platform iOS: Apple Maps
149
+ */
150
+ name?: string;
151
+
152
+ /**
153
+ * @platform iOS: Apple Maps
154
+ * @platform Android
155
+ */
156
+ coordinate?: LatLng;
157
+
158
+ /**
159
+ * @platform Android
160
+ */
161
+ position?: Point;
162
+ }>;
163
+
164
+ const styles = StyleSheet.create({
165
+ overlay: {
166
+ position: 'absolute',
167
+ backgroundColor: 'transparent',
168
+ },
169
+ });
170
+
171
+ MapOverlay.Animated = Animated.createAnimatedComponent(MapOverlay);
172
+
173
+ export default decorateMapComponent(MapOverlay, 'Overlay', {
174
+ google: {
175
+ ios: SUPPORTED,
176
+ android: USES_DEFAULT_IMPLEMENTATION,
177
+ },
178
+ });
@@ -0,0 +1,188 @@
1
+ import * as React from 'react';
2
+ import {View, ViewProps} from 'react-native';
3
+ import decorateMapComponent, {
4
+ USES_DEFAULT_IMPLEMENTATION,
5
+ SUPPORTED,
6
+ ProviderContext,
7
+ NativeComponent,
8
+ MapManagerCommand,
9
+ UIManagerCommand,
10
+ } from './decorateMapComponent';
11
+ import {PolygonPressEvent} from './MapPolygon.types';
12
+ import {LatLng, LineCapType, LineJoinType} from './sharedTypes';
13
+
14
+ export type MapPolygonProps = ViewProps & {
15
+ /**
16
+ * An array of coordinates to describe the polygon
17
+ *
18
+ * @platform iOS: Supported
19
+ * @platform Android: Supported
20
+ */
21
+ coordinates: LatLng[];
22
+
23
+ /**
24
+ * The fill color to use for the path.
25
+ *
26
+ * @default `#000`, `rgba(r,g,b,0.5)`
27
+ * @platform iOS: Supported
28
+ * @platform Android: Supported
29
+ */
30
+ fillColor?: string;
31
+
32
+ /**
33
+ * Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to straight lines on the Mercator projection.
34
+ * A geodesic is the shortest path between two points on the Earth's surface.
35
+ * The geodesic curve is constructed assuming the Earth is a sphere.
36
+ *
37
+ * @platform iOS: Google Maps only
38
+ * @platform Android: Supported
39
+ */
40
+ geodesic?: boolean;
41
+
42
+ /**
43
+ * A 2d array of coordinates to describe holes of the polygon where each hole has at least 3 points.
44
+ *
45
+ * @platform iOS: Supported
46
+ * @platform Android: Supported
47
+ */
48
+ holes?: LatLng[][];
49
+
50
+ /**
51
+ * The line cap style to apply to the open ends of the path
52
+ *
53
+ * @default `round`
54
+ * @platform iOS: Apple Maps only
55
+ * @platform Android: Not supported
56
+ */
57
+ lineCap?: LineCapType;
58
+
59
+ /**
60
+ * An array of numbers specifying the dash pattern to use for the path.
61
+ * The array contains one or more numbers that indicate the lengths (measured in points)
62
+ * of the line segments and gaps in the pattern.
63
+ * The values in the array alternate, starting with the first line segment length,
64
+ * followed by the first gap length, followed by the second line segment length, and so on.
65
+ *
66
+ * @platform iOS: Apple Maps only
67
+ * @platform Android: Supported
68
+ */
69
+ lineDashPattern?: number[];
70
+
71
+ /**
72
+ * The offset (in points) at which to start drawing the dash pattern.
73
+ * Use this property to start drawing a dashed line partway through a segment or gap.
74
+ * For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
75
+ *
76
+ * @default 0
77
+ * @platform iOS: Apple Maps only
78
+ * @platform Android: Not supported
79
+ */
80
+ lineDashPhase?: number;
81
+
82
+ /**
83
+ * The line join style to apply to corners of the path.
84
+ *
85
+ * @platform iOS: Apple Maps only
86
+ * @platform Android: Not supported
87
+ */
88
+ lineJoin?: LineJoinType;
89
+
90
+ /**
91
+ * The limiting value that helps avoid spikes at junctions between connected line segments.
92
+ * The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style.
93
+ * If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit,
94
+ * the joint is converted to a bevel join.
95
+ * The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
96
+ *
97
+ * @default 10
98
+ * @platform iOS: Apple Maps only
99
+ * @platform Android: Not supported
100
+ */
101
+ miterLimit?: number;
102
+
103
+ /**
104
+ * Callback that is called when the user presses on the polygon
105
+ *
106
+ * @platform iOS: Supported
107
+ * @platform Android: Supported
108
+ */
109
+ onPress?: (event: PolygonPressEvent) => void;
110
+
111
+ /**
112
+ * The stroke color to use for the path.
113
+ *
114
+ * @default `#000`, `rgba(r,g,b,0.5)`
115
+ * @platform iOS: Supported
116
+ * @platform Android: Supported
117
+ */
118
+ strokeColor?: string;
119
+
120
+ /**
121
+ * The stroke width to use for the path.
122
+ *
123
+ * @default 1
124
+ * @platform iOS: Supported
125
+ * @platform Android: Supported
126
+ */
127
+ strokeWidth?: number;
128
+
129
+ /**
130
+ * Boolean to allow a polygon to be tappable and use the onPress function.
131
+ *
132
+ * @platform iOS: Google Maps only
133
+ * @platform Android: Supported
134
+ */
135
+ tappable?: boolean;
136
+
137
+ /**
138
+ * The order in which this tile overlay is drawn with respect to other overlays.
139
+ * An overlay with a larger z-index is drawn over overlays with smaller z-indices.
140
+ * The order of overlays with the same z-index is arbitrary.
141
+ *
142
+ * @platform iOS: Google Maps only
143
+ * @platform Android: Supported
144
+ */
145
+ zIndex?: number;
146
+ };
147
+
148
+ type NativeProps = MapPolygonProps & {ref: React.RefObject<View | null>};
149
+
150
+ export class MapPolygon extends React.Component<MapPolygonProps> {
151
+ // declaration only, as they are set through decorateMap
152
+ /// @ts-ignore
153
+ context!: React.ContextType<typeof ProviderContext>;
154
+ getNativeComponent!: () => NativeComponent<NativeProps>;
155
+ getMapManagerCommand!: (name: string) => MapManagerCommand;
156
+ getUIManagerCommand!: (name: string) => UIManagerCommand;
157
+
158
+ private polygon: NativeProps['ref'];
159
+
160
+ constructor(props: MapPolygonProps) {
161
+ super(props);
162
+ this.polygon = React.createRef<View>();
163
+ }
164
+
165
+ setNativeProps(props: Partial<MapPolygonProps>) {
166
+ this.polygon.current?.setNativeProps(props);
167
+ }
168
+
169
+ render() {
170
+ const {strokeColor = '#000', strokeWidth = 1} = this.props;
171
+ const AIRMapPolygon = this.getNativeComponent();
172
+ return (
173
+ <AIRMapPolygon
174
+ {...this.props}
175
+ strokeColor={strokeColor}
176
+ strokeWidth={strokeWidth}
177
+ ref={this.polygon}
178
+ />
179
+ );
180
+ }
181
+ }
182
+
183
+ export default decorateMapComponent(MapPolygon, 'Polygon', {
184
+ google: {
185
+ ios: SUPPORTED,
186
+ android: USES_DEFAULT_IMPLEMENTATION,
187
+ },
188
+ });
@@ -0,0 +1,25 @@
1
+ import {NativeSyntheticEvent} from 'react-native';
2
+ import {LatLng, Point} from './sharedTypes';
3
+
4
+ // All types in this file are directly exported with the package for external
5
+ // use.
6
+
7
+ export type PolygonPressEvent = NativeSyntheticEvent<{
8
+ action: 'polygon-press';
9
+
10
+ /**
11
+ * @platform iOS: Google Maps
12
+ */
13
+ id?: string;
14
+
15
+ /**
16
+ * @platform iOS: Apple Maps
17
+ * @platform Android
18
+ */
19
+ coordinate?: LatLng;
20
+
21
+ /**
22
+ * @platform Android
23
+ */
24
+ position?: Point;
25
+ }>;
@@ -0,0 +1,215 @@
1
+ import * as React from 'react';
2
+ import {NativeSyntheticEvent, View, ViewProps} from 'react-native';
3
+ import decorateMapComponent, {
4
+ USES_DEFAULT_IMPLEMENTATION,
5
+ SUPPORTED,
6
+ ProviderContext,
7
+ NativeComponent,
8
+ MapManagerCommand,
9
+ UIManagerCommand,
10
+ } from './decorateMapComponent';
11
+ import {LatLng, LineCapType, LineJoinType, Point} from './sharedTypes';
12
+
13
+ export type MapPolylineProps = ViewProps & {
14
+ /**
15
+ * An array of coordinates to describe the polyline
16
+ *
17
+ * @platform iOS: Supported
18
+ * @platform Android: Supported
19
+ */
20
+ coordinates: LatLng[];
21
+
22
+ /**
23
+ * The fill color to use for the path.
24
+ *
25
+ * @default `#000`, `rgba(r,g,b,0.5)`
26
+ * @platform iOS: Apple Maps only
27
+ * @platform Android: Not supported
28
+ */
29
+ fillColor?: string;
30
+
31
+ /**
32
+ * Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to straight lines on the Mercator projection.
33
+ * A geodesic is the shortest path between two points on the Earth's surface.
34
+ * The geodesic curve is constructed assuming the Earth is a sphere.
35
+ *
36
+ * @platform iOS: Google Maps only
37
+ * @platform Android: Supported
38
+ */
39
+ geodesic?: boolean;
40
+
41
+ /**
42
+ * The line cap style to apply to the open ends of the path
43
+ *
44
+ * @default `round`
45
+ * @platform iOS: Apple Maps only
46
+ * @platform Android: supported
47
+ * */
48
+ lineCap?: LineCapType;
49
+
50
+ /**
51
+ * An array of numbers specifying the dash pattern to use for the path.
52
+ * The array contains one or more numbers that indicate the lengths (measured in points)
53
+ * of the line segments and gaps in the pattern.
54
+ * The values in the array alternate, starting with the first line segment length,
55
+ * followed by the first gap length, followed by the second line segment length, and so on.
56
+ *
57
+ * @platform iOS: Apple Maps only
58
+ * @platform Android: supported
59
+ */
60
+ lineDashPattern?: number[];
61
+
62
+ /**
63
+ * The offset (in points) at which to start drawing the dash pattern.
64
+ * Use this property to start drawing a dashed line partway through a segment or gap.
65
+ * For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
66
+ *
67
+ * @default 0
68
+ * @platform iOS: Apple Maps only
69
+ * @platform Android: Not supported
70
+ */
71
+ lineDashPhase?: number;
72
+
73
+ /**
74
+ * The line join style to apply to corners of the path.
75
+ *
76
+ * @platform iOS: Apple Maps only
77
+ * @platform Android: supported
78
+ */
79
+ lineJoin?: LineJoinType;
80
+
81
+ /**
82
+ * The limiting value that helps avoid spikes at junctions between connected line segments.
83
+ * The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style.
84
+ * If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit,
85
+ * the joint is converted to a bevel join.
86
+ * The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
87
+ *
88
+ * @default 10
89
+ * @platform iOS: Apple Maps only
90
+ * @platform Android: Not supported
91
+ */
92
+ miterLimit?: number;
93
+
94
+ /**
95
+ * Callback that is called when the user presses on the polyline
96
+ *
97
+ * @platform iOS: Supported
98
+ * @platform Android: Supported
99
+ */
100
+ onPress?: (event: PolylinePressEvent) => void;
101
+
102
+ /**
103
+ * The stroke color to use for the path.
104
+ *
105
+ * @default `#000`, `rgba(r,g,b,0.5)`
106
+ * @platform iOS: Supported
107
+ * @platform Android: Supported
108
+ */
109
+ strokeColor?: string;
110
+
111
+ /**
112
+ * The stroke colors to use for the path.
113
+ *
114
+ * Must be the same length as `coordinates`
115
+ *
116
+ * @platform iOS: Supported
117
+ * @platform Android: Supported
118
+ */
119
+ strokeColors?: string[];
120
+
121
+ /**
122
+ * The stroke width to use for the path.
123
+ *
124
+ * @default 1
125
+ * @platform iOS: Supported
126
+ * @platform Android: Supported
127
+ */
128
+ strokeWidth?: number;
129
+
130
+ /**
131
+ * Boolean to allow the polyline to be tappable and use the onPress function.
132
+ *
133
+ * @platform iOS: Google Maps only
134
+ * @platform Android: Supported
135
+ */
136
+ tappable?: boolean;
137
+
138
+ /**
139
+ * The order in which this tile overlay is drawn with respect to other overlays.
140
+ * An overlay with a larger z-index is drawn over overlays with smaller z-indices.
141
+ * The order of overlays with the same z-index is arbitrary.
142
+ *
143
+ * @platform iOS: Google Maps only
144
+ * @platform Android: Supported
145
+ */
146
+ zIndex?: number;
147
+ };
148
+
149
+ type NativeProps = MapPolylineProps & {ref: React.RefObject<View | null>};
150
+
151
+ export class MapPolyline extends React.Component<MapPolylineProps> {
152
+ // declaration only, as they are set through decorateMap
153
+ /// @ts-ignore
154
+ context!: React.ContextType<typeof ProviderContext>;
155
+ getNativeComponent!: () => NativeComponent<NativeProps>;
156
+ getMapManagerCommand!: (name: string) => MapManagerCommand;
157
+ getUIManagerCommand!: (name: string) => UIManagerCommand;
158
+
159
+ private polyline: NativeProps['ref'];
160
+
161
+ constructor(props: MapPolylineProps) {
162
+ super(props);
163
+ this.polyline = React.createRef<View>();
164
+ }
165
+
166
+ setNativeProps(props: Partial<NativeProps>) {
167
+ this.polyline.current?.setNativeProps(props);
168
+ }
169
+
170
+ render() {
171
+ const {
172
+ strokeColor = '#000',
173
+ strokeWidth = 1,
174
+ lineJoin = 'round',
175
+ lineCap = 'round',
176
+ } = this.props;
177
+ const AIRMapPolyline = this.getNativeComponent();
178
+ return (
179
+ <AIRMapPolyline
180
+ {...this.props}
181
+ strokeColor={strokeColor}
182
+ strokeWidth={strokeWidth}
183
+ lineJoin={lineJoin}
184
+ lineCap={lineCap}
185
+ ref={this.polyline}
186
+ />
187
+ );
188
+ }
189
+ }
190
+
191
+ export default decorateMapComponent(MapPolyline, 'Polyline', {
192
+ google: {
193
+ ios: SUPPORTED,
194
+ android: USES_DEFAULT_IMPLEMENTATION,
195
+ },
196
+ });
197
+
198
+ export type PolylinePressEvent = NativeSyntheticEvent<{
199
+ action: 'polyline-press';
200
+
201
+ /**
202
+ * @platform iOS: Google Maps
203
+ */
204
+ id?: string;
205
+
206
+ /**
207
+ * @platform Android
208
+ */
209
+ coordinate?: LatLng;
210
+
211
+ /**
212
+ * @platform Android
213
+ */
214
+ position?: Point;
215
+ }>;