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