react-native-map4d-map-dtqg 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +88 -41
  3. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  7. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  8. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  9. package/android/.gradle/8.9/gc.properties +0 -0
  10. package/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
  11. package/android/.gradle/9.0-milestone-1/checksums/md5-checksums.bin +0 -0
  12. package/android/.gradle/9.0-milestone-1/checksums/sha1-checksums.bin +0 -0
  13. package/android/.gradle/9.0-milestone-1/fileChanges/last-build.bin +0 -0
  14. package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
  15. package/android/.gradle/9.0-milestone-1/gc.properties +0 -0
  16. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  17. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  18. package/android/.gradle/config.properties +2 -0
  19. package/android/.gradle/vcs-1/gc.properties +0 -0
  20. package/android/.idea/AndroidProjectSystem.xml +6 -0
  21. package/android/.idea/caches/deviceStreaming.xml +1570 -0
  22. package/android/.idea/copilot.data.migration.ask2agent.xml +6 -0
  23. package/android/.idea/gradle.xml +12 -0
  24. package/android/.idea/migrations.xml +10 -0
  25. package/android/.idea/misc.xml +10 -0
  26. package/android/.idea/runConfigurations.xml +17 -0
  27. package/android/.idea/vcs.xml +6 -0
  28. package/android/build.gradle +60 -60
  29. package/android/local.properties +8 -0
  30. package/android/src/main/AndroidManifest.xml +4 -4
  31. package/android/src/main/java/com/reactnativemap4dmap/ImageUtils.java +87 -87
  32. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapModule.java +298 -298
  33. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapPackage.java +35 -35
  34. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapViewManager.java +31 -31
  35. package/android/src/main/java/com/reactnativemap4dmap/RMFBuilding.java +167 -167
  36. package/android/src/main/java/com/reactnativemap4dmap/RMFBuildingManager.java +121 -121
  37. package/android/src/main/java/com/reactnativemap4dmap/RMFCircle.java +105 -105
  38. package/android/src/main/java/com/reactnativemap4dmap/RMFCircleManager.java +121 -121
  39. package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRenderer.java +502 -502
  40. package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRendererManager.java +143 -143
  41. package/android/src/main/java/com/reactnativemap4dmap/RMFFeature.java +17 -17
  42. package/android/src/main/java/com/reactnativemap4dmap/RMFMapView.java +1172 -1172
  43. package/android/src/main/java/com/reactnativemap4dmap/RMFMapViewManager.java +226 -226
  44. package/android/src/main/java/com/reactnativemap4dmap/RMFMarker.java +412 -412
  45. package/android/src/main/java/com/reactnativemap4dmap/RMFMarkerManager.java +211 -211
  46. package/android/src/main/java/com/reactnativemap4dmap/RMFPOI.java +222 -222
  47. package/android/src/main/java/com/reactnativemap4dmap/RMFPOIManager.java +119 -119
  48. package/android/src/main/java/com/reactnativemap4dmap/RMFPolygon.java +172 -172
  49. package/android/src/main/java/com/reactnativemap4dmap/RMFPolygonManager.java +147 -147
  50. package/android/src/main/java/com/reactnativemap4dmap/RMFPolyline.java +146 -146
  51. package/android/src/main/java/com/reactnativemap4dmap/RMFPolylineManager.java +137 -137
  52. package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlay.java +95 -95
  53. package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlayManager.java +64 -64
  54. package/android/src/main/java/com/reactnativemap4dmap/SizeReportingShadowNode.java +31 -31
  55. package/android/src/main/java/com/reactnativemap4dmap/ViewAttacherGroup.java +31 -31
  56. package/android/src/main/java/com/reactnativemap4dmap/ViewChangesTracker.java +70 -70
  57. package/android/src/main/java/vn/map4d/map/annotations/RMFBitmapDescriptor.java +9 -9
  58. package/ios/Map4dMap.h +7 -7
  59. package/ios/Map4dMap.m +14 -14
  60. package/ios/Map4dMapViewManager.m +34 -34
  61. package/ios/RCTConvert+Map4dMap.h +33 -33
  62. package/ios/RCTConvert+Map4dMap.m +112 -112
  63. package/ios/RMFCircle.h +37 -37
  64. package/ios/RMFCircle.m +100 -100
  65. package/ios/RMFCircleManager.h +18 -18
  66. package/ios/RMFCircleManager.m +155 -155
  67. package/ios/RMFCircleMap4d.h +23 -23
  68. package/ios/RMFCircleMap4d.m +13 -13
  69. package/ios/RMFCoordinate.h +22 -22
  70. package/ios/RMFCoordinate.m +13 -13
  71. package/ios/RMFDirectionsMarkerOptions.h +24 -24
  72. package/ios/RMFDirectionsMarkerOptions.m +23 -23
  73. package/ios/RMFDirectionsRenderer.h +47 -47
  74. package/ios/RMFDirectionsRenderer.m +182 -182
  75. package/ios/RMFDirectionsRendererManager.h +17 -17
  76. package/ios/RMFDirectionsRendererManager.m +84 -84
  77. package/ios/RMFDirectionsRendererMap4d.h +21 -21
  78. package/ios/RMFDirectionsRendererMap4d.m +12 -12
  79. package/ios/RMFDummyView.h +6 -6
  80. package/ios/RMFDummyView.m +12 -12
  81. package/ios/RMFEventResponse.h +39 -39
  82. package/ios/RMFEventResponse.m +98 -98
  83. package/ios/RMFIcon.h +24 -24
  84. package/ios/RMFIcon.m +35 -35
  85. package/ios/RMFMapView.h +84 -84
  86. package/ios/RMFMapView.m +376 -376
  87. package/ios/RMFMapViewManager.h +17 -17
  88. package/ios/RMFMapViewManager.m +493 -493
  89. package/ios/RMFMarker.h +57 -57
  90. package/ios/RMFMarker.m +267 -267
  91. package/ios/RMFMarkerManager.h +17 -17
  92. package/ios/RMFMarkerManager.m +156 -156
  93. package/ios/RMFMarkerMap4d.h +19 -19
  94. package/ios/RMFMarkerMap4d.m +13 -13
  95. package/ios/RMFPOI.h +38 -38
  96. package/ios/RMFPOI.m +123 -123
  97. package/ios/RMFPOIManager.h +18 -18
  98. package/ios/RMFPOIManager.m +168 -168
  99. package/ios/RMFPOIMap4d.h +22 -22
  100. package/ios/RMFPOIMap4d.m +12 -12
  101. package/ios/RMFPolygon.h +41 -41
  102. package/ios/RMFPolygon.m +106 -106
  103. package/ios/RMFPolygonManager.h +18 -18
  104. package/ios/RMFPolygonManager.m +141 -141
  105. package/ios/RMFPolygonMap4d.h +23 -23
  106. package/ios/RMFPolygonMap4d.m +15 -15
  107. package/ios/RMFPolyline.h +38 -38
  108. package/ios/RMFPolyline.m +101 -101
  109. package/ios/RMFPolylineManager.h +18 -18
  110. package/ios/RMFPolylineManager.m +139 -139
  111. package/ios/RMFPolylineMap4d.h +22 -22
  112. package/ios/RMFPolylineMap4d.m +15 -15
  113. package/ios/building/RMFBuilding.h +41 -41
  114. package/ios/building/RMFBuilding.m +104 -104
  115. package/ios/building/RMFBuildingManager.h +19 -19
  116. package/ios/building/RMFBuildingManager.m +133 -133
  117. package/ios/building/RMFBuildingMap4d.h +23 -23
  118. package/ios/building/RMFBuildingMap4d.m +15 -15
  119. package/ios/overlays/RMFTileOverlay.h +36 -36
  120. package/ios/overlays/RMFTileOverlay.m +64 -64
  121. package/ios/overlays/RMFTileOverlayManager.h +17 -17
  122. package/ios/overlays/RMFTileOverlayManager.m +27 -27
  123. package/lib/commonjs/components/MFBuilding.js +26 -26
  124. package/lib/commonjs/components/MFBuilding.js.map +1 -1
  125. package/lib/commonjs/components/MFCircle.js +20 -20
  126. package/lib/commonjs/components/MFCircle.js.map +1 -1
  127. package/lib/commonjs/components/MFDirectionsRenderer.js +32 -32
  128. package/lib/commonjs/components/MFDirectionsRenderer.js.map +1 -1
  129. package/lib/commonjs/components/MFMapView.js +133 -71
  130. package/lib/commonjs/components/MFMapView.js.map +1 -1
  131. package/lib/commonjs/components/MFMarker.js +35 -35
  132. package/lib/commonjs/components/MFMarker.js.map +1 -1
  133. package/lib/commonjs/components/MFPOI.js +20 -20
  134. package/lib/commonjs/components/MFPOI.js.map +1 -1
  135. package/lib/commonjs/components/MFPolygon.js +22 -22
  136. package/lib/commonjs/components/MFPolygon.js.map +1 -1
  137. package/lib/commonjs/components/MFPolyline.js +18 -18
  138. package/lib/commonjs/components/MFPolyline.js.map +1 -1
  139. package/lib/commonjs/components/MFTileOverlay.js +9 -9
  140. package/lib/commonjs/components/MFTileOverlay.js.map +1 -1
  141. package/lib/commonjs/components/Map4dMapView.js.map +1 -1
  142. package/lib/commonjs/components/extends/AreaFocuser.js +311 -0
  143. package/lib/commonjs/components/extends/AreaFocuser.js.map +1 -0
  144. package/lib/commonjs/index.js +8 -0
  145. package/lib/commonjs/index.js.map +1 -1
  146. package/lib/module/components/MFBuilding.js +26 -26
  147. package/lib/module/components/MFBuilding.js.map +1 -1
  148. package/lib/module/components/MFCircle.js +20 -20
  149. package/lib/module/components/MFCircle.js.map +1 -1
  150. package/lib/module/components/MFDirectionsRenderer.js +32 -32
  151. package/lib/module/components/MFDirectionsRenderer.js.map +1 -1
  152. package/lib/module/components/MFMapView.js +131 -71
  153. package/lib/module/components/MFMapView.js.map +1 -1
  154. package/lib/module/components/MFMarker.js +35 -35
  155. package/lib/module/components/MFMarker.js.map +1 -1
  156. package/lib/module/components/MFPOI.js +20 -20
  157. package/lib/module/components/MFPOI.js.map +1 -1
  158. package/lib/module/components/MFPolygon.js +22 -22
  159. package/lib/module/components/MFPolygon.js.map +1 -1
  160. package/lib/module/components/MFPolyline.js +18 -18
  161. package/lib/module/components/MFPolyline.js.map +1 -1
  162. package/lib/module/components/MFTileOverlay.js +9 -9
  163. package/lib/module/components/MFTileOverlay.js.map +1 -1
  164. package/lib/module/components/Map4dMapView.js.map +1 -1
  165. package/lib/module/components/extends/AreaFocuser.js +302 -0
  166. package/lib/module/components/extends/AreaFocuser.js.map +1 -0
  167. package/lib/module/index.js +2 -1
  168. package/lib/module/index.js.map +1 -1
  169. package/lib/typescript/components/Map4dMapView.d.ts +7 -7
  170. package/package.json +152 -152
  171. package/react-native-map4d-map.podspec +20 -20
  172. package/src/components/MFBuilding.js +187 -187
  173. package/src/components/MFCircle.js +173 -173
  174. package/src/components/MFDirectionsRenderer.js +237 -237
  175. package/src/components/MFMapView.js +447 -373
  176. package/src/components/MFMarker.js +246 -246
  177. package/src/components/MFPOI.js +184 -184
  178. package/src/components/MFPolygon.js +186 -186
  179. package/src/components/MFPolyline.js +172 -172
  180. package/src/components/MFTileOverlay.js +45 -45
  181. package/src/components/Map4dMapView.tsx +26 -26
  182. package/src/components/extends/AreaFocuser.js +339 -0
  183. package/src/index.js +23 -21
