react-native-maps 1.20.1 → 1.21.0-alpha.10
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/README.md +13 -6
- package/android/build.gradle +19 -4
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
- package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +151 -7
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +28 -119
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +3 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +2 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +16 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +581 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +8 -5
- package/ios/AirMaps/AIRMap.m +180 -27
- package/ios/AirMaps/AIRMapManager.m +24 -39
- package/ios/AirMaps/AIRMapMarker.m +11 -3
- package/ios/AirMaps/RCTConvert+AirMap.h +6 -1
- package/ios/AirMaps/RCTConvert+AirMap.m +18 -0
- package/ios/AirMaps/RNMapsAirModule.h +16 -0
- package/ios/AirMaps/RNMapsAirModule.mm +149 -0
- package/ios/AirMaps/RNMapsMapView.h +24 -0
- package/ios/AirMaps/RNMapsMapView.mm +535 -0
- package/ios/AirMaps/RNMapsMapViewManager.mm +24 -0
- package/ios/AirMaps.xcodeproj/project.pbxproj +10 -0
- package/lib/MapOverlay.d.ts +1 -1
- package/lib/MapView.d.ts +8 -4
- package/lib/MapView.js +148 -73
- package/lib/createFabricMap.d.ts +23 -0
- package/lib/createFabricMap.js +175 -0
- package/lib/specs/NativeAirMapsModule.d.ts +31 -0
- package/lib/specs/NativeAirMapsModule.js +4 -0
- package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
- package/lib/specs/NativeComponentGoogleMapView.js +21 -0
- package/lib/specs/NativeComponentMapView.d.ts +855 -0
- package/lib/specs/NativeComponentMapView.js +21 -0
- package/package.json +14 -7
- package/react-native-maps.podspec +3 -1
- package/react-native-google-maps.podspec +0 -25
package/lib/MapView.js
CHANGED
|
@@ -22,13 +22,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.AnimatedMapView = exports.MAP_TYPES = void 0;
|
|
27
30
|
const React = __importStar(require("react"));
|
|
28
31
|
const react_native_1 = require("react-native");
|
|
29
32
|
const decorateMapComponent_1 = require("./decorateMapComponent");
|
|
30
|
-
const ProviderConstants = __importStar(require("./ProviderConstants"));
|
|
31
33
|
const MapViewNativeComponent_1 = require("./MapViewNativeComponent");
|
|
34
|
+
const NativeComponentMapView_1 = __importStar(require("./specs/NativeComponentMapView"));
|
|
35
|
+
const NativeComponentGoogleMapView_1 = __importStar(require("./specs/NativeComponentGoogleMapView"));
|
|
36
|
+
const createFabricMap_1 = __importDefault(require("./createFabricMap"));
|
|
37
|
+
const FabricMap = (0, createFabricMap_1.default)(NativeComponentMapView_1.default, NativeComponentMapView_1.Commands);
|
|
38
|
+
const FabricGoogleMap = (0, createFabricMap_1.default)(NativeComponentGoogleMapView_1.default, NativeComponentGoogleMapView_1.Commands);
|
|
32
39
|
exports.MAP_TYPES = {
|
|
33
40
|
STANDARD: 'standard',
|
|
34
41
|
SATELLITE: 'satellite',
|
|
@@ -39,13 +46,14 @@ exports.MAP_TYPES = {
|
|
|
39
46
|
SATELLITE_FLYOVER: 'satelliteFlyover',
|
|
40
47
|
HYBRID_FLYOVER: 'hybridFlyover',
|
|
41
48
|
};
|
|
42
|
-
const GOOGLE_MAPS_ONLY_TYPES = [exports.MAP_TYPES.TERRAIN, exports.MAP_TYPES.NONE];
|
|
43
49
|
class MapView extends React.Component {
|
|
44
50
|
static Animated;
|
|
45
51
|
map;
|
|
52
|
+
fabricMap;
|
|
46
53
|
constructor(props) {
|
|
47
54
|
super(props);
|
|
48
55
|
this.map = React.createRef();
|
|
56
|
+
this.fabricMap = React.createRef();
|
|
49
57
|
this.state = {
|
|
50
58
|
isReady: react_native_1.Platform.OS === 'ios',
|
|
51
59
|
};
|
|
@@ -81,40 +89,60 @@ class MapView extends React.Component {
|
|
|
81
89
|
return react_native_1.NativeModules.AirMapModule.getCamera(this._getHandle());
|
|
82
90
|
}
|
|
83
91
|
else if (react_native_1.Platform.OS === 'ios') {
|
|
84
|
-
|
|
92
|
+
if (this.fabricMap.current) {
|
|
93
|
+
return this.fabricMap.current.getCamera();
|
|
94
|
+
}
|
|
85
95
|
}
|
|
86
96
|
return Promise.reject('getCamera not supported on this platform');
|
|
87
97
|
}
|
|
88
98
|
setCamera(camera) {
|
|
89
|
-
if (this.
|
|
99
|
+
if (this.fabricMap.current) {
|
|
100
|
+
this.fabricMap.current.setCamera(camera);
|
|
101
|
+
}
|
|
102
|
+
else if (this.map.current) {
|
|
90
103
|
MapViewNativeComponent_1.Commands.setCamera(this.map.current, camera);
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
106
|
animateCamera(camera, opts) {
|
|
94
|
-
if (this.
|
|
107
|
+
if (this.fabricMap.current) {
|
|
108
|
+
this.fabricMap.current.animateCamera(camera, opts?.duration ? opts.duration : 500);
|
|
109
|
+
}
|
|
110
|
+
else if (this.map.current) {
|
|
95
111
|
MapViewNativeComponent_1.Commands.animateCamera(this.map.current, camera, opts?.duration ? opts.duration : 500);
|
|
96
112
|
}
|
|
97
113
|
}
|
|
98
114
|
animateToRegion(region, duration = 500) {
|
|
99
|
-
if (this.
|
|
115
|
+
if (this.fabricMap.current) {
|
|
116
|
+
this.fabricMap.current.animateToRegion(region, duration);
|
|
117
|
+
}
|
|
118
|
+
else if (this.map.current) {
|
|
100
119
|
MapViewNativeComponent_1.Commands.animateToRegion(this.map.current, region, duration);
|
|
101
120
|
}
|
|
102
121
|
}
|
|
103
122
|
fitToElements(options = {}) {
|
|
104
|
-
|
|
105
|
-
|
|
123
|
+
const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
|
|
124
|
+
if (this.fabricMap.current) {
|
|
125
|
+
this.fabricMap.current.fitToElements(edgePadding, animated);
|
|
126
|
+
}
|
|
127
|
+
else if (this.map.current) {
|
|
106
128
|
MapViewNativeComponent_1.Commands.fitToElements(this.map.current, edgePadding, animated);
|
|
107
129
|
}
|
|
108
130
|
}
|
|
109
131
|
fitToSuppliedMarkers(markers, options = {}) {
|
|
110
|
-
|
|
111
|
-
|
|
132
|
+
const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
|
|
133
|
+
if (this.fabricMap.current) {
|
|
134
|
+
this.fabricMap.current.fitToSuppliedMarkers(markers, edgePadding, animated);
|
|
135
|
+
}
|
|
136
|
+
else if (this.map.current) {
|
|
112
137
|
MapViewNativeComponent_1.Commands.fitToSuppliedMarkers(this.map.current, markers, edgePadding, animated);
|
|
113
138
|
}
|
|
114
139
|
}
|
|
115
140
|
fitToCoordinates(coordinates = [], options = {}) {
|
|
116
|
-
|
|
117
|
-
|
|
141
|
+
const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
|
|
142
|
+
if (this.fabricMap.current) {
|
|
143
|
+
this.fabricMap.current.fitToCoordinates(coordinates, edgePadding, animated);
|
|
144
|
+
}
|
|
145
|
+
else if (this.map.current) {
|
|
118
146
|
MapViewNativeComponent_1.Commands.fitToCoordinates(this.map.current, coordinates, edgePadding, animated);
|
|
119
147
|
}
|
|
120
148
|
}
|
|
@@ -128,7 +156,9 @@ class MapView extends React.Component {
|
|
|
128
156
|
return await react_native_1.NativeModules.AirMapModule.getMapBoundaries(this._getHandle());
|
|
129
157
|
}
|
|
130
158
|
else if (react_native_1.Platform.OS === 'ios') {
|
|
131
|
-
|
|
159
|
+
if (this.fabricMap.current) {
|
|
160
|
+
return this.fabricMap.current.getMapBoundaries();
|
|
161
|
+
}
|
|
132
162
|
}
|
|
133
163
|
return Promise.reject('getMapBoundaries not supported on this platform');
|
|
134
164
|
}
|
|
@@ -177,24 +207,10 @@ class MapView extends React.Component {
|
|
|
177
207
|
return react_native_1.NativeModules.AirMapModule.takeSnapshot(this._getHandle(), config);
|
|
178
208
|
}
|
|
179
209
|
else if (react_native_1.Platform.OS === 'ios') {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
config.region,
|
|
185
|
-
config.format,
|
|
186
|
-
config.quality,
|
|
187
|
-
config.result,
|
|
188
|
-
(err, snapshot) => {
|
|
189
|
-
if (err) {
|
|
190
|
-
reject(err);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
resolve(snapshot);
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
]);
|
|
197
|
-
});
|
|
210
|
+
if (this.fabricMap.current) {
|
|
211
|
+
// @ts-ignore
|
|
212
|
+
return this.fabricMap.current.takeSnapshot(config);
|
|
213
|
+
}
|
|
198
214
|
}
|
|
199
215
|
return Promise.reject('takeSnapshot not supported on this platform');
|
|
200
216
|
}
|
|
@@ -212,7 +228,9 @@ class MapView extends React.Component {
|
|
|
212
228
|
return react_native_1.NativeModules.AirMapModule.getAddressFromCoordinates(this._getHandle(), coordinate);
|
|
213
229
|
}
|
|
214
230
|
else if (react_native_1.Platform.OS === 'ios') {
|
|
215
|
-
|
|
231
|
+
if (this.fabricMap.current) {
|
|
232
|
+
return this.fabricMap.current.getAddressFromCoordinates(coordinate);
|
|
233
|
+
}
|
|
216
234
|
}
|
|
217
235
|
return Promise.reject('getAddress not supported on this platform');
|
|
218
236
|
}
|
|
@@ -230,7 +248,9 @@ class MapView extends React.Component {
|
|
|
230
248
|
return react_native_1.NativeModules.AirMapModule.pointForCoordinate(this._getHandle(), coordinate);
|
|
231
249
|
}
|
|
232
250
|
else if (react_native_1.Platform.OS === 'ios') {
|
|
233
|
-
|
|
251
|
+
if (this.fabricMap.current) {
|
|
252
|
+
return this.fabricMap.current.getPointForCoordinate(coordinate);
|
|
253
|
+
}
|
|
234
254
|
}
|
|
235
255
|
return Promise.reject('pointForCoordinate not supported on this platform');
|
|
236
256
|
}
|
|
@@ -248,7 +268,9 @@ class MapView extends React.Component {
|
|
|
248
268
|
return react_native_1.NativeModules.AirMapModule.coordinateForPoint(this._getHandle(), point);
|
|
249
269
|
}
|
|
250
270
|
else if (react_native_1.Platform.OS === 'ios') {
|
|
251
|
-
|
|
271
|
+
if (this.fabricMap.current) {
|
|
272
|
+
return this.fabricMap.current.getCoordinateForPoint(point);
|
|
273
|
+
}
|
|
252
274
|
}
|
|
253
275
|
return Promise.reject('coordinateForPoint not supported on this platform');
|
|
254
276
|
}
|
|
@@ -261,7 +283,10 @@ class MapView extends React.Component {
|
|
|
261
283
|
*/
|
|
262
284
|
getMarkersFrames(onlyVisible = false) {
|
|
263
285
|
if (react_native_1.Platform.OS === 'ios') {
|
|
264
|
-
|
|
286
|
+
if (this.fabricMap.current) {
|
|
287
|
+
// @ts-ignore
|
|
288
|
+
return this.fabricMap.current.getMarkersFrames(onlyVisible);
|
|
289
|
+
}
|
|
265
290
|
}
|
|
266
291
|
return Promise.reject('getMarkersFrames not supported on this platform');
|
|
267
292
|
}
|
|
@@ -284,69 +309,119 @@ class MapView extends React.Component {
|
|
|
284
309
|
},
|
|
285
310
|
};
|
|
286
311
|
}
|
|
287
|
-
_mapManagerCommand(name) {
|
|
288
|
-
return react_native_1.NativeModules[`${(0, decorateMapComponent_1.getNativeMapName)(this.props.provider)}Manager`][name];
|
|
289
|
-
}
|
|
290
312
|
_getHandle() {
|
|
291
313
|
return (0, react_native_1.findNodeHandle)(this.map.current);
|
|
292
314
|
}
|
|
293
|
-
|
|
294
|
-
if (
|
|
295
|
-
|
|
315
|
+
handleMapPress = (event) => {
|
|
316
|
+
if (this.props.onPress) {
|
|
317
|
+
this.props.onPress(event);
|
|
296
318
|
}
|
|
297
|
-
|
|
298
|
-
|
|
319
|
+
};
|
|
320
|
+
handleMarkerPress = (event) => {
|
|
321
|
+
if (this.props.onMarkerPress) {
|
|
322
|
+
this.props.onMarkerPress(event);
|
|
299
323
|
}
|
|
300
|
-
}
|
|
324
|
+
};
|
|
325
|
+
handleMarkerSelect = (event) => {
|
|
326
|
+
if (this.props.onMarkerSelect) {
|
|
327
|
+
this.props.onMarkerSelect(event);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
handleMarkerDeselect = (event) => {
|
|
331
|
+
if (this.props.onMarkerDeselect) {
|
|
332
|
+
this.props.onMarkerDeselect(event);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
handleRegionChange = (event) => {
|
|
336
|
+
const isGesture = event.nativeEvent.isGesture;
|
|
337
|
+
const details = { isGesture };
|
|
338
|
+
if (event.nativeEvent.continuous) {
|
|
339
|
+
if (this.props.onRegionChange) {
|
|
340
|
+
this.props.onRegionChange(event.nativeEvent.region, details);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else if (this.props.onRegionChangeComplete) {
|
|
344
|
+
this.props.onRegionChangeComplete(event.nativeEvent.region, details);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
301
347
|
render() {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
348
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
349
|
+
// Define props specifically for MapFabricNativeProps
|
|
350
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
351
|
+
const { onCalloutPress, onIndoorBuildingFocused, onKmlReady, onLongPress, onMarkerDeselect, onMarkerPress, onMarkerSelect, onRegionChangeStart, onRegionChange, onRegionChangeComplete, onPress, minZoomLevel, maxZoomLevel, region, provider, ...restProps } = this.props;
|
|
352
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
353
|
+
const userInterfaceStyle = this.props.userInterfaceStyle || 'system';
|
|
354
|
+
const props = {
|
|
308
355
|
onMapReady: this._onMapReady,
|
|
309
356
|
liteMode: this.props.liteMode,
|
|
310
357
|
googleMapId: this.props.googleMapId,
|
|
311
358
|
googleRenderer: this.props.googleRenderer,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
359
|
+
onPress: this.handleMapPress,
|
|
360
|
+
onMarkerPress: this.handleMarkerPress,
|
|
361
|
+
onMarkerSelect: this.handleMarkerSelect,
|
|
362
|
+
onMarkerDeselect: this.handleMarkerDeselect,
|
|
363
|
+
userInterfaceStyle: userInterfaceStyle,
|
|
364
|
+
minZoom: minZoomLevel,
|
|
365
|
+
maxZoom: maxZoomLevel,
|
|
366
|
+
onRegionChange: this.handleRegionChange,
|
|
367
|
+
...restProps,
|
|
317
368
|
};
|
|
318
|
-
if (
|
|
319
|
-
props.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
369
|
+
if (this.props.region) {
|
|
370
|
+
props.region = {
|
|
371
|
+
latitude: this.props.region.latitude,
|
|
372
|
+
longitude: this.props.region.longitude,
|
|
373
|
+
latitudeDelta: this.props.region.latitudeDelta,
|
|
374
|
+
longitudeDelta: this.props.region.longitudeDelta,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
if (!this.state.isReady) {
|
|
378
|
+
props.style = this.props.style;
|
|
379
|
+
props.initialCamera = this.props.initialCamera;
|
|
380
|
+
props.onLayout = this.props.onLayout;
|
|
323
381
|
}
|
|
324
|
-
if (
|
|
325
|
-
|
|
382
|
+
if (provider === 'google') {
|
|
383
|
+
return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
|
|
384
|
+
<FabricGoogleMap {...props} ref={this.fabricMap}/>
|
|
385
|
+
</decorateMapComponent_1.ProviderContext.Provider>);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
|
|
389
|
+
<FabricMap {...props} ref={this.fabricMap}/>
|
|
390
|
+
</decorateMapComponent_1.ProviderContext.Provider>);
|
|
326
391
|
}
|
|
327
392
|
}
|
|
328
393
|
else {
|
|
329
|
-
|
|
330
|
-
|
|
394
|
+
const AIRMap = getNativeMapComponent(this.props.provider);
|
|
395
|
+
// Define props specifically for NativeProps
|
|
396
|
+
const props = {
|
|
331
397
|
region: null,
|
|
398
|
+
initialRegion: null,
|
|
399
|
+
onChange: this._onChange,
|
|
400
|
+
onMapReady: this._onMapReady,
|
|
332
401
|
liteMode: this.props.liteMode,
|
|
333
402
|
googleMapId: this.props.googleMapId,
|
|
334
403
|
googleRenderer: this.props.googleRenderer,
|
|
335
|
-
initialRegion: this.props.initialRegion || null,
|
|
336
|
-
initialCamera: this.props.initialCamera,
|
|
337
404
|
ref: this.map,
|
|
338
|
-
onChange: this._onChange,
|
|
339
|
-
onMapReady: this._onMapReady,
|
|
340
|
-
onLayout: this.props.onLayout,
|
|
341
405
|
customMapStyleString: this.props.customMapStyle
|
|
342
406
|
? JSON.stringify(this.props.customMapStyle)
|
|
343
407
|
: undefined,
|
|
408
|
+
...this.props,
|
|
344
409
|
};
|
|
410
|
+
if (this.state.isReady) {
|
|
411
|
+
if (props.onPanDrag) {
|
|
412
|
+
props.handlePanDrag = !!props.onPanDrag;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
props.style = this.props.style;
|
|
417
|
+
props.initialCamera = this.props.initialCamera;
|
|
418
|
+
props.onLayout = this.props.onLayout;
|
|
419
|
+
}
|
|
420
|
+
// Render AIRMap with NativeProps
|
|
421
|
+
return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
|
|
422
|
+
<AIRMap {...props}/>
|
|
423
|
+
</decorateMapComponent_1.ProviderContext.Provider>);
|
|
345
424
|
}
|
|
346
|
-
const AIRMap = getNativeMapComponent(this.props.provider);
|
|
347
|
-
return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
|
|
348
|
-
<AIRMap {...props}/>
|
|
349
|
-
</decorateMapComponent_1.ProviderContext.Provider>);
|
|
350
425
|
}
|
|
351
426
|
}
|
|
352
427
|
const airMaps = {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { LatLng, Point, Region } from './sharedTypes';
|
|
3
|
+
import type { Address, Camera, EdgePadding, SnapshotOptions } from './MapView.types';
|
|
4
|
+
import { MapBoundaries } from './specs/NativeAirMapsModule';
|
|
5
|
+
import { MapFabricNativeProps } from './specs/NativeComponentMapView';
|
|
6
|
+
export type FabricMapViewProps = MapFabricNativeProps;
|
|
7
|
+
export interface FabricMapHandle {
|
|
8
|
+
getCamera: () => Promise<Camera>;
|
|
9
|
+
setCamera: (camera: Partial<Camera>) => void;
|
|
10
|
+
animateToRegion: (region: Region, duration: number) => void;
|
|
11
|
+
animateCamera: (camera: Partial<Camera>, duration: number) => void;
|
|
12
|
+
getMarkersFrames: (onlyVisible: boolean) => Promise<unknown>;
|
|
13
|
+
fitToElements: (edgePadding: EdgePadding, animated: boolean) => void;
|
|
14
|
+
fitToSuppliedMarkers: (markers: string[], edgePadding: EdgePadding, animated: boolean) => void;
|
|
15
|
+
fitToCoordinates: (coordinates: LatLng[], edgePadding: EdgePadding, animated: boolean) => void;
|
|
16
|
+
getMapBoundaries: () => Promise<MapBoundaries>;
|
|
17
|
+
takeSnapshot: (config: SnapshotOptions) => Promise<string>;
|
|
18
|
+
getAddressFromCoordinates: (coordinate: LatLng) => Promise<Address>;
|
|
19
|
+
getPointForCoordinate: (coordinate: LatLng) => Promise<Point>;
|
|
20
|
+
getCoordinateForPoint: (point: Point) => Promise<LatLng>;
|
|
21
|
+
}
|
|
22
|
+
declare const createFabricMap: (ViewComponent: React.ComponentType, Commands: any) => React.ForwardRefExoticComponent<MapFabricNativeProps & React.RefAttributes<FabricMapHandle>>;
|
|
23
|
+
export default createFabricMap;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const react_native_1 = require("react-native");
|
|
31
|
+
const NativeAirMapsModule_1 = __importDefault(require("./specs/NativeAirMapsModule"));
|
|
32
|
+
const createFabricMap = (ViewComponent, Commands) => {
|
|
33
|
+
return (0, react_1.forwardRef)((props, ref) => {
|
|
34
|
+
const fabricRef = (0, react_1.useRef)(null);
|
|
35
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
36
|
+
async getMarkersFrames(onlyVisible) {
|
|
37
|
+
if (fabricRef.current) {
|
|
38
|
+
return NativeAirMapsModule_1.default.getMarkersFrames((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, onlyVisible);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error('getMarkersFrames is only supported on iOS with Fabric.');
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async getCoordinateForPoint(point) {
|
|
45
|
+
if (fabricRef.current) {
|
|
46
|
+
return NativeAirMapsModule_1.default.getCoordinateForPoint((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, point);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new Error('getCoordinateForPoint is only supported on iOS with Fabric.');
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
async getPointForCoordinate(coordinate) {
|
|
53
|
+
if (fabricRef.current) {
|
|
54
|
+
return NativeAirMapsModule_1.default.getPointForCoordinate((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, coordinate);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw new Error('getPointForCoordinate is only supported on iOS with Fabric.');
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
async getAddressFromCoordinates(coordinate) {
|
|
61
|
+
if (fabricRef.current) {
|
|
62
|
+
return NativeAirMapsModule_1.default.getAddressFromCoordinates((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, coordinate);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new Error('getAddressFromCoordinates is only supported on iOS with Fabric.');
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async takeSnapshot(config) {
|
|
69
|
+
if (fabricRef.current) {
|
|
70
|
+
return NativeAirMapsModule_1.default.takeSnapshot((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, config);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new Error('takeSnapshot is only supported on iOS with Fabric.');
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
async getCamera() {
|
|
77
|
+
if (fabricRef.current) {
|
|
78
|
+
return NativeAirMapsModule_1.default.getCamera((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new Error('getCamera is only supported on iOS with Fabric.');
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
async getMapBoundaries() {
|
|
85
|
+
if (fabricRef.current) {
|
|
86
|
+
return NativeAirMapsModule_1.default.getMapBoundaries((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new Error('getMapBoundaries is only supported on iOS with Fabric.');
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
animateToRegion(region, duration) {
|
|
93
|
+
if (fabricRef.current) {
|
|
94
|
+
try {
|
|
95
|
+
Commands.animateToRegion(fabricRef.current, JSON.stringify(region), duration);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw new Error('Failed to animateToRegion');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw new Error('animateToRegion is only supported on iOS with Fabric.');
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
fitToElements(edgePadding, animated) {
|
|
106
|
+
if (fabricRef.current) {
|
|
107
|
+
try {
|
|
108
|
+
Commands.fitToElements(fabricRef.current, JSON.stringify(edgePadding), animated);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
throw new Error('Failed to fitToElements');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
throw new Error('fitToElements is only supported on iOS with Fabric.');
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
fitToSuppliedMarkers(markers, edgePadding, animated) {
|
|
119
|
+
if (fabricRef.current) {
|
|
120
|
+
try {
|
|
121
|
+
Commands.fitToSuppliedMarkers(fabricRef.current, JSON.stringify(markers), JSON.stringify(edgePadding), animated);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
throw new Error('Failed to fitToSuppliedMarkers');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw new Error('fitToSuppliedMarkers is only supported on iOS with Fabric.');
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
animateCamera(camera, duration) {
|
|
132
|
+
if (fabricRef.current) {
|
|
133
|
+
try {
|
|
134
|
+
Commands.animateCamera(fabricRef.current, JSON.stringify(camera), duration);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
throw new Error('Failed to animateCamera');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
throw new Error('animateCamera is only supported on iOS with Fabric.');
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
fitToCoordinates(coordinates, edgePadding, animated) {
|
|
145
|
+
if (fabricRef.current) {
|
|
146
|
+
try {
|
|
147
|
+
Commands.fitToCoordinates(fabricRef.current, JSON.stringify(coordinates), JSON.stringify(edgePadding), animated);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
throw new Error('Failed to fitToCoordinates');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
throw new Error('fitToCoordinates is only supported on iOS with Fabric.');
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
setCamera(camera) {
|
|
158
|
+
if (fabricRef.current) {
|
|
159
|
+
try {
|
|
160
|
+
Commands.setCamera(fabricRef.current, JSON.stringify(camera));
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
console.error('Failed to set camera:', error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.warn('setCamera is only supported on iOS with Fabric.');
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
}));
|
|
171
|
+
// @ts-ignore
|
|
172
|
+
return <ViewComponent {...props} ref={fabricRef}/>;
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
exports.default = createFabricMap;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import type { Double, UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import type { Camera } from './NativeComponentMapView';
|
|
4
|
+
import { Address } from 'react-native-maps';
|
|
5
|
+
type LatLng = {
|
|
6
|
+
latitude: Double;
|
|
7
|
+
longitude: Double;
|
|
8
|
+
};
|
|
9
|
+
type Point = Readonly<{
|
|
10
|
+
x: Double;
|
|
11
|
+
y: Double;
|
|
12
|
+
}>;
|
|
13
|
+
export type Region = Readonly<LatLng & {
|
|
14
|
+
latitudeDelta: Double;
|
|
15
|
+
longitudeDelta: Double;
|
|
16
|
+
}>;
|
|
17
|
+
export type MapBoundaries = {
|
|
18
|
+
northEast: LatLng;
|
|
19
|
+
southWest: LatLng;
|
|
20
|
+
};
|
|
21
|
+
export interface Spec extends TurboModule {
|
|
22
|
+
getCamera(tag: Double): Promise<Camera>;
|
|
23
|
+
getMarkersFrames(tag: Double, onlyVisible: boolean): Promise<unknown>;
|
|
24
|
+
getMapBoundaries(tag: Double): Promise<MapBoundaries>;
|
|
25
|
+
takeSnapshot(tag: Double, config: UnsafeObject): Promise<string>;
|
|
26
|
+
getAddressFromCoordinates(tag: Double, coordinate: LatLng): Promise<Address>;
|
|
27
|
+
getPointForCoordinate(tag: Double, coordinate: LatLng): Promise<Point>;
|
|
28
|
+
getCoordinateForPoint(tag: Double, point: Point): Promise<LatLng>;
|
|
29
|
+
}
|
|
30
|
+
declare const _default: Spec;
|
|
31
|
+
export default _default;
|