react-native-maps 1.21.0-alpha.20 → 1.21.0-alpha.22
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/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +50 -0
- package/ios/AirMaps/RNMapsMapView.mm +0 -1
- package/lib/MapMarker.d.ts +2 -0
- package/lib/MapMarker.js +44 -7
- package/lib/specs/NativeComponentMarker.d.ts +1 -0
- package/lib/specs/NativeComponentMarker.js +1 -0
- package/package.json +1 -1
|
@@ -30,6 +30,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
30
30
|
BOOL _calloutIsOpen;
|
|
31
31
|
NSInteger _zIndexBeforeOpen;
|
|
32
32
|
BOOL _useLegacyPinView;
|
|
33
|
+
|
|
34
|
+
CADisplayLink *_displayLink;
|
|
35
|
+
CLLocationCoordinate2D _startCoordinate;
|
|
36
|
+
CLLocationCoordinate2D _endCoordinate;
|
|
37
|
+
NSTimeInterval _animationStartTime;
|
|
38
|
+
NSTimeInterval _animationDuration;
|
|
39
|
+
BOOL _isAnimating;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
@@ -404,4 +411,47 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
404
411
|
_useLegacyPinView = value;
|
|
405
412
|
}
|
|
406
413
|
|
|
414
|
+
- (void)animateToCoordinate:(CLLocationCoordinate2D)newCoordinate duration:(NSTimeInterval)duration {
|
|
415
|
+
if (_isAnimating) {
|
|
416
|
+
NSLog(@"Animation already in progress. Rejecting new animation request.");
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Mark as animating
|
|
421
|
+
_isAnimating = YES;
|
|
422
|
+
|
|
423
|
+
// Store animation parameters
|
|
424
|
+
_startCoordinate = self.coordinate;
|
|
425
|
+
_endCoordinate = newCoordinate;
|
|
426
|
+
_animationDuration = duration;
|
|
427
|
+
_animationStartTime = [NSDate timeIntervalSinceReferenceDate];
|
|
428
|
+
|
|
429
|
+
// Start a CADisplayLink
|
|
430
|
+
if (_displayLink) {
|
|
431
|
+
[_displayLink invalidate];
|
|
432
|
+
}
|
|
433
|
+
_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updatePosition)];
|
|
434
|
+
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
- (void)updatePosition {
|
|
438
|
+
NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _animationStartTime;
|
|
439
|
+
CGFloat progress = MIN(elapsed / _animationDuration, 1.0);
|
|
440
|
+
|
|
441
|
+
// Interpolate coordinates
|
|
442
|
+
CLLocationDegrees currentLatitude = _startCoordinate.latitude + progress * (_endCoordinate.latitude - _startCoordinate.latitude);
|
|
443
|
+
CLLocationDegrees currentLongitude = _startCoordinate.longitude + progress * (_endCoordinate.longitude - _startCoordinate.longitude);
|
|
444
|
+
|
|
445
|
+
// Update annotation's coordinate
|
|
446
|
+
CLLocationCoordinate2D currentCoordinate = CLLocationCoordinate2DMake(currentLatitude, currentLongitude);
|
|
447
|
+
[self setValue:[NSValue valueWithMKCoordinate:currentCoordinate] forKey:@"coordinate"];
|
|
448
|
+
|
|
449
|
+
// Stop the animation when complete
|
|
450
|
+
if (progress == 1.0) {
|
|
451
|
+
[_displayLink invalidate];
|
|
452
|
+
_displayLink = nil;
|
|
453
|
+
_isAnimating = NO; // Reset the animation state
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
407
457
|
@end
|
|
@@ -153,7 +153,6 @@ using namespace facebook::react;
|
|
|
153
153
|
};
|
|
154
154
|
_view.onChange = [self](NSDictionary* dictionary) {
|
|
155
155
|
if (_eventEmitter) {
|
|
156
|
-
|
|
157
156
|
NSDictionary* regionDict = dictionary[@"region"];
|
|
158
157
|
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
159
158
|
facebook::react::RNMapsMapViewEventEmitter::OnRegionChange data = {
|
package/lib/MapMarker.d.ts
CHANGED
|
@@ -295,8 +295,10 @@ export declare class MapMarker extends React.Component<MapMarkerProps> {
|
|
|
295
295
|
getUIManagerCommand: (name: string) => UIManagerCommand;
|
|
296
296
|
static Animated: Animated.AnimatedComponent<typeof MapMarker>;
|
|
297
297
|
private marker;
|
|
298
|
+
private fabricMarker;
|
|
298
299
|
constructor(props: MapMarkerProps);
|
|
299
300
|
setNativeProps(props: Partial<NativeProps>): void;
|
|
301
|
+
componentDidMount(): void;
|
|
300
302
|
showCallout(): void;
|
|
301
303
|
hideCallout(): void;
|
|
302
304
|
setCoordinates(coordinate: LatLng): void;
|
package/lib/MapMarker.js
CHANGED
|
@@ -28,6 +28,7 @@ const React = __importStar(require("react"));
|
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
29
|
const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
|
|
30
30
|
const MapMarkerNativeComponent_1 = require("./MapMarkerNativeComponent");
|
|
31
|
+
const NativeComponentMarker_1 = require("./specs/NativeComponentMarker");
|
|
31
32
|
const ProviderConstants_1 = require("./ProviderConstants");
|
|
32
33
|
class MapMarker extends React.Component {
|
|
33
34
|
getNativeComponent;
|
|
@@ -35,6 +36,7 @@ class MapMarker extends React.Component {
|
|
|
35
36
|
getUIManagerCommand;
|
|
36
37
|
static Animated;
|
|
37
38
|
marker;
|
|
39
|
+
fabricMarker = false;
|
|
38
40
|
constructor(props) {
|
|
39
41
|
super(props);
|
|
40
42
|
this.marker = React.createRef();
|
|
@@ -48,29 +50,65 @@ class MapMarker extends React.Component {
|
|
|
48
50
|
// @ts-ignore
|
|
49
51
|
this.marker.current?.setNativeProps(props);
|
|
50
52
|
}
|
|
53
|
+
componentDidMount() {
|
|
54
|
+
const provider = this.context;
|
|
55
|
+
this.fabricMarker = provider !== ProviderConstants_1.PROVIDER_GOOGLE && react_native_1.Platform.OS === 'ios';
|
|
56
|
+
}
|
|
51
57
|
showCallout() {
|
|
52
58
|
if (this.marker.current) {
|
|
53
|
-
|
|
59
|
+
if (this.fabricMarker) {
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
NativeComponentMarker_1.Commands.showCallout(this.marker.current);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
MapMarkerNativeComponent_1.Commands.showCallout(this.marker.current);
|
|
65
|
+
}
|
|
54
66
|
}
|
|
55
67
|
}
|
|
56
68
|
hideCallout() {
|
|
57
69
|
if (this.marker.current) {
|
|
58
|
-
|
|
70
|
+
if (this.fabricMarker) {
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
NativeComponentMarker_1.Commands.hideCallout(this.marker.current);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
MapMarkerNativeComponent_1.Commands.hideCallout(this.marker.current);
|
|
76
|
+
}
|
|
59
77
|
}
|
|
60
78
|
}
|
|
61
79
|
setCoordinates(coordinate) {
|
|
62
80
|
if (this.marker.current) {
|
|
63
|
-
|
|
81
|
+
if (this.fabricMarker) {
|
|
82
|
+
NativeComponentMarker_1.Commands.setCoordinates(
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
this.marker.current, coordinate.latitude, coordinate.longitude);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
MapMarkerNativeComponent_1.Commands.setCoordinates(this.marker.current, coordinate);
|
|
88
|
+
}
|
|
64
89
|
}
|
|
65
90
|
}
|
|
66
91
|
redrawCallout() {
|
|
67
92
|
if (this.marker.current) {
|
|
68
|
-
|
|
93
|
+
if (this.fabricMarker) {
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
NativeComponentMarker_1.Commands.redrawCallout(this.marker.current);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
MapMarkerNativeComponent_1.Commands.redrawCallout(this.marker.current);
|
|
99
|
+
}
|
|
69
100
|
}
|
|
70
101
|
}
|
|
71
102
|
animateMarkerToCoordinate(coordinate, duration = 500) {
|
|
72
103
|
if (this.marker.current) {
|
|
73
|
-
|
|
104
|
+
if (this.fabricMarker) {
|
|
105
|
+
NativeComponentMarker_1.Commands.animateToCoordinates(
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
this.marker.current, coordinate.latitude, coordinate.longitude, duration);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
MapMarkerNativeComponent_1.Commands.animateMarkerToCoordinate(this.marker.current, coordinate, duration);
|
|
111
|
+
}
|
|
74
112
|
}
|
|
75
113
|
}
|
|
76
114
|
redraw() {
|
|
@@ -86,10 +124,9 @@ class MapMarker extends React.Component {
|
|
|
86
124
|
icon = icon.uri;
|
|
87
125
|
}
|
|
88
126
|
const AIRMapMarker = this.getNativeComponent();
|
|
89
|
-
const provider = this.context;
|
|
90
127
|
let image;
|
|
91
128
|
if (this.props.image) {
|
|
92
|
-
if (
|
|
129
|
+
if (this.fabricMarker) {
|
|
93
130
|
image = this.props.image;
|
|
94
131
|
}
|
|
95
132
|
else {
|
|
@@ -235,6 +235,7 @@ export interface MarkerFabricNativeProps extends ViewProps {
|
|
|
235
235
|
}
|
|
236
236
|
export interface NativeCommands {
|
|
237
237
|
animateToCoordinates: (viewRef: React.ElementRef<React.ComponentType>, latitude: Double, longitude: Double, duration: Int32) => void;
|
|
238
|
+
setCoordinates: (viewRef: React.ElementRef<React.ComponentType>, latitude: Double, longitude: Double) => void;
|
|
238
239
|
showCallout: (viewRef: React.ElementRef<React.ComponentType>) => void;
|
|
239
240
|
hideCallout: (viewRef: React.ElementRef<React.ComponentType>) => void;
|
|
240
241
|
redrawCallout: (viewRef: React.ElementRef<React.ComponentType>) => void;
|
|
@@ -8,6 +8,7 @@ const codegenNativeComponent_1 = __importDefault(require("react-native/Libraries
|
|
|
8
8
|
const codegenNativeCommands_1 = __importDefault(require("react-native/Libraries/Utilities/codegenNativeCommands"));
|
|
9
9
|
exports.Commands = (0, codegenNativeCommands_1.default)({
|
|
10
10
|
supportedCommands: [
|
|
11
|
+
'setCoordinates',
|
|
11
12
|
'animateToCoordinates',
|
|
12
13
|
'showCallout',
|
|
13
14
|
'hideCallout',
|
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.22",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|