@towsila/expo-ui-library 4.18.0 → 4.18.1
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/package.json +1 -1
- package/src/components/ui/appMap.tsx +9 -12
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import { useAppTheme } from "../../context/ThemeContext";
|
|
|
6
6
|
import CustomMarker from "./customMarker";
|
|
7
7
|
import PositionMarker from "./positionMarker";
|
|
8
8
|
import MovingMarker from "./movingMarker";
|
|
9
|
+
import { RouteInfo } from "../../types/route";
|
|
9
10
|
|
|
10
11
|
type LngLat = [number, number];
|
|
11
12
|
|
|
@@ -26,11 +27,7 @@ export interface MapRoute {
|
|
|
26
27
|
color?: string;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
type RouteInput =
|
|
30
|
-
| { type: "LineString"; coordinates: LngLat[] } // single route (old callers)
|
|
31
|
-
| MapRoute[] // array of routes (new)
|
|
32
|
-
| null
|
|
33
|
-
| undefined;
|
|
30
|
+
type RouteInput = RouteInfo | RouteInfo[] | null | undefined;
|
|
34
31
|
interface Props {
|
|
35
32
|
mapStyle: any;
|
|
36
33
|
position: LngLat;
|
|
@@ -55,27 +52,27 @@ export default function AppMap({
|
|
|
55
52
|
cameraRef.current?.easeTo({ center: position, duration: 1000 });
|
|
56
53
|
}, [follow, position[0], position[1]]);
|
|
57
54
|
|
|
58
|
-
const routes:
|
|
55
|
+
const routes: RouteInfo[] = Array.isArray(routeGeometry)
|
|
59
56
|
? routeGeometry
|
|
60
57
|
: routeGeometry
|
|
61
|
-
? [
|
|
58
|
+
? [routeGeometry]
|
|
62
59
|
: [];
|
|
63
60
|
return (
|
|
64
61
|
<MLMap style={StyleSheet.absoluteFill} mapStyle={mapStyle} onRegionDidChange={(e: any) => onCenterChange?.(e.nativeEvent.center)}>
|
|
65
62
|
<Camera ref={cameraRef} initialViewState={{ center: position, zoom: 15 }} />
|
|
66
63
|
|
|
67
|
-
{routes.map((r) => (
|
|
64
|
+
{routes.map((r, i) => (
|
|
68
65
|
<GeoJSONSource
|
|
69
|
-
key={
|
|
70
|
-
id={
|
|
66
|
+
key={i}
|
|
67
|
+
id={`route-${i}`}
|
|
71
68
|
data={{ type: "Feature", properties: {}, geometry: r.geometry }}
|
|
72
69
|
>
|
|
73
70
|
<Layer
|
|
74
|
-
id={
|
|
71
|
+
id={`route-line-${i}`}
|
|
75
72
|
type="line"
|
|
76
73
|
layout={{ "line-join": "round", "line-cap": "round" }}
|
|
77
74
|
paint={{
|
|
78
|
-
"line-color":
|
|
75
|
+
"line-color": i === 0 ? colors.primary : colors.text.primary,
|
|
79
76
|
"line-width": 5,
|
|
80
77
|
"line-opacity": 0.85,
|
|
81
78
|
}}
|