react-native-maps 1.21.0-alpha.7 → 1.21.0-alpha.8
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/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +5 -3
- package/ios/AirMaps/AIRMap.h +2 -2
- package/ios/AirMaps/AIRMap.m +12 -0
- package/ios/AirMaps/AIRMapManager.m +2 -17
- package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
- package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
- package/ios/AirMaps/RNMapsMapView.mm +10 -0
- package/lib/MapView.js +16 -7
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -11
- package/lib/createFabricMap.js +175 -0
- package/package.json +1 -1
- package/lib/FabricMapView.js +0 -181
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
#import <Foundation/Foundation.h>
|
|
10
10
|
#import <GoogleMaps/GoogleMaps.h>
|
|
11
11
|
#import <React/RCTConvert.h>
|
|
12
|
+
#import "AIRGoogleMapCoordinate.h"
|
|
12
13
|
|
|
13
14
|
@interface RCTConvert (GMSMapViewType)
|
|
14
15
|
+ (GMSCameraPosition*)GMSCameraPositionWithDefaults:(id)json existingCamera:(GMSCameraPosition*)existingCamera;
|
|
16
|
+
+ (NSArray<NSArray<AIRGoogleMapCoordinate *> *> *)AIRGoogleMapCoordinateArrayArray:(id)json;
|
|
17
|
+
+ (AIRGoogleMapCoordinate *)AIRGoogleMapCoordinate:(id)json;
|
|
15
18
|
@end
|
|
16
19
|
|
|
17
20
|
#endif
|
|
@@ -73,10 +73,14 @@ using namespace facebook::react;
|
|
|
73
73
|
}
|
|
74
74
|
- (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
75
75
|
NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
|
|
76
|
+
NSMutableArray<AIRGoogleMapCoordinate*>* coordinatesArray = [NSMutableArray new];
|
|
77
|
+
for (id json : coordinatesArr){
|
|
78
|
+
[coordinatesArray addObject:[RCTConvert AIRGoogleMapCoordinate:json]];
|
|
79
|
+
}
|
|
76
80
|
|
|
77
81
|
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
[_view fitToCoordinates:coordinatesArray withEdgePadding:edgePadding animated:animated];
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
#pragma mark - Native commands
|
|
@@ -128,7 +132,6 @@ using namespace facebook::react;
|
|
|
128
132
|
|
|
129
133
|
_view.onMapReady = [self](NSDictionary* dictionary) {
|
|
130
134
|
if (_eventEmitter) {
|
|
131
|
-
NSLog(@"mapReady");
|
|
132
135
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
133
136
|
facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapReady data = {};
|
|
134
137
|
mapViewEventEmitter->onMapReady(data);
|
|
@@ -137,7 +140,6 @@ using namespace facebook::react;
|
|
|
137
140
|
|
|
138
141
|
_view.onMapLoaded = [self](NSDictionary* dictionary) {
|
|
139
142
|
if (_eventEmitter) {
|
|
140
|
-
NSLog(@"mapLoaded");
|
|
141
143
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsGoogleMapViewEventEmitter const>(_eventEmitter);
|
|
142
144
|
facebook::react::RNMapsGoogleMapViewEventEmitter::OnMapLoaded data = {};
|
|
143
145
|
mapViewEventEmitter->onMapLoaded(data);
|
package/ios/AirMaps/AIRMap.h
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
#import "SMCalloutView.h"
|
|
15
15
|
#import "RCTConvert+AirMap.h"
|
|
16
16
|
#import "AIRMapCalloutSubview.h"
|
|
17
|
-
|
|
17
|
+
@class AIRMapCoordinate;
|
|
18
18
|
@class AIRMapMarker;
|
|
19
19
|
|
|
20
20
|
extern const NSTimeInterval AIRMapRegionChangeObserveInterval;
|
|
@@ -80,5 +80,5 @@ extern const NSInteger AIRMapMaxZoomLevel;
|
|
|
80
80
|
- (AIRMapMarker*) markerAtPoint:(CGPoint)point;
|
|
81
81
|
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
|
|
82
82
|
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex;
|
|
83
|
-
|
|
83
|
+
-(void) fitToCoordinates:(NSArray<AIRMapCoordinate*>*) coordinates edgePadding:(UIEdgeInsets) edgeInsets animated:(Boolean) animated;
|
|
84
84
|
@end
|
package/ios/AirMaps/AIRMap.m
CHANGED
|
@@ -199,7 +199,19 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
199
199
|
}
|
|
200
200
|
return marker;
|
|
201
201
|
}
|
|
202
|
+
// Create Polyline with coordinates
|
|
203
|
+
-(void) fitToCoordinates:(NSArray<AIRMapCoordinate*>*) coordinates edgePadding:(UIEdgeInsets) edgeInsets animated:(Boolean) animated {
|
|
204
|
+
CLLocationCoordinate2D coords[coordinates.count];
|
|
205
|
+
for(int i = 0; i < coordinates.count; i++)
|
|
206
|
+
{
|
|
207
|
+
coords[i] = coordinates[i].coordinate;
|
|
208
|
+
}
|
|
209
|
+
MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count];
|
|
202
210
|
|
|
211
|
+
// Set Map viewport
|
|
212
|
+
|
|
213
|
+
[self setVisibleMapRect:[polyline boundingMapRect] edgePadding:edgeInsets animated:animated];
|
|
214
|
+
}
|
|
203
215
|
- (CGRect) frameForMarker:(AIRMapMarker*) mrkAnn {
|
|
204
216
|
MKAnnotationView* mrkView = [self viewForAnnotation: mrkAnn];
|
|
205
217
|
CGRect mrkFrame = mrkView.frame;
|
|
@@ -350,23 +350,8 @@ RCT_EXPORT_METHOD(fitToCoordinates:(nonnull NSNumber *)reactTag
|
|
|
350
350
|
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
351
351
|
} else {
|
|
352
352
|
AIRMap *mapView = (AIRMap *)view;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
CLLocationCoordinate2D coords[coordinates.count];
|
|
356
|
-
for(int i = 0; i < coordinates.count; i++)
|
|
357
|
-
{
|
|
358
|
-
coords[i] = coordinates[i].coordinate;
|
|
359
|
-
}
|
|
360
|
-
MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count];
|
|
361
|
-
|
|
362
|
-
// Set Map viewport
|
|
363
|
-
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
364
|
-
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
365
|
-
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
366
|
-
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
367
|
-
|
|
368
|
-
[mapView setVisibleMapRect:[polyline boundingMapRect] edgePadding:UIEdgeInsetsMake(top, left, bottom, right) animated:animated];
|
|
369
|
-
|
|
353
|
+
UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
|
|
354
|
+
[mapView fitToCoordinates: coordinates edgePadding:edgeInsets animated:animated];
|
|
370
355
|
}
|
|
371
356
|
}];
|
|
372
357
|
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
#import <MapKit/MapKit.h>
|
|
8
8
|
#import <React/RCTConvert.h>
|
|
9
9
|
|
|
10
|
+
@class AIRMapCoordinate;
|
|
11
|
+
|
|
10
12
|
@interface RCTConvert (AirMap)
|
|
11
13
|
|
|
12
14
|
+ (MKCoordinateSpan)MKCoordinateSpan:(id)json;
|
|
@@ -16,4 +18,6 @@
|
|
|
16
18
|
+ (MKMapType)MKMapType:(id)json;
|
|
17
19
|
+ (NSDictionary*) dictonaryFromString:(NSString *) str;
|
|
18
20
|
+ (NSArray*) arrayFromString:(NSString *) str;
|
|
21
|
+
+ (NSArray<NSArray<AIRMapCoordinate *> *> *)AIRMapCoordinateArrayArray:(id)json;
|
|
22
|
+
+ (AIRMapCoordinate*) AIRMapCoordinate:(id)json;
|
|
19
23
|
@end
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
|
|
30
31
|
+ (MKMapCamera*)MKMapCamera:(id)json
|
|
31
32
|
{
|
|
32
33
|
json = [self NSDictionary:json];
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
error:&jsonError];
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
|
|
52
54
|
+ (MKMapCamera*)MKMapCameraWithDefaults:(id)json existingCamera:(MKMapCamera*)camera
|
|
53
55
|
{
|
|
54
56
|
json = [self NSDictionary:json];
|
|
@@ -76,6 +76,16 @@ using namespace facebook::react;
|
|
|
76
76
|
|
|
77
77
|
}
|
|
78
78
|
- (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
79
|
+
NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
|
|
80
|
+
NSMutableArray<AIRMapCoordinate*>* mutableArray = [NSMutableArray new];
|
|
81
|
+
for (id json : coordinatesArr){
|
|
82
|
+
[mutableArray addObject:[RCTConvert AIRMapCoordinate:json]];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
86
|
+
|
|
87
|
+
UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
|
|
88
|
+
[_view fitToCoordinates:mutableArray edgePadding:edgeInsets animated:animated];
|
|
79
89
|
|
|
80
90
|
}
|
|
81
91
|
|
package/lib/MapView.js
CHANGED
|
@@ -31,7 +31,11 @@ const React = __importStar(require("react"));
|
|
|
31
31
|
const react_native_1 = require("react-native");
|
|
32
32
|
const decorateMapComponent_1 = require("./decorateMapComponent");
|
|
33
33
|
const MapViewNativeComponent_1 = require("./MapViewNativeComponent");
|
|
34
|
-
const
|
|
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);
|
|
35
39
|
exports.MAP_TYPES = {
|
|
36
40
|
STANDARD: 'standard',
|
|
37
41
|
SATELLITE: 'satellite',
|
|
@@ -342,10 +346,9 @@ class MapView extends React.Component {
|
|
|
342
346
|
};
|
|
343
347
|
render() {
|
|
344
348
|
if (react_native_1.Platform.OS === 'ios') {
|
|
345
|
-
const AIRMap = FabricMapView_1.default;
|
|
346
349
|
// Define props specifically for MapFabricNativeProps
|
|
347
350
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
348
|
-
const { onCalloutPress, onIndoorBuildingFocused, onKmlReady, onLongPress, onMarkerDeselect, onMarkerPress, onMarkerSelect, onRegionChangeStart, onRegionChange, onRegionChangeComplete, onPress, minZoomLevel, maxZoomLevel, region, ...restProps } = this.props;
|
|
351
|
+
const { onCalloutPress, onIndoorBuildingFocused, onKmlReady, onLongPress, onMarkerDeselect, onMarkerPress, onMarkerSelect, onRegionChangeStart, onRegionChange, onRegionChangeComplete, onPress, minZoomLevel, maxZoomLevel, region, provider, ...restProps } = this.props;
|
|
349
352
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
350
353
|
const userInterfaceStyle = this.props.userInterfaceStyle || 'system';
|
|
351
354
|
const props = {
|
|
@@ -376,10 +379,16 @@ class MapView extends React.Component {
|
|
|
376
379
|
props.initialCamera = this.props.initialCamera;
|
|
377
380
|
props.onLayout = this.props.onLayout;
|
|
378
381
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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>);
|
|
391
|
+
}
|
|
383
392
|
}
|
|
384
393
|
else {
|
|
385
394
|
const AIRMap = getNativeMapComponent(this.props.provider);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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;
|
|
6
7
|
export interface FabricMapHandle {
|
|
7
8
|
getCamera: () => Promise<Camera>;
|
|
8
9
|
setCamera: (camera: Partial<Camera>) => void;
|
|
@@ -18,10 +19,5 @@ export interface FabricMapHandle {
|
|
|
18
19
|
getPointForCoordinate: (coordinate: LatLng) => Promise<Point>;
|
|
19
20
|
getCoordinateForPoint: (point: Point) => Promise<LatLng>;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
export declare const FabricMap: React.ForwardRefExoticComponent<MapFabricNativeProps & {
|
|
25
|
-
provider?: Provider;
|
|
26
|
-
} & React.RefAttributes<FabricMapHandle>>;
|
|
27
|
-
export default FabricMap;
|
|
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;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
|
|
7
7
|
"homepage": "https://github.com/react-native-maps/react-native-maps#readme",
|
|
8
|
-
"version": "1.21.0-alpha.
|
|
8
|
+
"version": "1.21.0-alpha.8",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|
package/lib/FabricMapView.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
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
|
-
exports.FabricMap = void 0;
|
|
30
|
-
const react_1 = __importStar(require("react"));
|
|
31
|
-
const NativeAirMapsModule_1 = __importDefault(require("./specs/NativeAirMapsModule"));
|
|
32
|
-
const NativeComponentMapView_1 = __importStar(require("./specs/NativeComponentMapView"));
|
|
33
|
-
const NativeComponentGoogleMapView_1 = __importDefault(require("./specs/NativeComponentGoogleMapView"));
|
|
34
|
-
const react_native_1 = require("react-native");
|
|
35
|
-
exports.FabricMap = (0, react_1.forwardRef)((props, ref) => {
|
|
36
|
-
const fabricRef = (0, react_1.useRef)(null);
|
|
37
|
-
// Use Imperative Handle to expose commands
|
|
38
|
-
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
39
|
-
async getMarkersFrames(onlyVisible) {
|
|
40
|
-
if (fabricRef.current) {
|
|
41
|
-
return NativeAirMapsModule_1.default.getMarkersFrames((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, onlyVisible);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
throw new Error('getMarkersFrames is only supported on iOS with Fabric.');
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
async getCoordinateForPoint(point) {
|
|
48
|
-
if (fabricRef.current) {
|
|
49
|
-
return NativeAirMapsModule_1.default.getCoordinateForPoint((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, point);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
throw new Error('getCoordinateForPoint is only supported on iOS with Fabric.');
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async getPointForCoordinate(coordinate) {
|
|
56
|
-
if (fabricRef.current) {
|
|
57
|
-
return NativeAirMapsModule_1.default.getPointForCoordinate((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, coordinate);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw new Error('getPointForCoordinate is only supported on iOS with Fabric.');
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
async getAddressFromCoordinates(coordinate) {
|
|
64
|
-
if (fabricRef.current) {
|
|
65
|
-
return NativeAirMapsModule_1.default.getAddressFromCoordinates((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, coordinate);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
throw new Error('getAddressFromCoordinates is only supported on iOS with Fabric.');
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
async takeSnapshot(config) {
|
|
72
|
-
if (fabricRef.current) {
|
|
73
|
-
return NativeAirMapsModule_1.default.takeSnapshot((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1, config);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
throw new Error('takeSnapshot is only supported on iOS with Fabric.');
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
async getCamera() {
|
|
80
|
-
if (fabricRef.current) {
|
|
81
|
-
return NativeAirMapsModule_1.default.getCamera((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
throw new Error('getCamera is only supported on iOS with Fabric.');
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
async getMapBoundaries() {
|
|
88
|
-
if (fabricRef.current) {
|
|
89
|
-
return NativeAirMapsModule_1.default.getMapBoundaries((0, react_native_1.findNodeHandle)(fabricRef.current) ?? -1);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
throw new Error('getMapBoundaries is only supported on iOS with Fabric.');
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
animateToRegion(region, duration) {
|
|
96
|
-
if (fabricRef.current) {
|
|
97
|
-
try {
|
|
98
|
-
NativeComponentMapView_1.Commands.animateToRegion(fabricRef.current, JSON.stringify(region), duration);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
throw new Error('Failed to animateToRegion');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
throw new Error('animateToRegion is only supported on iOS with Fabric.');
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
fitToElements(edgePadding, animated) {
|
|
109
|
-
if (fabricRef.current) {
|
|
110
|
-
try {
|
|
111
|
-
NativeComponentMapView_1.Commands.fitToElements(fabricRef.current, JSON.stringify(edgePadding), animated);
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
throw new Error('Failed to fitToElements');
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
throw new Error('fitToElements is only supported on iOS with Fabric.');
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
fitToSuppliedMarkers(markers, edgePadding, animated) {
|
|
122
|
-
if (fabricRef.current) {
|
|
123
|
-
try {
|
|
124
|
-
NativeComponentMapView_1.Commands.fitToSuppliedMarkers(fabricRef.current, JSON.stringify(markers), JSON.stringify(edgePadding), animated);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
throw new Error('Failed to fitToSuppliedMarkers');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
throw new Error('fitToSuppliedMarkers is only supported on iOS with Fabric.');
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
animateCamera(camera, duration) {
|
|
135
|
-
if (fabricRef.current) {
|
|
136
|
-
try {
|
|
137
|
-
NativeComponentMapView_1.Commands.animateCamera(fabricRef.current, JSON.stringify(camera), duration);
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
throw new Error('Failed to animateCamera');
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
throw new Error('animateCamera is only supported on iOS with Fabric.');
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
fitToCoordinates(coordinates, edgePadding, animated) {
|
|
148
|
-
if (fabricRef.current) {
|
|
149
|
-
try {
|
|
150
|
-
NativeComponentMapView_1.Commands.fitToCoordinates(fabricRef.current, JSON.stringify(coordinates), JSON.stringify(edgePadding), animated);
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
throw new Error('Failed to fitToCoordinates');
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
throw new Error('fitToCoordinates is only supported on iOS with Fabric.');
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
setCamera(camera) {
|
|
161
|
-
if (fabricRef.current) {
|
|
162
|
-
try {
|
|
163
|
-
NativeComponentMapView_1.Commands.setCamera(fabricRef.current, JSON.stringify(camera));
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
console.error('Failed to set camera:', error);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
console.warn('setCamera is only supported on iOS with Fabric.');
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
}));
|
|
174
|
-
if (props.provider === 'google') {
|
|
175
|
-
return <NativeComponentGoogleMapView_1.default {...props} ref={fabricRef}/>;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
return <NativeComponentMapView_1.default {...props} ref={fabricRef}/>;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
exports.default = exports.FabricMap;
|