@lugg/maps 0.2.0-alpha.17 → 0.2.0-alpha.19
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/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +16 -17
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +1 -0
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +129 -13
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +15 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +8 -0
- package/ios/LuggAppleMapView.mm +58 -25
- package/ios/LuggGoogleMapView.mm +43 -20
- package/ios/LuggMarkerView.h +7 -0
- package/ios/LuggMarkerView.mm +66 -0
- package/ios/core/GMSPolylineAnimator.h +2 -0
- package/ios/core/GMSPolylineAnimator.m +8 -0
- package/ios/core/MKPolylineAnimator.h +2 -0
- package/ios/core/MKPolylineAnimator.m +8 -0
- package/lib/module/MapProvider.web.js +5 -2
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.web.js +14 -11
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Marker.js +6 -0
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +8 -0
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polyline.web.js +15 -4
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +7 -1
- package/lib/typescript/src/MapProvider.web.d.ts +8 -2
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.d.ts +17 -0
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +4 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapProvider.web.tsx +5 -2
- package/src/MapView.web.tsx +11 -11
- package/src/components/Marker.tsx +32 -2
- package/src/components/Marker.web.tsx +9 -0
- package/src/components/Polyline.web.tsx +13 -4
- package/src/fabric/LuggMarkerViewNativeComponent.ts +7 -1
|
@@ -29,6 +29,23 @@ export interface MarkerProps {
|
|
|
29
29
|
* Z-index for marker ordering. Higher values render on top.
|
|
30
30
|
*/
|
|
31
31
|
zIndex?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Rotation angle in degrees clockwise from north.
|
|
34
|
+
* @default 0
|
|
35
|
+
*/
|
|
36
|
+
rotate?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Scale factor for the marker.
|
|
39
|
+
* @default 1
|
|
40
|
+
*/
|
|
41
|
+
scale?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Rasterize custom marker view to bitmap for better performance.
|
|
44
|
+
* Set to false if you need live view updates (e.g., animations).
|
|
45
|
+
* @platform ios, android
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
rasterize?: boolean;
|
|
32
49
|
/**
|
|
33
50
|
* Custom marker view
|
|
34
51
|
*/
|
|
@@ -37,8 +54,18 @@ export interface MarkerProps {
|
|
|
37
54
|
|
|
38
55
|
export class Marker extends React.Component<MarkerProps> {
|
|
39
56
|
render() {
|
|
40
|
-
const {
|
|
41
|
-
|
|
57
|
+
const {
|
|
58
|
+
name,
|
|
59
|
+
coordinate,
|
|
60
|
+
title,
|
|
61
|
+
description,
|
|
62
|
+
anchor,
|
|
63
|
+
zIndex,
|
|
64
|
+
rotate = 0,
|
|
65
|
+
scale = 1,
|
|
66
|
+
rasterize = true,
|
|
67
|
+
children,
|
|
68
|
+
} = this.props;
|
|
42
69
|
|
|
43
70
|
return (
|
|
44
71
|
<LuggMarkerViewNativeComponent
|
|
@@ -48,6 +75,9 @@ export class Marker extends React.Component<MarkerProps> {
|
|
|
48
75
|
title={title}
|
|
49
76
|
description={description}
|
|
50
77
|
anchor={anchor}
|
|
78
|
+
rotate={rotate}
|
|
79
|
+
scale={scale}
|
|
80
|
+
rasterize={rasterize}
|
|
51
81
|
>
|
|
52
82
|
{children}
|
|
53
83
|
</LuggMarkerViewNativeComponent>
|
|
@@ -8,8 +8,14 @@ export function Marker({
|
|
|
8
8
|
title,
|
|
9
9
|
anchor,
|
|
10
10
|
zIndex,
|
|
11
|
+
rotate,
|
|
12
|
+
scale,
|
|
11
13
|
children,
|
|
12
14
|
}: MarkerProps) {
|
|
15
|
+
const transforms: string[] = [];
|
|
16
|
+
if (rotate) transforms.push(`rotate(${rotate}deg)`);
|
|
17
|
+
if (scale && scale !== 1) transforms.push(`scale(${scale})`);
|
|
18
|
+
|
|
13
19
|
return (
|
|
14
20
|
<AdvancedMarker
|
|
15
21
|
position={{ lat: coordinate.latitude, lng: coordinate.longitude }}
|
|
@@ -17,6 +23,9 @@ export function Marker({
|
|
|
17
23
|
zIndex={zIndex}
|
|
18
24
|
anchorLeft={anchor ? toWebAnchor(anchor.x) : undefined}
|
|
19
25
|
anchorTop={anchor ? toWebAnchor(anchor.y) : undefined}
|
|
26
|
+
style={
|
|
27
|
+
transforms.length > 0 ? { transform: transforms.join(' ') } : undefined
|
|
28
|
+
}
|
|
20
29
|
>
|
|
21
30
|
{children}
|
|
22
31
|
</AdvancedMarker>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { useMapId } from '../MapProvider.web';
|
|
2
|
+
import { useMapContext } from '../MapProvider.web';
|
|
4
3
|
import type { PolylineProps } from './Polyline';
|
|
5
4
|
|
|
6
5
|
const ANIMATION_DURATION = 1500;
|
|
@@ -43,10 +42,10 @@ export function Polyline({
|
|
|
43
42
|
zIndex,
|
|
44
43
|
}: PolylineProps) {
|
|
45
44
|
const resolvedZIndex = zIndex ?? (animated ? 1 : 0);
|
|
46
|
-
const
|
|
47
|
-
const map = useMap(mapId);
|
|
45
|
+
const { map, isDragging } = useMapContext();
|
|
48
46
|
const polylinesRef = useRef<google.maps.Polyline[]>([]);
|
|
49
47
|
const animationRef = useRef<number>(0);
|
|
48
|
+
const isPausedRef = useRef(false);
|
|
50
49
|
|
|
51
50
|
const colors = useMemo(
|
|
52
51
|
() =>
|
|
@@ -133,6 +132,11 @@ export function Polyline({
|
|
|
133
132
|
};
|
|
134
133
|
}, []);
|
|
135
134
|
|
|
135
|
+
// Pause/resume animation during drag
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
isPausedRef.current = isDragging;
|
|
138
|
+
}, [isDragging]);
|
|
139
|
+
|
|
136
140
|
// Main effect
|
|
137
141
|
useEffect(() => {
|
|
138
142
|
if (!propsRef.current.map || coordinates.length === 0) return;
|
|
@@ -153,6 +157,11 @@ export function Polyline({
|
|
|
153
157
|
const cycleDuration = ANIMATION_DURATION * 2;
|
|
154
158
|
|
|
155
159
|
const animate = (time: number) => {
|
|
160
|
+
if (isPausedRef.current) {
|
|
161
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
156
165
|
const progress = (time % cycleDuration) / ANIMATION_DURATION;
|
|
157
166
|
const startIdx = progress <= 1 ? 0 : (progress - 1) * totalPoints;
|
|
158
167
|
const endIdx = progress <= 1 ? progress * totalPoints : totalPoints;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { codegenNativeComponent } from 'react-native';
|
|
2
2
|
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
WithDefault,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
7
|
|
|
5
8
|
export interface Coordinate {
|
|
6
9
|
latitude: Double;
|
|
@@ -18,6 +21,9 @@ export interface NativeProps extends ViewProps {
|
|
|
18
21
|
title?: string;
|
|
19
22
|
description?: string;
|
|
20
23
|
anchor?: Point;
|
|
24
|
+
rotate?: WithDefault<Double, 0>;
|
|
25
|
+
scale?: WithDefault<Double, 1>;
|
|
26
|
+
rasterize?: WithDefault<boolean, true>;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export default codegenNativeComponent<NativeProps>(
|