react-native-map4d-map-dtqg 0.1.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 (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +41 -0
  3. package/android/build.gradle +60 -0
  4. package/android/src/main/AndroidManifest.xml +4 -0
  5. package/android/src/main/java/com/reactnativemap4dmap/ImageUtils.java +87 -0
  6. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapModule.java +298 -0
  7. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapPackage.java +35 -0
  8. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapViewManager.java +31 -0
  9. package/android/src/main/java/com/reactnativemap4dmap/RMFBuilding.java +167 -0
  10. package/android/src/main/java/com/reactnativemap4dmap/RMFBuildingManager.java +121 -0
  11. package/android/src/main/java/com/reactnativemap4dmap/RMFCircle.java +105 -0
  12. package/android/src/main/java/com/reactnativemap4dmap/RMFCircleManager.java +122 -0
  13. package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRenderer.java +502 -0
  14. package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRendererManager.java +143 -0
  15. package/android/src/main/java/com/reactnativemap4dmap/RMFFeature.java +18 -0
  16. package/android/src/main/java/com/reactnativemap4dmap/RMFMapView.java +1172 -0
  17. package/android/src/main/java/com/reactnativemap4dmap/RMFMapViewManager.java +226 -0
  18. package/android/src/main/java/com/reactnativemap4dmap/RMFMarker.java +412 -0
  19. package/android/src/main/java/com/reactnativemap4dmap/RMFMarkerManager.java +212 -0
  20. package/android/src/main/java/com/reactnativemap4dmap/RMFPOI.java +222 -0
  21. package/android/src/main/java/com/reactnativemap4dmap/RMFPOIManager.java +119 -0
  22. package/android/src/main/java/com/reactnativemap4dmap/RMFPolygon.java +173 -0
  23. package/android/src/main/java/com/reactnativemap4dmap/RMFPolygonManager.java +148 -0
  24. package/android/src/main/java/com/reactnativemap4dmap/RMFPolyline.java +146 -0
  25. package/android/src/main/java/com/reactnativemap4dmap/RMFPolylineManager.java +138 -0
  26. package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlay.java +95 -0
  27. package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlayManager.java +65 -0
  28. package/android/src/main/java/com/reactnativemap4dmap/SizeReportingShadowNode.java +31 -0
  29. package/android/src/main/java/com/reactnativemap4dmap/ViewAttacherGroup.java +31 -0
  30. package/android/src/main/java/com/reactnativemap4dmap/ViewChangesTracker.java +70 -0
  31. package/android/src/main/java/vn/map4d/map/annotations/RMFBitmapDescriptor.java +9 -0
  32. package/ios/Map4dMap.h +7 -0
  33. package/ios/Map4dMap.m +14 -0
  34. package/ios/Map4dMap.xcodeproj/project.pbxproj +282 -0
  35. package/ios/Map4dMapViewManager.m +34 -0
  36. package/ios/RCTConvert+Map4dMap.h +33 -0
  37. package/ios/RCTConvert+Map4dMap.m +112 -0
  38. package/ios/RMFCircle.h +37 -0
  39. package/ios/RMFCircle.m +100 -0
  40. package/ios/RMFCircleManager.h +18 -0
  41. package/ios/RMFCircleManager.m +155 -0
  42. package/ios/RMFCircleMap4d.h +23 -0
  43. package/ios/RMFCircleMap4d.m +13 -0
  44. package/ios/RMFCoordinate.h +22 -0
  45. package/ios/RMFCoordinate.m +13 -0
  46. package/ios/RMFDirectionsMarkerOptions.h +24 -0
  47. package/ios/RMFDirectionsMarkerOptions.m +23 -0
  48. package/ios/RMFDirectionsRenderer.h +47 -0
  49. package/ios/RMFDirectionsRenderer.m +182 -0
  50. package/ios/RMFDirectionsRendererManager.h +17 -0
  51. package/ios/RMFDirectionsRendererManager.m +84 -0
  52. package/ios/RMFDirectionsRendererMap4d.h +21 -0
  53. package/ios/RMFDirectionsRendererMap4d.m +12 -0
  54. package/ios/RMFDummyView.h +7 -0
  55. package/ios/RMFDummyView.m +13 -0
  56. package/ios/RMFEventResponse.h +39 -0
  57. package/ios/RMFEventResponse.m +98 -0
  58. package/ios/RMFIcon.h +24 -0
  59. package/ios/RMFIcon.m +35 -0
  60. package/ios/RMFMapView.h +84 -0
  61. package/ios/RMFMapView.m +376 -0
  62. package/ios/RMFMapViewManager.h +17 -0
  63. package/ios/RMFMapViewManager.m +493 -0
  64. package/ios/RMFMarker.h +57 -0
  65. package/ios/RMFMarker.m +267 -0
  66. package/ios/RMFMarkerManager.h +17 -0
  67. package/ios/RMFMarkerManager.m +156 -0
  68. package/ios/RMFMarkerMap4d.h +19 -0
  69. package/ios/RMFMarkerMap4d.m +13 -0
  70. package/ios/RMFPOI.h +38 -0
  71. package/ios/RMFPOI.m +123 -0
  72. package/ios/RMFPOIManager.h +18 -0
  73. package/ios/RMFPOIManager.m +168 -0
  74. package/ios/RMFPOIMap4d.h +22 -0
  75. package/ios/RMFPOIMap4d.m +12 -0
  76. package/ios/RMFPolygon.h +41 -0
  77. package/ios/RMFPolygon.m +106 -0
  78. package/ios/RMFPolygonManager.h +18 -0
  79. package/ios/RMFPolygonManager.m +141 -0
  80. package/ios/RMFPolygonMap4d.h +23 -0
  81. package/ios/RMFPolygonMap4d.m +15 -0
  82. package/ios/RMFPolyline.h +38 -0
  83. package/ios/RMFPolyline.m +101 -0
  84. package/ios/RMFPolylineManager.h +18 -0
  85. package/ios/RMFPolylineManager.m +139 -0
  86. package/ios/RMFPolylineMap4d.h +22 -0
  87. package/ios/RMFPolylineMap4d.m +15 -0
  88. package/ios/building/RMFBuilding.h +41 -0
  89. package/ios/building/RMFBuilding.m +104 -0
  90. package/ios/building/RMFBuildingManager.h +19 -0
  91. package/ios/building/RMFBuildingManager.m +133 -0
  92. package/ios/building/RMFBuildingMap4d.h +23 -0
  93. package/ios/building/RMFBuildingMap4d.m +15 -0
  94. package/ios/overlays/RMFTileOverlay.h +36 -0
  95. package/ios/overlays/RMFTileOverlay.m +64 -0
  96. package/ios/overlays/RMFTileOverlayManager.h +17 -0
  97. package/ios/overlays/RMFTileOverlayManager.m +27 -0
  98. package/lib/commonjs/components/MFBuilding.js +192 -0
  99. package/lib/commonjs/components/MFBuilding.js.map +1 -0
  100. package/lib/commonjs/components/MFCircle.js +181 -0
  101. package/lib/commonjs/components/MFCircle.js.map +1 -0
  102. package/lib/commonjs/components/MFDirectionsRenderer.js +240 -0
  103. package/lib/commonjs/components/MFDirectionsRenderer.js.map +1 -0
  104. package/lib/commonjs/components/MFMapView.js +375 -0
  105. package/lib/commonjs/components/MFMapView.js.map +1 -0
  106. package/lib/commonjs/components/MFMarker.js +255 -0
  107. package/lib/commonjs/components/MFMarker.js.map +1 -0
  108. package/lib/commonjs/components/MFPOI.js +204 -0
  109. package/lib/commonjs/components/MFPOI.js.map +1 -0
  110. package/lib/commonjs/components/MFPolygon.js +183 -0
  111. package/lib/commonjs/components/MFPolygon.js.map +1 -0
  112. package/lib/commonjs/components/MFPolyline.js +173 -0
  113. package/lib/commonjs/components/MFPolyline.js.map +1 -0
  114. package/lib/commonjs/components/MFTileOverlay.js +51 -0
  115. package/lib/commonjs/components/MFTileOverlay.js.map +1 -0
  116. package/lib/commonjs/components/Map4dMapView.js +19 -0
  117. package/lib/commonjs/components/Map4dMapView.js.map +1 -0
  118. package/lib/commonjs/index.js +78 -0
  119. package/lib/commonjs/index.js.map +1 -0
  120. package/lib/module/components/MFBuilding.js +178 -0
  121. package/lib/module/components/MFBuilding.js.map +1 -0
  122. package/lib/module/components/MFCircle.js +167 -0
  123. package/lib/module/components/MFCircle.js.map +1 -0
  124. package/lib/module/components/MFDirectionsRenderer.js +226 -0
  125. package/lib/module/components/MFDirectionsRenderer.js.map +1 -0
  126. package/lib/module/components/MFMapView.js +361 -0
  127. package/lib/module/components/MFMapView.js.map +1 -0
  128. package/lib/module/components/MFMarker.js +240 -0
  129. package/lib/module/components/MFMarker.js.map +1 -0
  130. package/lib/module/components/MFPOI.js +190 -0
  131. package/lib/module/components/MFPOI.js.map +1 -0
  132. package/lib/module/components/MFPolygon.js +169 -0
  133. package/lib/module/components/MFPolygon.js.map +1 -0
  134. package/lib/module/components/MFPolyline.js +159 -0
  135. package/lib/module/components/MFPolyline.js.map +1 -0
  136. package/lib/module/components/MFTileOverlay.js +38 -0
  137. package/lib/module/components/MFTileOverlay.js.map +1 -0
  138. package/lib/module/components/Map4dMapView.js +10 -0
  139. package/lib/module/components/Map4dMapView.js.map +1 -0
  140. package/lib/module/index.js +11 -0
  141. package/lib/module/index.js.map +1 -0
  142. package/lib/typescript/components/Map4dMapView.d.ts +7 -0
  143. package/package.json +152 -0
  144. package/react-native-map4d-map.podspec +20 -0
  145. package/src/components/MFBuilding.js +188 -0
  146. package/src/components/MFCircle.js +173 -0
  147. package/src/components/MFDirectionsRenderer.js +237 -0
  148. package/src/components/MFMapView.js +374 -0
  149. package/src/components/MFMarker.js +246 -0
  150. package/src/components/MFPOI.js +184 -0
  151. package/src/components/MFPolygon.js +186 -0
  152. package/src/components/MFPolyline.js +172 -0
  153. package/src/components/MFTileOverlay.js +45 -0
  154. package/src/components/Map4dMapView.tsx +27 -0
  155. package/src/index.js +21 -0
@@ -0,0 +1,374 @@
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
+
374
+ export { MFMapView }
@@ -0,0 +1,246 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import {ViewPropTypes} from 'deprecated-react-native-prop-types';
4
+ import {
5
+ requireNativeComponent,
6
+ StyleSheet,
7
+ Platform,
8
+ Image,
9
+ NativeModules,
10
+ findNodeHandle
11
+ } from 'react-native';
12
+
13
+ // if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
14
+ const viewPropTypes = ViewPropTypes || View.propTypes;
15
+
16
+ const propTypes = {
17
+ ...viewPropTypes,
18
+
19
+ /**
20
+ * The coordinate for the marker.
21
+ */
22
+ coordinate: PropTypes.shape({
23
+ latitude: PropTypes.number.isRequired,
24
+ longitude: PropTypes.number.isRequired,
25
+ }).isRequired,
26
+
27
+ /**
28
+ * Default value is `false`
29
+ */
30
+ draggable: PropTypes.bool,
31
+
32
+ /**
33
+ * Sets the ground anchor point for the marker.
34
+ */
35
+ anchor: PropTypes.shape({
36
+ x: PropTypes.number.isRequired,
37
+ y: PropTypes.number.isRequired,
38
+ }),
39
+
40
+ /**
41
+ *
42
+ */
43
+ elevation: PropTypes.number,
44
+
45
+ /**
46
+ *
47
+ */
48
+ rotation: PropTypes.number,
49
+
50
+ /**
51
+ * Sets the infor window anchor point for the marker.
52
+ */
53
+ infoWindowAnchor: PropTypes.shape({
54
+ x: PropTypes.number.isRequired,
55
+ y: PropTypes.number.isRequired,
56
+ }),
57
+
58
+ /**
59
+ * The title of the marker.
60
+ */
61
+ title: PropTypes.string,
62
+
63
+ /**
64
+ * The snippet of the marker.
65
+ */
66
+ snippet: PropTypes.string,
67
+
68
+ /**
69
+ * Marker icon to render.
70
+ */
71
+ icon: PropTypes.shape({
72
+ uri: PropTypes.any.isRequired,
73
+ width: PropTypes.number.isRequired,
74
+ height: PropTypes.number.isRequired,
75
+ }),
76
+
77
+
78
+ /**
79
+ * zIndex
80
+ */
81
+ zIndex: PropTypes.number,
82
+
83
+ /**
84
+ * visible
85
+ */
86
+ visible: PropTypes.bool,
87
+
88
+ /**
89
+ * userData
90
+ */
91
+ userData:PropTypes.object,
92
+
93
+ /**
94
+ * Callback that is called when the user presses on the marker
95
+ */
96
+ onPress: PropTypes.func,
97
+
98
+ /**
99
+ * Callback that is called when the user presses on the info window
100
+ */
101
+ onPressInfoWindow: PropTypes.func,
102
+
103
+ /**
104
+ * Callback that is called when the user initiates a drag on this marker (if it is draggable)
105
+ */
106
+ onDragStart: PropTypes.func,
107
+
108
+ /**
109
+ * Callback called continuously as the marker is dragged
110
+ */
111
+ onDrag: PropTypes.func,
112
+
113
+ /**
114
+ * Callback that is called when a drag on this marker finishes. This is usually the point you
115
+ * will want to setState on the marker's coordinate again
116
+ */
117
+ onDragEnd: PropTypes.func,
118
+ };
119
+
120
+
121
+ class MFMarker extends React.Component {
122
+ constructor(props) {
123
+ super(props);
124
+ this._onPress = this._onPress.bind(this)
125
+ this._ref = this._ref.bind(this)
126
+ }
127
+
128
+ setCoordinate(location) {
129
+ this._runCommand("setCoordinate", [location])
130
+ }
131
+
132
+ setRotation(rotation) {
133
+ this._runCommand("setRotation", [rotation])
134
+ }
135
+
136
+ setTitle(title) {
137
+ this._runCommand("setTitle", [title])
138
+ }
139
+
140
+ setSnippet(snippet) {
141
+ this._runCommand("setSnippet", [snippet])
142
+ }
143
+
144
+ setDraggable(draggable) {
145
+ this._runCommand("setDraggable", [draggable])
146
+ }
147
+
148
+ setZIndex(zIndex) {
149
+ this._runCommand("setZIndex", [zIndex])
150
+ }
151
+
152
+ setVisible(visible) {
153
+ this._runCommand("setVisible", [visible])
154
+ }
155
+
156
+ setInfoWindowAnchor(anchor) {
157
+ this._runCommand("setInfoWindowAnchor", [anchor])
158
+ }
159
+
160
+ setElevation(elevation) {
161
+ this._runCommand("setElevation", [elevation])
162
+ }
163
+
164
+ setUserData(userData) {
165
+ this._runCommand("setUserData", [userData])
166
+ }
167
+
168
+ _getHandle() {
169
+ return findNodeHandle(this.marker);
170
+ }
171
+
172
+
173
+ _runCommand(name, args) {
174
+ switch (Platform.OS) {
175
+ case 'android':
176
+ NativeModules.UIManager.dispatchViewManagerCommand(
177
+ this._getHandle(),
178
+ this._uiManagerCommand(name),
179
+ args
180
+ );
181
+ break;
182
+
183
+ case 'ios':
184
+ //this.getMapManagerCommand(name)(this._getHandle(), ...args);
185
+ this._mapManagerCommand(name)(this._getHandle(), ...args);
186
+ break;
187
+
188
+ default:
189
+ break;
190
+ }
191
+ }
192
+
193
+ _uiManagerCommand(name) {
194
+ const UIManager = NativeModules.UIManager;
195
+ const componentName = "RMFMarker";
196
+
197
+ if (!UIManager.getViewManagerConfig) {
198
+ // RN < 0.58
199
+ return UIManager[componentName].Commands[name];
200
+ }
201
+
202
+ // RN >= 0.58
203
+ return UIManager.getViewManagerConfig(componentName).Commands[name];
204
+ }
205
+
206
+ _mapManagerCommand(name) {
207
+ return NativeModules[`RMFMarker`][name];
208
+ }
209
+
210
+ _onPress(event) {
211
+ event.stopPropagation();
212
+ if (this.props.onPress) {
213
+ this.props.onPress(event);
214
+ }
215
+ }
216
+
217
+ _ref(ref) {
218
+ this.marker = ref;
219
+ }
220
+
221
+ render() {
222
+ let icon = {};
223
+ if (this.props.icon) {
224
+ let uri = Image.resolveAssetSource(this.props.icon.uri) || {uri: this.props.icon.uri};
225
+ icon = {uri: uri.uri, width: this.props.icon.width, height: this.props.icon.height}
226
+ }
227
+ return <RMFMarker
228
+ {...this.props}
229
+ icon={icon}
230
+ ref={this._ref}
231
+ style={[styles.marker, this.props.style]}
232
+ onPress={this._onPress}
233
+ />;
234
+ }
235
+ }
236
+
237
+ MFMarker.propTypes = propTypes;
238
+ var RMFMarker = requireNativeComponent(`RMFMarker`, MFMarker);
239
+
240
+ const styles = StyleSheet.create({
241
+ marker: {
242
+ position: 'absolute'
243
+ },
244
+ });
245
+
246
+ export {MFMarker}