@heycar/heycars-map 2.7.2 → 2.8.0
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/dist/v2/api/gaodeDirectionDriving.js +21 -6
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +6 -4
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +22 -13
- package/dist/v2/business-components/DrivingLine/DrivingLine.d.ts +5 -1
- package/dist/v2/business-components/DrivingLine/DrivingLine.js +44 -10
- package/dist/v2/business-components/DrivingRoute/DrivingRoute.d.ts +2 -1
- package/dist/v2/business-components/DrivingRoute/DrivingRoute.js +4 -2
- package/dist/v2/business-components/TrafficDrivingLine/TrafficDrivingLine.d.ts +6 -0
- package/dist/v2/business-components/TrafficDrivingLine/TrafficDrivingLine.js +93 -0
- package/dist/v2/business-components/TrafficDrivingLine/index.d.ts +1 -0
- package/dist/v2/business-components/TrafficDrivingLine/index.js +4 -0
- package/dist/v2/components/AmapMarker/AmapMarker.js +0 -2
- package/dist/v2/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
- package/dist/v2/hooks/useDrivingRoute.d.ts +3 -0
- package/dist/v2/hooks/useDrivingRoute.js +2 -1
- package/dist/v2/hooks/useDrivingTrackCorrection.d.ts +1 -0
- package/dist/v2/types/amap/driving.d.ts +2 -1
- package/dist/v2/types/interface.d.ts +3 -0
- package/dist/v2/utils/compatibleDrivingRoute.js +21 -2
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.d.ts +3 -1
- package/dist/v2/utils/transform.js +19 -1
- package/dist/v3/api/gaodeDirectionDriving.js +21 -6
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +6 -4
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +22 -13
- package/dist/v3/business-components/DrivingLine/DrivingLine.d.ts +5 -1
- package/dist/v3/business-components/DrivingLine/DrivingLine.js +44 -10
- package/dist/v3/business-components/DrivingRoute/DrivingRoute.d.ts +2 -1
- package/dist/v3/business-components/DrivingRoute/DrivingRoute.js +4 -2
- package/dist/v3/business-components/TrafficDrivingLine/TrafficDrivingLine.d.ts +8 -0
- package/dist/v3/business-components/TrafficDrivingLine/TrafficDrivingLine.js +91 -0
- package/dist/v3/business-components/TrafficDrivingLine/index.d.ts +1 -0
- package/dist/v3/business-components/TrafficDrivingLine/index.js +4 -0
- package/dist/v3/components/AmapMarker/AmapMarker.js +0 -2
- package/dist/v3/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
- package/dist/v3/hooks/useDrivingRoute.d.ts +3 -0
- package/dist/v3/hooks/useDrivingRoute.js +2 -1
- package/dist/v3/hooks/useDrivingTrackCorrection.d.ts +1 -0
- package/dist/v3/types/amap/driving.d.ts +2 -1
- package/dist/v3/types/interface.d.ts +3 -0
- package/dist/v3/utils/compatibleDrivingRoute.js +21 -2
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.d.ts +3 -1
- package/dist/v3/utils/transform.js +19 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gaodePointsStringify, gaodePolyline2amapLngLat } from "../utils/transform.js";
|
|
2
2
|
import { createTypeError, isProxyServiceError } from "../utils/typeChecking.js";
|
|
3
|
-
const GAODE_POLYLINE_REGEX = /^(
|
|
3
|
+
const GAODE_POLYLINE_REGEX = /^(?:-?\d*\.\d+,-?\d*\.\d+)?(?:;-?\d*\.\d+,-?\d*\.\d+)*$/;
|
|
4
4
|
var GaodeDirectionStatus = /* @__PURE__ */ ((GaodeDirectionStatus2) => {
|
|
5
5
|
GaodeDirectionStatus2["SUCCESS"] = "1";
|
|
6
6
|
GaodeDirectionStatus2["FAIL"] = "0";
|
|
@@ -35,10 +35,19 @@ function isGaodeDirectionBasicStep(value) {
|
|
|
35
35
|
function isGaodeEmptyValue(value) {
|
|
36
36
|
return Array.isArray(value) && value.length === 0;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
38
|
+
function isAmapTmcStatus(value) {
|
|
39
|
+
return value === "未知" || value === "畅通" || value === "缓行" || value === "拥堵" || value === "严重拥堵";
|
|
40
|
+
}
|
|
41
|
+
function assertGaodeDirectionDrivingTmc(value) {
|
|
42
|
+
if (typeof value === "object" && value !== null && "status" in value && isAmapTmcStatus(value.status) && "polyline" in value && isGaodeDirectionPolyline(value.polyline))
|
|
40
43
|
return;
|
|
41
|
-
throw createTypeError("
|
|
44
|
+
throw createTypeError("GaodeDirectionDrivingTmc", value);
|
|
45
|
+
}
|
|
46
|
+
function assertGaodoDirectionDrivingStep(value) {
|
|
47
|
+
if (!isGaodeDirectionBasicStep(value) || !("tmcs" in value) || !Array.isArray(value.tmcs)) {
|
|
48
|
+
throw createTypeError("GaodeDirectionDrivingStep", value);
|
|
49
|
+
}
|
|
50
|
+
value.tmcs.forEach(assertGaodeDirectionDrivingTmc);
|
|
42
51
|
}
|
|
43
52
|
function assertGaodeDirectionDrivingRoutePath(value) {
|
|
44
53
|
if (!isGaodeMeasurableObject(value) || !("tolls" in value) || !isGaodeNumberableString(value.tolls) || !("steps" in value) || !Array.isArray(value.steps)) {
|
|
@@ -63,15 +72,21 @@ function assertGaodeDirectionDrivingResponse(value) {
|
|
|
63
72
|
throw createTypeError("GaodeDirectionDrivingResponse", value, detail);
|
|
64
73
|
}
|
|
65
74
|
}
|
|
75
|
+
function gaodeDirectionDrivingTmc2amapTmc(gaodeTmc) {
|
|
76
|
+
const { status, polyline } = gaodeTmc;
|
|
77
|
+
const path = gaodePolyline2amapLngLat(String(polyline));
|
|
78
|
+
return { status, path };
|
|
79
|
+
}
|
|
66
80
|
function gaodeDirectionDrivingRoute2amapDrivingRoute(gaodeRoute) {
|
|
67
81
|
return gaodeRoute.paths.map((routePath) => {
|
|
68
82
|
const { distance, duration, tolls, steps: godeDirectionSteps } = routePath;
|
|
69
83
|
const steps = godeDirectionSteps.map((directionStep) => {
|
|
70
|
-
const { distance: distance2, duration: duration2, polyline } = directionStep;
|
|
84
|
+
const { distance: distance2, duration: duration2, polyline, tmcs } = directionStep;
|
|
71
85
|
return {
|
|
72
86
|
distance: Number(distance2),
|
|
73
87
|
time: Number(duration2),
|
|
74
|
-
path: gaodePolyline2amapLngLat(String(polyline))
|
|
88
|
+
path: gaodePolyline2amapLngLat(String(polyline)),
|
|
89
|
+
tmcs: tmcs.map(gaodeDirectionDrivingTmc2amapTmc)
|
|
75
90
|
};
|
|
76
91
|
});
|
|
77
92
|
return {
|
|
@@ -9,10 +9,10 @@ import { defineSetup, defineLagecySetup } from "../../types/helper.js";
|
|
|
9
9
|
import { generateCreateElementV2PropsOn } from "../../utils/compare.js";
|
|
10
10
|
import { place2point, pipeDefer } from "../../utils/transform.js";
|
|
11
11
|
import { toCoordinatePlaceType } from "../../utils/typeChecking.js";
|
|
12
|
-
import { DrivingLine } from "../DrivingLine/DrivingLine.js";
|
|
13
12
|
import { DrivingRoute } from "../DrivingRoute/DrivingRoute.js";
|
|
14
13
|
import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
|
|
15
14
|
import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
|
|
15
|
+
import { TrafficDrivingLine } from "../TrafficDrivingLine/TrafficDrivingLine.js";
|
|
16
16
|
const BUSINESS_QUOTING_FITVIEW_PANDING = [26, 26, 19, 26];
|
|
17
17
|
const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(props, {
|
|
18
18
|
emit,
|
|
@@ -91,10 +91,12 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
|
|
|
91
91
|
path,
|
|
92
92
|
distance,
|
|
93
93
|
duration,
|
|
94
|
-
tolls
|
|
95
|
-
|
|
94
|
+
tolls,
|
|
95
|
+
trafficJams
|
|
96
|
+
}) => [h(TrafficDrivingLine, {
|
|
96
97
|
"attrs": {
|
|
97
|
-
"path": path
|
|
98
|
+
"path": path,
|
|
99
|
+
"trafficJams": trafficJams
|
|
98
100
|
}
|
|
99
101
|
}), h(StartEndPoint, {
|
|
100
102
|
"attrs": {
|
|
@@ -14,6 +14,7 @@ import { ConditionalFittablePassengerCircle } from "../PassengerCircle/Passenger
|
|
|
14
14
|
import { PlaceCircle } from "../PlaceCircle/PlaceCircle.js";
|
|
15
15
|
import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
|
|
16
16
|
import { TaxiCar } from "../TaxiCar/TaxiCar.js";
|
|
17
|
+
import { TrafficDrivingLine } from "../TrafficDrivingLine/TrafficDrivingLine.js";
|
|
17
18
|
import { WalkingLine } from "../WalkingLine/WalkingLine.js";
|
|
18
19
|
import { WalkingRoute } from "../WalkingRoute/WalkingRoute.js";
|
|
19
20
|
import { WaveCircle } from "../WaveCircle/WaveCircle.js";
|
|
@@ -88,10 +89,12 @@ const SectionConfirmed = defineSetup("SectionConfirmed", function(props) {
|
|
|
88
89
|
"to": to,
|
|
89
90
|
"from": from,
|
|
90
91
|
"render": ({
|
|
91
|
-
path
|
|
92
|
-
|
|
92
|
+
path,
|
|
93
|
+
trafficJams
|
|
94
|
+
}) => h(TrafficDrivingLine, {
|
|
93
95
|
"attrs": {
|
|
94
|
-
"path": path
|
|
96
|
+
"path": path,
|
|
97
|
+
"trafficJams": trafficJams
|
|
95
98
|
}
|
|
96
99
|
})
|
|
97
100
|
}
|
|
@@ -197,12 +200,14 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
|
|
|
197
200
|
path,
|
|
198
201
|
angle,
|
|
199
202
|
distance,
|
|
200
|
-
duration
|
|
203
|
+
duration,
|
|
204
|
+
trafficJams
|
|
201
205
|
}) => {
|
|
202
206
|
var _a;
|
|
203
|
-
return [h(
|
|
207
|
+
return [h(TrafficDrivingLine, {
|
|
204
208
|
"attrs": {
|
|
205
|
-
"path": path
|
|
209
|
+
"path": path,
|
|
210
|
+
"trafficJams": trafficJams
|
|
206
211
|
}
|
|
207
212
|
}), h(TaxiCar, {
|
|
208
213
|
"attrs": {
|
|
@@ -286,10 +291,12 @@ const SectionBookDispatched = defineSetup("SectionBookDispatched", function(prop
|
|
|
286
291
|
"to": to,
|
|
287
292
|
"from": from,
|
|
288
293
|
"render": ({
|
|
289
|
-
path
|
|
290
|
-
|
|
294
|
+
path,
|
|
295
|
+
trafficJams
|
|
296
|
+
}) => h(TrafficDrivingLine, {
|
|
291
297
|
"attrs": {
|
|
292
|
-
"path": path
|
|
298
|
+
"path": path,
|
|
299
|
+
"trafficJams": trafficJams
|
|
293
300
|
}
|
|
294
301
|
})
|
|
295
302
|
}
|
|
@@ -461,12 +468,14 @@ const SectionInService = defineSetup("SectionInService", function(props) {
|
|
|
461
468
|
path,
|
|
462
469
|
angle,
|
|
463
470
|
distance,
|
|
464
|
-
duration
|
|
471
|
+
duration,
|
|
472
|
+
trafficJams
|
|
465
473
|
}) => {
|
|
466
474
|
var _a;
|
|
467
|
-
return [h(
|
|
475
|
+
return [h(TrafficDrivingLine, {
|
|
468
476
|
"attrs": {
|
|
469
|
-
"path": path
|
|
477
|
+
"path": path,
|
|
478
|
+
"trafficJams": trafficJams
|
|
470
479
|
}
|
|
471
480
|
}), h(TaxiCar, {
|
|
472
481
|
"attrs": {
|
|
@@ -601,7 +610,7 @@ const SectionEndService = defineSetup("SectionEndService", function(props) {
|
|
|
601
610
|
}) => h(DrivingLine, {
|
|
602
611
|
"attrs": {
|
|
603
612
|
"path": path,
|
|
604
|
-
"
|
|
613
|
+
"status": "DONE"
|
|
605
614
|
}
|
|
606
615
|
})
|
|
607
616
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { TrafficStatus } from "../../types/interface";
|
|
2
|
+
type DrivingLineStatus = TrafficStatus | "DONE";
|
|
1
3
|
export interface DrivingLineProps {
|
|
2
|
-
|
|
4
|
+
status?: DrivingLineStatus;
|
|
3
5
|
path: [number, number][];
|
|
6
|
+
lineCap?: AMap.LineSharedOptions["lineCap"];
|
|
4
7
|
}
|
|
5
8
|
export declare const ADrivingLine: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<DrivingLineProps, Required<DrivingLineProps>>, never, DrivingLineProps>;
|
|
6
9
|
export declare const GDrivingLine: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<DrivingLineProps, Required<DrivingLineProps>>, never, DrivingLineProps>;
|
|
7
10
|
export declare const DrivingLine: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<DrivingLineProps, Required<DrivingLineProps>>, never, DrivingLineProps>;
|
|
11
|
+
export {};
|
|
@@ -7,17 +7,48 @@ import { createElement } from "../../demi-polyfill/demi-polyfill.js";
|
|
|
7
7
|
import { useMapSupplier } from "../../hooks/useMapSupplier.js";
|
|
8
8
|
import { defineSetup } from "../../types/helper.js";
|
|
9
9
|
import { vec2lnglat } from "../../utils/transform.js";
|
|
10
|
+
const trafficInnerColors = {
|
|
11
|
+
// UNKNOWN: "#487BF4",
|
|
12
|
+
UNKNOWN: "#00C875",
|
|
13
|
+
NORMAL: "#00C875",
|
|
14
|
+
SLOW: "#F9D100",
|
|
15
|
+
TRAFFIC_JAM: "#EB0E33",
|
|
16
|
+
HEAVY_TRAFFIC_JAM: "#99001A",
|
|
17
|
+
DONE: "#96B2CA"
|
|
18
|
+
};
|
|
19
|
+
const trafficOuterColors = {
|
|
20
|
+
// UNKNOWN: "#4175F1",
|
|
21
|
+
UNKNOWN: "#008559",
|
|
22
|
+
NORMAL: "#008559",
|
|
23
|
+
SLOW: "#B29400",
|
|
24
|
+
TRAFFIC_JAM: "#990D24",
|
|
25
|
+
HEAVY_TRAFFIC_JAM: "#4D000D",
|
|
26
|
+
DONE: "#7693AF"
|
|
27
|
+
};
|
|
28
|
+
const trafficBorderColors = {
|
|
29
|
+
// UNKNOWN: "#6C95F5",
|
|
30
|
+
UNKNOWN: "#00C875",
|
|
31
|
+
NORMAL: "#00C875",
|
|
32
|
+
SLOW: "#F9D100",
|
|
33
|
+
TRAFFIC_JAM: "#EB0E33",
|
|
34
|
+
HEAVY_TRAFFIC_JAM: "#99001A",
|
|
35
|
+
DONE: "#7693AF"
|
|
36
|
+
};
|
|
10
37
|
const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
11
38
|
return () => {
|
|
39
|
+
const {
|
|
40
|
+
status = "UNKNOWN",
|
|
41
|
+
lineCap = "round"
|
|
42
|
+
} = props;
|
|
12
43
|
const vw = window.innerWidth * 0.01;
|
|
13
44
|
const strokeWidth = 1 * vw;
|
|
14
45
|
const borderWidth = 0.13 * vw;
|
|
15
46
|
const dirWidth = 0.24 * vw;
|
|
16
47
|
const outlineWidth = 0.4 * vw;
|
|
17
48
|
const dashLength = 0.3 * vw;
|
|
18
|
-
const strokeColorInner =
|
|
19
|
-
const strokeColorOuter =
|
|
20
|
-
const strokeColorBorder =
|
|
49
|
+
const strokeColorInner = trafficInnerColors[status];
|
|
50
|
+
const strokeColorOuter = trafficOuterColors[status];
|
|
51
|
+
const strokeColorBorder = trafficBorderColors[status];
|
|
21
52
|
return h("div", [h(AmapPolyline, {
|
|
22
53
|
"attrs": {
|
|
23
54
|
"path": props.path,
|
|
@@ -25,7 +56,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
25
56
|
"strokeOpacity": 1,
|
|
26
57
|
"strokeColor": strokeColorOuter,
|
|
27
58
|
"lineJoin": "round",
|
|
28
|
-
"lineCap":
|
|
59
|
+
"lineCap": lineCap,
|
|
29
60
|
"zIndex": ZINDEX_LINE_LAYER
|
|
30
61
|
}
|
|
31
62
|
}), h(AmapPolyline, {
|
|
@@ -35,7 +66,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
35
66
|
"strokeOpacity": 1,
|
|
36
67
|
"strokeColor": strokeColorBorder,
|
|
37
68
|
"lineJoin": "round",
|
|
38
|
-
"lineCap":
|
|
69
|
+
"lineCap": lineCap,
|
|
39
70
|
"strokeStyle": "dashed",
|
|
40
71
|
"strokeDasharray": [dashLength, dashLength * 0.5],
|
|
41
72
|
"zIndex": ZINDEX_LINE_LAYER
|
|
@@ -47,7 +78,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
47
78
|
"strokeOpacity": 1,
|
|
48
79
|
"strokeColor": strokeColorInner,
|
|
49
80
|
"lineJoin": "round",
|
|
50
|
-
"lineCap":
|
|
81
|
+
"lineCap": lineCap,
|
|
51
82
|
"zIndex": ZINDEX_LINE_LAYER
|
|
52
83
|
}
|
|
53
84
|
}), h(AmapPolyline, {
|
|
@@ -58,7 +89,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
58
89
|
"strokeOpacity": 1,
|
|
59
90
|
"strokeColor": "transparent",
|
|
60
91
|
"lineJoin": "round",
|
|
61
|
-
"lineCap":
|
|
92
|
+
"lineCap": lineCap,
|
|
62
93
|
"zIndex": ZINDEX_LINE_LAYER
|
|
63
94
|
}
|
|
64
95
|
})]);
|
|
@@ -67,15 +98,18 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
67
98
|
const GDrivingLine = defineSetup("GDrivingLine", function(props) {
|
|
68
99
|
const pathRef = computed(() => props.path.map(vec2lnglat));
|
|
69
100
|
return () => {
|
|
101
|
+
const {
|
|
102
|
+
status = "UNKNOWN"
|
|
103
|
+
} = props;
|
|
70
104
|
const vw = window.innerWidth * 0.01;
|
|
71
105
|
const repeat = 10 * vw;
|
|
72
106
|
const strokeWidth = 1.25 * vw * 0.65;
|
|
73
107
|
const borderWidth = 0.175 * vw * 0.65;
|
|
74
108
|
const dirStrokeWeight = 0.375 * vw * 0.65;
|
|
75
109
|
const outlineWidth = 0.45 * vw * 0.65;
|
|
76
|
-
const strokeColorInner =
|
|
77
|
-
const strokeColorOuter =
|
|
78
|
-
const strokeColorBorder =
|
|
110
|
+
const strokeColorInner = trafficInnerColors[status];
|
|
111
|
+
const strokeColorOuter = trafficOuterColors[status];
|
|
112
|
+
const strokeColorBorder = trafficBorderColors[status];
|
|
79
113
|
return h("div", [h(GmapPolyline, {
|
|
80
114
|
"attrs": {
|
|
81
115
|
"path": pathRef.value,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type VNodeChild } from "../../demi-polyfill";
|
|
2
2
|
import { type UseDrivingRouteProps } from "../../hooks/useDrivingRoute";
|
|
3
|
-
import type { Point } from "../../types/interface";
|
|
3
|
+
import type { Point, TrafficJams } from "../../types/interface";
|
|
4
4
|
export type DrivingRouteRenderProps = {
|
|
5
5
|
path: Point[];
|
|
6
6
|
angle?: number;
|
|
7
7
|
distance: number;
|
|
8
8
|
duration: number;
|
|
9
9
|
tolls?: number;
|
|
10
|
+
trafficJams?: TrafficJams;
|
|
10
11
|
};
|
|
11
12
|
export interface DrivingRouteProps extends UseDrivingRouteProps {
|
|
12
13
|
render?: (props: DrivingRouteRenderProps) => VNodeChild;
|
|
@@ -14,7 +14,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
|
|
|
14
14
|
path,
|
|
15
15
|
distance,
|
|
16
16
|
duration,
|
|
17
|
-
tolls
|
|
17
|
+
tolls,
|
|
18
|
+
trafficJams
|
|
18
19
|
} = toRefs(useADrivingRoute(props).route);
|
|
19
20
|
const {
|
|
20
21
|
angleRef
|
|
@@ -29,7 +30,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
|
|
|
29
30
|
angle: angleRef,
|
|
30
31
|
distance,
|
|
31
32
|
duration,
|
|
32
|
-
tolls
|
|
33
|
+
tolls,
|
|
34
|
+
trafficJams
|
|
33
35
|
}))]);
|
|
34
36
|
};
|
|
35
37
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Point, TrafficJams } from "../../types/interface";
|
|
2
|
+
export interface TrafficDrivingLineProps {
|
|
3
|
+
path: Point[];
|
|
4
|
+
trafficJams?: TrafficJams;
|
|
5
|
+
}
|
|
6
|
+
export declare const TrafficDrivingLine: import("vue").DefineComponent<import("vue3").ComponentObjectPropsOptions<TrafficDrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<TrafficDrivingLineProps, Required<TrafficDrivingLineProps>>, never, TrafficDrivingLineProps>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
import { defineSetup } from "../../types/helper.js";
|
|
3
|
+
import { stringifyPoint } from "../../utils/transform.js";
|
|
4
|
+
import { DrivingLine } from "../DrivingLine/DrivingLine.js";
|
|
5
|
+
const justifyFirstPointStatus = (firstPointStatus, secondPointStatus) => {
|
|
6
|
+
return (firstPointStatus === void 0 || firstPointStatus === "UNKNOWN") && !!secondPointStatus && secondPointStatus !== "UNKNOWN" ? secondPointStatus : firstPointStatus != null ? firstPointStatus : "UNKNOWN";
|
|
7
|
+
};
|
|
8
|
+
const createMulitpleLineByTrafficJams = (path, trafficJams) => {
|
|
9
|
+
var _a;
|
|
10
|
+
if (!trafficJams)
|
|
11
|
+
return [{
|
|
12
|
+
path,
|
|
13
|
+
status: "UNKNOWN"
|
|
14
|
+
}];
|
|
15
|
+
const firstPoint = path[0];
|
|
16
|
+
if (!firstPoint)
|
|
17
|
+
return [];
|
|
18
|
+
const multipleLines = [];
|
|
19
|
+
let line = {
|
|
20
|
+
path: [firstPoint],
|
|
21
|
+
status: justifyFirstPointStatus(trafficJams[stringifyPoint(firstPoint)], trafficJams[stringifyPoint(path[1])])
|
|
22
|
+
};
|
|
23
|
+
for (let idx = 2; idx < path.length; idx++) {
|
|
24
|
+
const point = path[idx];
|
|
25
|
+
const traffic = (_a = trafficJams[stringifyPoint(point)]) != null ? _a : "UNKNOWN";
|
|
26
|
+
line.path.push(point);
|
|
27
|
+
if (traffic === line.status)
|
|
28
|
+
continue;
|
|
29
|
+
multipleLines.push(line);
|
|
30
|
+
line = {
|
|
31
|
+
path: [point],
|
|
32
|
+
status: traffic
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
multipleLines.push(line);
|
|
36
|
+
return multipleLines;
|
|
37
|
+
};
|
|
38
|
+
const beautifyMultipleLines = (lines) => {
|
|
39
|
+
const max = lines.length - 1;
|
|
40
|
+
if (max === 0)
|
|
41
|
+
return [{
|
|
42
|
+
...lines[0],
|
|
43
|
+
lineCap: "round"
|
|
44
|
+
}];
|
|
45
|
+
const totalPath = lines.flatMap((line) => line.path);
|
|
46
|
+
const totalLine = {
|
|
47
|
+
path: totalPath,
|
|
48
|
+
status: "NORMAL",
|
|
49
|
+
lineCap: "round"
|
|
50
|
+
};
|
|
51
|
+
const coveredLines = [];
|
|
52
|
+
for (const line of lines) {
|
|
53
|
+
const {
|
|
54
|
+
path,
|
|
55
|
+
status
|
|
56
|
+
} = line;
|
|
57
|
+
if (status !== "SLOW" && status !== "TRAFFIC_JAM" && status !== "HEAVY_TRAFFIC_JAM")
|
|
58
|
+
continue;
|
|
59
|
+
coveredLines.push({
|
|
60
|
+
status,
|
|
61
|
+
path,
|
|
62
|
+
lineCap: "butt"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const first = lines[0];
|
|
66
|
+
const ignoredLine = {
|
|
67
|
+
status: first.status,
|
|
68
|
+
path: first.path.slice(0, 2),
|
|
69
|
+
lineCap: "butt"
|
|
70
|
+
};
|
|
71
|
+
return [ignoredLine, totalLine, ...coveredLines];
|
|
72
|
+
};
|
|
73
|
+
const TrafficDrivingLine = defineSetup("TrafficDrivingLine", function(props) {
|
|
74
|
+
return () => {
|
|
75
|
+
const {
|
|
76
|
+
path,
|
|
77
|
+
trafficJams
|
|
78
|
+
} = props;
|
|
79
|
+
const multipleLines = createMulitpleLineByTrafficJams(path, trafficJams);
|
|
80
|
+
console.log("multipleLines = ", multipleLines);
|
|
81
|
+
const beautifiedLines = beautifyMultipleLines(multipleLines);
|
|
82
|
+
return h("div", [beautifiedLines.map((line) => h(DrivingLine, {
|
|
83
|
+
"attrs": {
|
|
84
|
+
"path": line.path,
|
|
85
|
+
"status": line.status,
|
|
86
|
+
"lineCap": line.lineCap
|
|
87
|
+
}
|
|
88
|
+
}))]);
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
export {
|
|
92
|
+
TrafficDrivingLine
|
|
93
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TrafficDrivingLine";
|
|
@@ -5,7 +5,6 @@ import { defineSetup } from "../../types/helper.js";
|
|
|
5
5
|
import { watchNoneImmediatePostEffectForMapProperty, watchPostEffectForAMapEvent } from "../../utils/compare.js";
|
|
6
6
|
import { detectTouchDevice } from "../../utils/platform.js";
|
|
7
7
|
import { referenceCount } from "../../utils/referenceCount.js";
|
|
8
|
-
import { useAmapFixBugOverlayDrag } from "../AmapPolygon/AmapPolygon.js";
|
|
9
8
|
const isTouchDevice = detectTouchDevice();
|
|
10
9
|
const shouldSkipByAmapClickDoubleTriggerBug = (e) => {
|
|
11
10
|
return isTouchDevice && e.originEvent.type === "mouseup";
|
|
@@ -33,7 +32,6 @@ const AmapMarker = defineSetup("AmapMarker", function(props, { emit }) {
|
|
|
33
32
|
(_b = markerRef.value) == null ? void 0 : _b.destroy();
|
|
34
33
|
markerRef.value = void 0;
|
|
35
34
|
});
|
|
36
|
-
useAmapFixBugOverlayDrag(markerRef);
|
|
37
35
|
watchPostEffect((onCleanup) => {
|
|
38
36
|
var _a;
|
|
39
37
|
const map = mapRef == null ? void 0 : mapRef.value;
|
|
@@ -27,6 +27,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
|
|
|
27
27
|
duration: number;
|
|
28
28
|
distance: number;
|
|
29
29
|
}[];
|
|
30
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
30
31
|
};
|
|
31
32
|
index: number;
|
|
32
33
|
path: [number, number][];
|
|
@@ -38,6 +39,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
|
|
|
38
39
|
duration: number;
|
|
39
40
|
distance: number;
|
|
40
41
|
}[];
|
|
42
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
41
43
|
};
|
|
42
44
|
angleRef: import("vue-demi").Ref<number>;
|
|
43
45
|
graspRoadPathRef: import("vue-demi").Ref<Point[] | undefined>;
|
|
@@ -14,6 +14,7 @@ export declare const useADrivingRoute: (props?: UseDrivingRouteProps) => {
|
|
|
14
14
|
duration: number;
|
|
15
15
|
distance: number;
|
|
16
16
|
}[];
|
|
17
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
17
18
|
};
|
|
18
19
|
apiMapDrivingRoute: (from: Point, to: Point) => Promise<Route>;
|
|
19
20
|
};
|
|
@@ -28,6 +29,7 @@ export declare const useGDrivingRoute: (props?: UseDrivingRouteProps) => {
|
|
|
28
29
|
duration: number;
|
|
29
30
|
distance: number;
|
|
30
31
|
}[];
|
|
32
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
31
33
|
};
|
|
32
34
|
apiMapDrivingRoute: (from: Point, to: Point) => Promise<Route>;
|
|
33
35
|
};
|
|
@@ -42,6 +44,7 @@ export declare const useDrivingRoute: (props?: UseDrivingRouteProps) => {
|
|
|
42
44
|
duration: number;
|
|
43
45
|
distance: number;
|
|
44
46
|
}[];
|
|
47
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
45
48
|
};
|
|
46
49
|
apiMapDrivingRoute: (from: Point, to: Point) => Promise<Route>;
|
|
47
50
|
};
|
|
@@ -78,6 +78,7 @@ export interface Route {
|
|
|
78
78
|
duration: number;
|
|
79
79
|
tolls?: number;
|
|
80
80
|
steps: RouteStep[];
|
|
81
|
+
trafficJams?: TrafficJams;
|
|
81
82
|
}
|
|
82
83
|
export interface TrackPoint {
|
|
83
84
|
lng: number;
|
|
@@ -105,3 +106,5 @@ export type ProxyServiceError = {
|
|
|
105
106
|
code: number;
|
|
106
107
|
msg: string;
|
|
107
108
|
};
|
|
109
|
+
export type TrafficStatus = "UNKNOWN" | "NORMAL" | "SLOW" | "TRAFFIC_JAM" | "HEAVY_TRAFFIC_JAM";
|
|
110
|
+
export type TrafficJams = Record<`${number},${number}`, TrafficStatus>;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { apiGaodeDirectionDriving } from "../api/gaodeDirectionDriving.js";
|
|
2
2
|
import { apiGoogleDirections } from "../api/googleDirections.js";
|
|
3
|
+
import { stringifyPoint, amapTraffic2trafficStatus } from "./transform.js";
|
|
4
|
+
const amapTmcs2trafficJams = (tmcs) => {
|
|
5
|
+
const trafficJams = {};
|
|
6
|
+
for (const tmc of tmcs) {
|
|
7
|
+
const { path } = tmc;
|
|
8
|
+
if (!path)
|
|
9
|
+
continue;
|
|
10
|
+
for (const { lng, lat } of path) {
|
|
11
|
+
trafficJams[stringifyPoint([lng, lat])] = amapTraffic2trafficStatus(tmc.status);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return trafficJams;
|
|
15
|
+
};
|
|
3
16
|
function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
4
17
|
return new Promise((resolve, reject) => {
|
|
5
18
|
amapDriving.search(
|
|
@@ -7,6 +20,7 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
7
20
|
AMap.LngLat.from(to),
|
|
8
21
|
{ waypoints: [] },
|
|
9
22
|
(status, result) => {
|
|
23
|
+
const trafficJams = {};
|
|
10
24
|
switch (status) {
|
|
11
25
|
case "complete": {
|
|
12
26
|
let path = [];
|
|
@@ -19,6 +33,7 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
19
33
|
const basicStep = step;
|
|
20
34
|
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
21
35
|
path = path.concat(stepPath);
|
|
36
|
+
Object.assign(trafficJams, amapTmcs2trafficJams(basicStep.tmcs));
|
|
22
37
|
routeSteps.push({
|
|
23
38
|
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
24
39
|
duration: basicStep.time,
|
|
@@ -30,7 +45,8 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
30
45
|
distance: firstRoute.distance,
|
|
31
46
|
duration: firstRoute.time,
|
|
32
47
|
tolls: firstRoute.tolls,
|
|
33
|
-
steps: routeSteps
|
|
48
|
+
steps: routeSteps,
|
|
49
|
+
trafficJams
|
|
34
50
|
});
|
|
35
51
|
}
|
|
36
52
|
case "no_data":
|
|
@@ -48,6 +64,7 @@ async function gaodeServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
|
48
64
|
origin: [from],
|
|
49
65
|
destination: to
|
|
50
66
|
});
|
|
67
|
+
const trafficJams = {};
|
|
51
68
|
switch (status) {
|
|
52
69
|
case "complete": {
|
|
53
70
|
let path = [];
|
|
@@ -59,6 +76,7 @@ async function gaodeServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
|
59
76
|
const basicStep = step;
|
|
60
77
|
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
61
78
|
path = path.concat(stepPath);
|
|
79
|
+
Object.assign(trafficJams, amapTmcs2trafficJams(basicStep.tmcs));
|
|
62
80
|
routeSteps.push({
|
|
63
81
|
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
64
82
|
duration: basicStep.time,
|
|
@@ -70,7 +88,8 @@ async function gaodeServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
|
70
88
|
distance: firstRoute.distance,
|
|
71
89
|
duration: firstRoute.time,
|
|
72
90
|
tolls: firstRoute.tolls,
|
|
73
|
-
steps: routeSteps
|
|
91
|
+
steps: routeSteps,
|
|
92
|
+
trafficJams
|
|
74
93
|
};
|
|
75
94
|
}
|
|
76
95
|
case "no_data":
|
package/dist/v2/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.
|
|
3
|
+
const pkgVersion = "2.8.0";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
|
-
import type { LngLatLiterial, Place, Point, TrackPoint, Zone } from "../types/interface";
|
|
2
|
+
import type { LngLatLiterial, Place, Point, TrackPoint, TrafficStatus, Zone } from "../types/interface";
|
|
3
3
|
import type { AlipayMyGetLocationSuccessResponse } from "../types/my";
|
|
4
4
|
import type { WxGetLocationSuccessResponse } from "../types/wx";
|
|
5
5
|
import { BRWOSER_PLATFORM } from "./platform";
|
|
@@ -9,6 +9,7 @@ export declare const lnglat2point: ({ lng, lat }: {
|
|
|
9
9
|
lng: number;
|
|
10
10
|
lat: number;
|
|
11
11
|
}) => Point;
|
|
12
|
+
export declare const stringifyPoint: (p: Point) => `${number},${number}`;
|
|
12
13
|
export declare const googlePointsStringify: (points: Point[]) => string;
|
|
13
14
|
export declare const gaodePointsStringify: (points: Point[]) => string;
|
|
14
15
|
export interface AsteriskItem {
|
|
@@ -45,4 +46,5 @@ export declare const maybeFunctionToFunction: <T>(value: T) => MaybeFunctionToFu
|
|
|
45
46
|
export declare const signal2promise: (signal?: AbortSignal) => Promise<any>;
|
|
46
47
|
export declare const googleEncodedPolyline2googleLatLng: (value: string) => google.maps.LatLng[];
|
|
47
48
|
export declare const gaodePolyline2amapLngLat: (value: string) => AMap.LngLat[];
|
|
49
|
+
export declare const amapTraffic2trafficStatus: (value?: AMap.TMC["status"]) => TrafficStatus;
|
|
48
50
|
export {};
|