@@ -1,374 +1,448 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import {ViewPropTypes, ColorPropType} from 'deprecated-react-native-prop-types';
4
- import {
5
- requireNativeComponent,
6
- Platform,
7
- NativeModules,
8
- findNodeHandle
9
- } from 'react-native';
10
-
11
- const CameraShape = PropTypes.shape({
12
- target: PropTypes.shape({
13
- latitude: PropTypes.number.isRequired,
14
- longitude: PropTypes.number.isRequired,
15
- }),
16
- zoom: PropTypes.number.isRequired,
17
- bearing: PropTypes.number.isRequired,
18
- tilt: PropTypes.number.isRequired,
19
- });
20
-
21
- // if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
22
- const viewPropTypes = ViewPropTypes || View.propTypes;
23
-
24
- const propTypes = {
25
- ...viewPropTypes,
26
-
27
- /**
28
- * An opaque identifier for a custom map configuration.
29
- */
30
- mapID: PropTypes.string,
31
-
32
- /**
33
- * Map style by string for a custom map configuration.
34
- */
35
- mapStyle: PropTypes.string,
36
-
37
- /**
38
- * If `false` hide the button to move map to the current user's location.
39
- * Default value is `false`.
40
- */
41
- showsMyLocationButton: PropTypes.bool,
42
-
43
- /**
44
- * If `true` the app will ask for the user's location.
45
- * Default value is `false`.
46
- */
47
- showsMyLocation: PropTypes.bool,
48
-
49
- /**
50
- * A Boolean indicating whether the map displays buildings.
51
- * Default value is `true`.
52
- */
53
- showsBuildings: PropTypes.bool,
54
-
55
- /**
56
- * A Boolean indicating whether the map displays POIs.
57
- * Default value is `true`.
58
- */
59
- showsPOIs: PropTypes.bool,
60
-
61
- /**
62
- * If `false` the user won't be able to zoom the map.
63
- * Default value is `true`.
64
- */
65
- zoomGesturesEnabled: PropTypes.bool,
66
-
67
- /**
68
- * If `false` the user won't be able to scroll the map.
69
- * Default value is `true`.
70
- */
71
- scrollGesturesEnabled: PropTypes.bool,
72
-
73
- /**
74
- * If `false` the user won't be able to pinch/rotate the map.
75
- * Default value is `true`.
76
- */
77
- rotateGesturesEnabled: PropTypes.bool,
78
-
79
- /**
80
- * If `false` the user won't be able to tilt the map.
81
- * Default value is `true`.
82
- */
83
- tiltGesturesEnabled: PropTypes.bool,
84
-
85
- /**
86
- * The camera view position.
87
- */
88
- camera: CameraShape,
89
-
90
- /**
91
- * Type of map tiles to be rendered.
92
- */
93
- mapType: PropTypes.oneOf(['roadmap', 'satellite', 'hybrid']),
94
-
95
- /**
96
- * Callback that is called once the map is fully loaded.
97
- * @platform android
98
- */
99
- onMapReady: PropTypes.func,
100
-
101
- /**
102
- * Callback that is called when user taps on the map.
103
- */
104
- onPress: PropTypes.func,
105
-
106
- /**
107
- * Callback that is called when user taps on the POIs
108
- */
109
- onPoiPress: PropTypes.func,
110
-
111
- /**
112
- * Callback that is called when user taps on the Buildings
113
- */
114
- onBuildingPress: PropTypes.func,
115
-
116
- /**
117
- * Callback that is called when user taps on the Places
118
- */
119
- onPlacePress: PropTypes.func,
120
-
121
- /**
122
- * Callback that is called when user taps on the Data Source Features
123
- */
124
- onDataSourceFeaturePress: PropTypes.func,
125
-
126
- /**
127
- * Callback that is called when moving camera
128
- */
129
- onCameraMove: PropTypes.func,
130
-
131
- /**
132
- * Callback that is called when camera start moving
133
- */
134
- onCameraMoveStart: PropTypes.func,
135
-
136
- /**
137
- * Callback that is called when camera idle
138
- */
139
- onCameraIdle: PropTypes.func,
140
-
141
- /**
142
- * Callback that is called when user taps on location Button
143
- */
144
- onMyLocationButtonPress: PropTypes.func,
145
- };
146
-
147
-
148
- class MFMapView extends React.Component {
149
- constructor(props) {
150
- super(props);
151
- this.state = {
152
- isReady: Platform.OS === 'ios',
153
- };
154
-
155
- this._onMapReady = this._onMapReady.bind(this);
156
- this._ref = this._ref.bind(this);
157
- }
158
-
159
- _onMapReady() {
160
- const { onMapReady } = this.props;
161
- this.setState({ isReady: true }, () => {
162
- if (onMapReady) {
163
- onMapReady();
164
- }
165
- });
166
- }
167
-
168
- _ref(ref) {
169
- this.map = ref;
170
- }
171
-
172
- getCamera() {
173
- if (Platform.OS === 'android') {
174
- return NativeModules.Map4dMap.getCamera(this._getHandle());
175
- } else if (Platform.OS === 'ios') {
176
- return this._runCommand('getCamera', []);
177
- }
178
- return Promise.reject('Function not supported on this platform');
179
- }
180
-
181
- getBounds() {
182
- if (Platform.OS === 'android') {
183
- return NativeModules.Map4dMap.getBounds(this._getHandle());
184
- } else if (Platform.OS === 'ios') {
185
- return this._runCommand('getBounds', []);
186
- }
187
- return Promise.reject('Function not supported on this platform');
188
- }
189
-
190
- getMyLocation() {
191
- if (Platform.OS === 'android') {
192
- return NativeModules.Map4dMap.getMyLocation(this._getHandle());
193
- } else if (Platform.OS === 'ios') {
194
- return this._runCommand('getMyLocation', []);
195
- }
196
- return Promise.reject('Function not supported on this platform');
197
- }
198
-
199
- animateCamera(camera) {
200
- this._runCommand('animateCamera', [camera]);
201
- }
202
-
203
- moveCamera(camera) {
204
- this._runCommand('moveCamera', [camera]);
205
- }
206
-
207
- setMyLocationEnabled(enable) {
208
- this._runCommand('setMyLocationEnabled', [enable]);
209
- }
210
-
211
- showsMyLocationButton(enable) {
212
- this._runCommand('showsMyLocationButton', [enable]);
213
- }
214
-
215
- setPOIsEnabled(enable) {
216
- this._runCommand('setPOIsEnabled', [enable]);
217
- }
218
-
219
- setZoomGesturesEnabled(enable) {
220
- this._runCommand('setZoomGesturesEnabled', [enable]);
221
- }
222
-
223
- setScrollGesturesEnabled(enable) {
224
- this._runCommand('setScrollGesturesEnabled', [enable]);
225
- }
226
-
227
- setRotateGesturesEnabled(enable) {
228
- this._runCommand('setRotateGesturesEnabled', [enable]);
229
- }
230
-
231
- setTiltGesturesEnabled(enable) {
232
- this._runCommand('setTiltGesturesEnabled', [enable]);
233
- }
234
-
235
- setAllGesturesEnabled(enable) {
236
- this._runCommand('setAllGesturesEnabled', [enable]);
237
- }
238
-
239
- setTime(time) {
240
- let t = Date.parse(time)
241
- if (isNaN(t)) {
242
- console.log('time invalid')
243
- }
244
- else {
245
- this._runCommand('setTime', [t]);
246
- }
247
- }
248
-
249
- fitBounds(boundsData) {
250
- this._runCommand("fitBounds", [boundsData])
251
- }
252
-
253
- cameraForBounds(boundsData) {
254
- if (Platform.OS === 'android') {
255
- return NativeModules.Map4dMap.cameraForBounds(
256
- this._getHandle(),
257
- boundsData
258
- );
259
- } else if (Platform.OS === 'ios') {
260
- return this._runCommand('cameraForBounds', [boundsData]);
261
- }
262
- return Promise.reject('cameraForBounds not supported on this platform');
263
- }
264
-
265
-
266
- /**
267
- * Convert a map coordinate to screen point
268
- *
269
- * @param coordinate Coordinate
270
- * @param [coordinate.latitude] Latitude
271
- * @param [coordinate.longitude] Longitude
272
- *
273
- * @return Promise Promise with the point ({ x: Number, y: Number })
274
- */
275
- pointForCoordinate(coordinate) {
276
- if (Platform.OS === 'android') {
277
- return NativeModules.Map4dMap.pointForCoordinate(
278
- this._getHandle(),
279
- coordinate
280
- );
281
- } else if (Platform.OS === 'ios') {
282
- return this._runCommand('pointForCoordinate', [coordinate]);
283
- }
284
- return Promise.reject('pointForCoordinate not supported on this platform');
285
- }
286
-
287
- /**
288
- * Convert a screen point to a map coordinate
289
- *
290
- * @param point Point
291
- * @param [point.x] X
292
- * @param [point.x] Y
293
- *
294
- * @return Promise Promise with the coordinate ({ latitude: Number, longitude: Number })
295
- */
296
- coordinateForPoint(point) {
297
- if (Platform.OS === 'android') {
298
- return NativeModules.Map4dMap.coordinateForPoint(
299
- this._getHandle(),
300
- point
301
- );
302
- } else if (Platform.OS === 'ios') {
303
- return this._runCommand('coordinateForPoint', [point]);
304
- }
305
- return Promise.reject('coordinateForPoint not supported on this platform');
306
- }
307
-
308
- _getHandle() {
309
- return findNodeHandle(this.map);
310
- }
311
-
312
- _runCommand(name, args) {
313
- switch (Platform.OS) {
314
- case 'android':
315
- return NativeModules.UIManager.dispatchViewManagerCommand(
316
- this._getHandle(),
317
- this._uiManagerCommand(name),
318
- args
319
- );
320
-
321
- case 'ios':
322
- return this._mapManagerCommand(name)(this._getHandle(), ...args);
323
-
324
- default:
325
- return Promise.reject(`Invalid platform was passed: ${Platform.OS}`);
326
- }
327
- }
328
-
329
- _uiManagerCommand(name) {
330
- const UIManager = NativeModules.UIManager;
331
- const componentName = "RMFMapView";
332
-
333
- if (!UIManager.getViewManagerConfig) {
334
- // RN < 0.58
335
- return UIManager[componentName].Commands[name];
336
- }
337
-
338
- // RN >= 0.58
339
- return UIManager.getViewManagerConfig(componentName).Commands[name];
340
- }
341
-
342
- _mapManagerCommand(name) {
343
- return NativeModules[`RMFMapView`][name];
344
- }
345
-
346
-
347
- render() {
348
- let props;
349
-
350
- if (this.state.isReady) {
351
- props = {
352
- style: this.props.style,
353
- onMapReady: this._onMapReady,
354
- ...this.props,
355
- };
356
- } else {
357
- props = {
358
- style: this.props.style,
359
- onMapReady: this._onMapReady
360
- };
361
- }
362
-
363
- return <RMFMapView
364
- {...props}
365
- ref={this._ref}
366
- />;
367
- }
368
- }
369
-
370
- MFMapView.propTypes = propTypes;
371
- var RMFMapView = requireNativeComponent(`RMFMapView`, MFMapView);
372
-
373
-
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import {ViewPropTypes, ColorPropType} from 'deprecated-react-native-prop-types';
4
+ import {AreaFocuser} from './extends/AreaFocuser';
5
+ import {MFPolygon} from './MFPolygon';
6
+ import {
7
+ requireNativeComponent,
8
+ Platform,
9
+ NativeModules,
10
+ findNodeHandle
11
+ } from 'react-native';
12
+
13
+ const CameraShape = PropTypes.shape({
14
+ target: PropTypes.shape({
15
+ latitude: PropTypes.number.isRequired,
16
+ longitude: PropTypes.number.isRequired,
17
+ }),
18
+ zoom: PropTypes.number.isRequired,
19
+ bearing: PropTypes.number.isRequired,
20
+ tilt: PropTypes.number.isRequired,
21
+ });
22
+
23
+ // if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
24
+ const viewPropTypes = ViewPropTypes || View.propTypes;
25
+
26
+ const propTypes = {
27
+ ...viewPropTypes,
28
+
29
+ /**
30
+ * An opaque identifier for a custom map configuration.
31
+ */
32
+ mapID: PropTypes.string,
33
+
34
+ /**
35
+ * Map style by string for a custom map configuration.
36
+ */
37
+ mapStyle: PropTypes.string,
38
+
39
+ /**
40
+ * If `false` hide the button to move map to the current user's location.
41
+ * Default value is `false`.
42
+ */
43
+ showsMyLocationButton: PropTypes.bool,
44
+
45
+ /**
46
+ * If `true` the app will ask for the user's location.
47
+ * Default value is `false`.
48
+ */
49
+ showsMyLocation: PropTypes.bool,
50
+
51
+ /**
52
+ * A Boolean indicating whether the map displays buildings.
53
+ * Default value is `true`.
54
+ */
55
+ showsBuildings: PropTypes.bool,
56
+
57
+ /**
58
+ * A Boolean indicating whether the map displays POIs.
59
+ * Default value is `true`.
60
+ */
61
+ showsPOIs: PropTypes.bool,
62
+
63
+ /**
64
+ * If `false` the user won't be able to zoom the map.
65
+ * Default value is `true`.
66
+ */
67
+ zoomGesturesEnabled: PropTypes.bool,
68
+
69
+ /**
70
+ * If `false` the user won't be able to scroll the map.
71
+ * Default value is `true`.
72
+ */
73
+ scrollGesturesEnabled: PropTypes.bool,
74
+
75
+ /**
76
+ * If `false` the user won't be able to pinch/rotate the map.
77
+ * Default value is `true`.
78
+ */
79
+ rotateGesturesEnabled: PropTypes.bool,
80
+
81
+ /**
82
+ * If `false` the user won't be able to tilt the map.
83
+ * Default value is `true`.
84
+ */
85
+ tiltGesturesEnabled: PropTypes.bool,
86
+
87
+ /**
88
+ * The camera view position.
89
+ */
90
+ camera: CameraShape,
91
+
92
+ /**
93
+ * Type of map tiles to be rendered.
94
+ */
95
+ mapType: PropTypes.oneOf(['roadmap', 'satellite', 'hybrid']),
96
+
97
+ /**
98
+ * Callback that is called once the map is fully loaded.
99
+ * @platform android
100
+ */
101
+ onMapReady: PropTypes.func,
102
+
103
+ /**
104
+ * Callback that is called when user taps on the map.
105
+ */
106
+ onPress: PropTypes.func,
107
+
108
+ /**
109
+ * Callback that is called when user taps on the POIs
110
+ */
111
+ onPoiPress: PropTypes.func,
112
+
113
+ /**
114
+ * Callback that is called when user taps on the Buildings
115
+ */
116
+ onBuildingPress: PropTypes.func,
117
+
118
+ /**
119
+ * Callback that is called when user taps on the Places
120
+ */
121
+ onPlacePress: PropTypes.func,
122
+
123
+ /**
124
+ * Callback that is called when user taps on the Data Source Features
125
+ */
126
+ onDataSourceFeaturePress: PropTypes.func,
127
+
128
+ /**
129
+ * Callback that is called when moving camera
130
+ */
131
+ onCameraMove: PropTypes.func,
132
+
133
+ /**
134
+ * Callback that is called when camera start moving
135
+ */
136
+ onCameraMoveStart: PropTypes.func,
137
+
138
+ /**
139
+ * Callback that is called when camera idle
140
+ */
141
+ onCameraIdle: PropTypes.func,
142
+
143
+ /**
144
+ * Callback that is called when user taps on location Button
145
+ */
146
+ onMyLocationButtonPress: PropTypes.func,
147
+ };
148
+
149
+
150
+ class MFMapView extends React.Component {
151
+ constructor(props) {
152
+ super(props);
153
+ this.areaFocuser = new AreaFocuser(this);
154
+ this.state = {
155
+ isReady: Platform.OS === 'ios',
156
+ managedPolygons: {},
157
+ };
158
+
159
+ this._onMapReady = this._onMapReady.bind(this);
160
+ this._ref = this._ref.bind(this);
161
+ }
162
+
163
+ _addPolygon(polygon) {
164
+ if (polygon == null || typeof polygon !== 'object') {
165
+ return null;
166
+ }
167
+
168
+ const id =
169
+ typeof polygon.id === 'string' && polygon.id.trim().length > 0
170
+ ? polygon.id
171
+ : 'polygon-highlight-id-default';
172
+
173
+ const _polygon = {
174
+ ...polygon,
175
+ id,
176
+ };
177
+
178
+ this.setState((prevState) => ({
179
+ managedPolygons: {
180
+ ...prevState.managedPolygons,
181
+ [id]: _polygon,
182
+ },
183
+ }));
184
+
185
+ return id;
186
+ }
187
+
188
+ _removePolygon(id) {
189
+ if (typeof id !== 'string' || id.trim().length === 0) {
190
+ return;
191
+ }
192
+
193
+ this.setState((prevState) => {
194
+ if (!prevState.managedPolygons[id]) {
195
+ return null;
196
+ }
197
+
198
+ const managedPolygons = {
199
+ ...prevState.managedPolygons,
200
+ };
201
+ delete managedPolygons[id];
202
+
203
+ return {
204
+ managedPolygons,
205
+ };
206
+ });
207
+ }
208
+
209
+ _clearManagedPolygons() {
210
+ this.setState({
211
+ managedPolygons: {},
212
+ });
213
+ }
214
+
215
+ _onMapReady() {
216
+ const { onMapReady } = this.props;
217
+ this.setState({ isReady: true }, () => {
218
+ if (onMapReady) {
219
+ onMapReady();
220
+ }
221
+ });
222
+ }
223
+
224
+ _ref(ref) {
225
+ this.map = ref;
226
+ }
227
+
228
+ getCamera() {
229
+ if (Platform.OS === 'android') {
230
+ return NativeModules.Map4dMap.getCamera(this._getHandle());
231
+ } else if (Platform.OS === 'ios') {
232
+ return this._runCommand('getCamera', []);
233
+ }
234
+ return Promise.reject('Function not supported on this platform');
235
+ }
236
+
237
+ getBounds() {
238
+ if (Platform.OS === 'android') {
239
+ return NativeModules.Map4dMap.getBounds(this._getHandle());
240
+ } else if (Platform.OS === 'ios') {
241
+ return this._runCommand('getBounds', []);
242
+ }
243
+ return Promise.reject('Function not supported on this platform');
244
+ }
245
+
246
+ getMyLocation() {
247
+ if (Platform.OS === 'android') {
248
+ return NativeModules.Map4dMap.getMyLocation(this._getHandle());
249
+ } else if (Platform.OS === 'ios') {
250
+ return this._runCommand('getMyLocation', []);
251
+ }
252
+ return Promise.reject('Function not supported on this platform');
253
+ }
254
+
255
+ animateCamera(camera) {
256
+ this._runCommand('animateCamera', [camera]);
257
+ }
258
+
259
+ moveCamera(camera) {
260
+ this._runCommand('moveCamera', [camera]);
261
+ }
262
+
263
+ setMyLocationEnabled(enable) {
264
+ this._runCommand('setMyLocationEnabled', [enable]);
265
+ }
266
+
267
+ showsMyLocationButton(enable) {
268
+ this._runCommand('showsMyLocationButton', [enable]);
269
+ }
270
+
271
+ setPOIsEnabled(enable) {
272
+ this._runCommand('setPOIsEnabled', [enable]);
273
+ }
274
+
275
+ setZoomGesturesEnabled(enable) {
276
+ this._runCommand('setZoomGesturesEnabled', [enable]);
277
+ }
278
+
279
+ setScrollGesturesEnabled(enable) {
280
+ this._runCommand('setScrollGesturesEnabled', [enable]);
281
+ }
282
+
283
+ setRotateGesturesEnabled(enable) {
284
+ this._runCommand('setRotateGesturesEnabled', [enable]);
285
+ }
286
+
287
+ setTiltGesturesEnabled(enable) {
288
+ this._runCommand('setTiltGesturesEnabled', [enable]);
289
+ }
290
+
291
+ setAllGesturesEnabled(enable) {
292
+ this._runCommand('setAllGesturesEnabled', [enable]);
293
+ }
294
+
295
+ setTime(time) {
296
+ let t = Date.parse(time)
297
+ if (isNaN(t)) {
298
+ console.log('time invalid')
299
+ }
300
+ else {
301
+ this._runCommand('setTime', [t]);
302
+ }
303
+ }
304
+
305
+ fitBounds(boundsData) {
306
+ this._runCommand("fitBounds", [boundsData])
307
+ }
308
+
309
+ cameraForBounds(boundsData) {
310
+ if (Platform.OS === 'android') {
311
+ return NativeModules.Map4dMap.cameraForBounds(
312
+ this._getHandle(),
313
+ boundsData
314
+ );
315
+ } else if (Platform.OS === 'ios') {
316
+ return this._runCommand('cameraForBounds', [boundsData]);
317
+ }
318
+ return Promise.reject('cameraForBounds not supported on this platform');
319
+ }
320
+
321
+
322
+ /**
323
+ * Convert a map coordinate to screen point
324
+ *
325
+ * @param coordinate Coordinate
326
+ * @param [coordinate.latitude] Latitude
327
+ * @param [coordinate.longitude] Longitude
328
+ *
329
+ * @return Promise Promise with the point ({ x: Number, y: Number })
330
+ */
331
+ pointForCoordinate(coordinate) {
332
+ if (Platform.OS === 'android') {
333
+ return NativeModules.Map4dMap.pointForCoordinate(
334
+ this._getHandle(),
335
+ coordinate
336
+ );
337
+ } else if (Platform.OS === 'ios') {
338
+ return this._runCommand('pointForCoordinate', [coordinate]);
339
+ }
340
+ return Promise.reject('pointForCoordinate not supported on this platform');
341
+ }
342
+
343
+ /**
344
+ * Convert a screen point to a map coordinate
345
+ *
346
+ * @param point Point
347
+ * @param [point.x] X
348
+ * @param [point.x] Y
349
+ *
350
+ * @return Promise Promise with the coordinate ({ latitude: Number, longitude: Number })
351
+ */
352
+ coordinateForPoint(point) {
353
+ if (Platform.OS === 'android') {
354
+ return NativeModules.Map4dMap.coordinateForPoint(
355
+ this._getHandle(),
356
+ point
357
+ );
358
+ } else if (Platform.OS === 'ios') {
359
+ return this._runCommand('coordinateForPoint', [point]);
360
+ }
361
+ return Promise.reject('coordinateForPoint not supported on this platform');
362
+ }
363
+
364
+ _getHandle() {
365
+ return findNodeHandle(this.map);
366
+ }
367
+
368
+ _runCommand(name, args) {
369
+ switch (Platform.OS) {
370
+ case 'android':
371
+ return NativeModules.UIManager.dispatchViewManagerCommand(
372
+ this._getHandle(),
373
+ this._uiManagerCommand(name),
374
+ args
375
+ );
376
+
377
+ case 'ios':
378
+ return this._mapManagerCommand(name)(this._getHandle(), ...args);
379
+
380
+ default:
381
+ return Promise.reject(`Invalid platform was passed: ${Platform.OS}`);
382
+ }
383
+ }
384
+
385
+ _uiManagerCommand(name) {
386
+ const UIManager = NativeModules.UIManager;
387
+ const componentName = "RMFMapView";
388
+
389
+ if (!UIManager.getViewManagerConfig) {
390
+ // RN < 0.58
391
+ return UIManager[componentName].Commands[name];
392
+ }
393
+
394
+ // RN >= 0.58
395
+ return UIManager.getViewManagerConfig(componentName).Commands[name];
396
+ }
397
+
398
+ _mapManagerCommand(name) {
399
+ return NativeModules[`RMFMapView`][name];
400
+ }
401
+
402
+
403
+ render() {
404
+ let props;
405
+ const { children, ...restProps } = this.props;
406
+ const managedPolygons = Object.values(this.state.managedPolygons);
407
+
408
+ if (this.state.isReady) {
409
+ props = {
410
+ style: this.props.style,
411
+ onMapReady: this._onMapReady,
412
+ ...restProps,
413
+ children: (
414
+ <React.Fragment>
415
+ {children}
416
+ {managedPolygons.map((polygon) => (
417
+ <MFPolygon
418
+ key={polygon.id}
419
+ coordinates={polygon.coordinates}
420
+ holes={polygon.holes}
421
+ fillColor={polygon.fillColor}
422
+ strokeColor={polygon.strokeColor}
423
+ strokeWidth={polygon.strokeWidth}
424
+ zIndex={polygon.zIndex}
425
+ />
426
+ ))}
427
+ </React.Fragment>
428
+ ),
429
+ };
430
+ } else {
431
+ props = {
432
+ style: this.props.style,
433
+ onMapReady: this._onMapReady
434
+ };
435
+ }
436
+
437
+ return <RMFMapView
438
+ {...props}
439
+ ref={this._ref}
440
+ />;
441
+ }
442
+ }
443
+
444
+ MFMapView.propTypes = propTypes;
445
+ var RMFMapView = requireNativeComponent(`RMFMapView`, MFMapView);
446
+
447
+
374
448
  export { MFMapView }