@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
|
@@ -42,8 +42,9 @@ const vec2lnglat = ([lng, lat]) => ({
|
|
|
42
42
|
lat: Number(lat)
|
|
43
43
|
});
|
|
44
44
|
const lnglat2point = ({ lng, lat }) => [lng, lat];
|
|
45
|
+
const stringifyPoint = (p) => `${p[0]},${p[1]}`;
|
|
45
46
|
const googlePointsStringify = (points) => points.map(([lng, lat]) => `${lat},${lng}`).join("|");
|
|
46
|
-
const gaodePointsStringify = (points) => points.map(
|
|
47
|
+
const gaodePointsStringify = (points) => points.map(stringifyPoint).join(";");
|
|
47
48
|
const decodeAsterisk = (encodedValue) => {
|
|
48
49
|
const result = [];
|
|
49
50
|
const tokens = encodedValue.split("*");
|
|
@@ -287,10 +288,26 @@ const gaodePolyline2amapLngLat = (value) => {
|
|
|
287
288
|
return { lng, lat };
|
|
288
289
|
});
|
|
289
290
|
};
|
|
291
|
+
const amapTraffic2trafficStatus = (value) => {
|
|
292
|
+
switch (value) {
|
|
293
|
+
case void 0:
|
|
294
|
+
case "未知":
|
|
295
|
+
return "UNKNOWN";
|
|
296
|
+
case "畅通":
|
|
297
|
+
return "NORMAL";
|
|
298
|
+
case "缓行":
|
|
299
|
+
return "SLOW";
|
|
300
|
+
case "拥堵":
|
|
301
|
+
return "TRAFFIC_JAM";
|
|
302
|
+
case "严重拥堵":
|
|
303
|
+
return "HEAVY_TRAFFIC_JAM";
|
|
304
|
+
}
|
|
305
|
+
};
|
|
290
306
|
export {
|
|
291
307
|
alipayMyGetLocationError2GeolocationPositionErrorCode,
|
|
292
308
|
alipayMyGetLocationSuccessResponse2GeolocationPosition,
|
|
293
309
|
amapPlaceName2DisplayName,
|
|
310
|
+
amapTraffic2trafficStatus,
|
|
294
311
|
businessCandidatesToAdsorptionPlace,
|
|
295
312
|
combineHandler,
|
|
296
313
|
decodeAsterisk,
|
|
@@ -316,6 +333,7 @@ export {
|
|
|
316
333
|
property2emitEventName,
|
|
317
334
|
property2mapEventName,
|
|
318
335
|
signal2promise,
|
|
336
|
+
stringifyPoint,
|
|
319
337
|
trackPoints2amapGraspRoadPoints,
|
|
320
338
|
vec2lnglat,
|
|
321
339
|
wxGetLocationSuccessResponse2GeolocationPosition
|
|
@@ -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,
|
|
@@ -83,9 +83,11 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
|
|
|
83
83
|
path,
|
|
84
84
|
distance,
|
|
85
85
|
duration,
|
|
86
|
-
tolls
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
tolls,
|
|
87
|
+
trafficJams
|
|
88
|
+
}) => [createVNode(TrafficDrivingLine, {
|
|
89
|
+
"path": path,
|
|
90
|
+
"trafficJams": trafficJams
|
|
89
91
|
}, null), createVNode(StartEndPoint, {
|
|
90
92
|
"type": "end",
|
|
91
93
|
"registerOverlay": fittableRegistryOverlay,
|
|
@@ -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";
|
|
@@ -77,9 +78,11 @@ const SectionConfirmed = defineSetup("SectionConfirmed", function(props) {
|
|
|
77
78
|
"to": to,
|
|
78
79
|
"from": from,
|
|
79
80
|
"render": ({
|
|
80
|
-
path
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
path,
|
|
82
|
+
trafficJams
|
|
83
|
+
}) => createVNode(TrafficDrivingLine, {
|
|
84
|
+
"path": path,
|
|
85
|
+
"trafficJams": trafficJams
|
|
83
86
|
}, null)
|
|
84
87
|
}, null), createVNode(ConditionalFittablePassengerCircle, {
|
|
85
88
|
"position": passengerPosition,
|
|
@@ -162,11 +165,13 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
|
|
|
162
165
|
path,
|
|
163
166
|
angle,
|
|
164
167
|
distance,
|
|
165
|
-
duration
|
|
168
|
+
duration,
|
|
169
|
+
trafficJams
|
|
166
170
|
}) => {
|
|
167
171
|
var _a;
|
|
168
|
-
return [createVNode(
|
|
169
|
-
"path": path
|
|
172
|
+
return [createVNode(TrafficDrivingLine, {
|
|
173
|
+
"path": path,
|
|
174
|
+
"trafficJams": trafficJams
|
|
170
175
|
}, null), createVNode(TaxiCar, {
|
|
171
176
|
"position": (_a = path[0]) != null ? _a : carPosition,
|
|
172
177
|
"angle": angle != null ? angle : carAngle,
|
|
@@ -233,9 +238,11 @@ const SectionBookDispatched = defineSetup("SectionBookDispatched", function(prop
|
|
|
233
238
|
"to": to,
|
|
234
239
|
"from": from,
|
|
235
240
|
"render": ({
|
|
236
|
-
path
|
|
237
|
-
|
|
238
|
-
|
|
241
|
+
path,
|
|
242
|
+
trafficJams
|
|
243
|
+
}) => createVNode(TrafficDrivingLine, {
|
|
244
|
+
"path": path,
|
|
245
|
+
"trafficJams": trafficJams
|
|
239
246
|
}, null)
|
|
240
247
|
}, null), !!passengerPosition && passengerDistance && passengerDistance < PASSENGER_DISTANCE_MAX && passengerDistance > PASSENGER_DISTANCE_MIN && createVNode(WalkingRoute, {
|
|
241
248
|
"from": passengerPosition,
|
|
@@ -370,11 +377,13 @@ const SectionInService = defineSetup("SectionInService", function(props) {
|
|
|
370
377
|
path,
|
|
371
378
|
angle,
|
|
372
379
|
distance,
|
|
373
|
-
duration
|
|
380
|
+
duration,
|
|
381
|
+
trafficJams
|
|
374
382
|
}) => {
|
|
375
383
|
var _a;
|
|
376
|
-
return [createVNode(
|
|
377
|
-
"path": path
|
|
384
|
+
return [createVNode(TrafficDrivingLine, {
|
|
385
|
+
"path": path,
|
|
386
|
+
"trafficJams": trafficJams
|
|
378
387
|
}, null), createVNode(TaxiCar, {
|
|
379
388
|
"position": (_a = path[0]) != null ? _a : carPosition,
|
|
380
389
|
"angle": angle != null ? angle : carAngle,
|
|
@@ -479,7 +488,7 @@ const SectionEndService = defineSetup("SectionEndService", function(props) {
|
|
|
479
488
|
path
|
|
480
489
|
}) => createVNode(DrivingLine, {
|
|
481
490
|
"path": path,
|
|
482
|
-
"
|
|
491
|
+
"status": "DONE"
|
|
483
492
|
}, null)
|
|
484
493
|
}, null), createVNode(StartEndPoint, {
|
|
485
494
|
"type": "start",
|
|
@@ -1,6 +1,9 @@
|
|
|
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("vue-demi").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, import("vue-demi").PublicProps, DrivingLineProps, DrivingLineProps, import("vue-demi").SlotsType<{} & {
|
|
6
9
|
default?: import("../../demi-polyfill").Slot | undefined;
|
|
@@ -11,3 +14,4 @@ export declare const GDrivingLine: import("vue-demi").DefineComponent<import("vu
|
|
|
11
14
|
export declare const DrivingLine: import("vue-demi").DefineComponent<import("vue-demi").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, import("vue-demi").PublicProps, DrivingLineProps, DrivingLineProps, import("vue-demi").SlotsType<{} & {
|
|
12
15
|
default?: import("../../demi-polyfill").Slot | undefined;
|
|
13
16
|
}>>;
|
|
17
|
+
export {};
|
|
@@ -7,24 +7,55 @@ 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 createVNode("div", null, [createVNode(AmapPolyline, {
|
|
22
53
|
"path": props.path,
|
|
23
54
|
"strokeWeight": strokeWidth + 2 * borderWidth + 2 * outlineWidth,
|
|
24
55
|
"strokeOpacity": 1,
|
|
25
56
|
"strokeColor": strokeColorOuter,
|
|
26
57
|
"lineJoin": "round",
|
|
27
|
-
"lineCap":
|
|
58
|
+
"lineCap": lineCap,
|
|
28
59
|
"zIndex": ZINDEX_LINE_LAYER
|
|
29
60
|
}, null), createVNode(AmapPolyline, {
|
|
30
61
|
"path": props.path,
|
|
@@ -32,7 +63,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
32
63
|
"strokeOpacity": 1,
|
|
33
64
|
"strokeColor": strokeColorBorder,
|
|
34
65
|
"lineJoin": "round",
|
|
35
|
-
"lineCap":
|
|
66
|
+
"lineCap": lineCap,
|
|
36
67
|
"strokeStyle": "dashed",
|
|
37
68
|
"strokeDasharray": [dashLength, dashLength * 0.5],
|
|
38
69
|
"zIndex": ZINDEX_LINE_LAYER
|
|
@@ -42,7 +73,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
42
73
|
"strokeOpacity": 1,
|
|
43
74
|
"strokeColor": strokeColorInner,
|
|
44
75
|
"lineJoin": "round",
|
|
45
|
-
"lineCap":
|
|
76
|
+
"lineCap": lineCap,
|
|
46
77
|
"zIndex": ZINDEX_LINE_LAYER
|
|
47
78
|
}, null), createVNode(AmapPolyline, {
|
|
48
79
|
"showDir": true,
|
|
@@ -51,7 +82,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
51
82
|
"strokeOpacity": 1,
|
|
52
83
|
"strokeColor": "transparent",
|
|
53
84
|
"lineJoin": "round",
|
|
54
|
-
"lineCap":
|
|
85
|
+
"lineCap": lineCap,
|
|
55
86
|
"zIndex": ZINDEX_LINE_LAYER
|
|
56
87
|
}, null)]);
|
|
57
88
|
};
|
|
@@ -59,15 +90,18 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
59
90
|
const GDrivingLine = defineSetup("GDrivingLine", function(props) {
|
|
60
91
|
const pathRef = computed(() => props.path.map(vec2lnglat));
|
|
61
92
|
return () => {
|
|
93
|
+
const {
|
|
94
|
+
status = "UNKNOWN"
|
|
95
|
+
} = props;
|
|
62
96
|
const vw = window.innerWidth * 0.01;
|
|
63
97
|
const repeat = 10 * vw;
|
|
64
98
|
const strokeWidth = 1.25 * vw * 0.65;
|
|
65
99
|
const borderWidth = 0.175 * vw * 0.65;
|
|
66
100
|
const dirStrokeWeight = 0.375 * vw * 0.65;
|
|
67
101
|
const outlineWidth = 0.45 * vw * 0.65;
|
|
68
|
-
const strokeColorInner =
|
|
69
|
-
const strokeColorOuter =
|
|
70
|
-
const strokeColorBorder =
|
|
102
|
+
const strokeColorInner = trafficInnerColors[status];
|
|
103
|
+
const strokeColorOuter = trafficOuterColors[status];
|
|
104
|
+
const strokeColorBorder = trafficBorderColors[status];
|
|
71
105
|
return createVNode("div", null, [createVNode(GmapPolyline, {
|
|
72
106
|
"path": pathRef.value,
|
|
73
107
|
"strokeWeight": strokeWidth + 2 * borderWidth + 2 * outlineWidth,
|
|
@@ -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,8 @@
|
|
|
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("vue").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, import("vue").PublicProps, TrafficDrivingLineProps, TrafficDrivingLineProps, import("vue").SlotsType<{} & {
|
|
7
|
+
default?: import("../../demi-polyfill").Slot | undefined;
|
|
8
|
+
}>>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createVNode } 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 createVNode("div", null, [beautifiedLines.map((line) => createVNode(DrivingLine, {
|
|
83
|
+
"path": line.path,
|
|
84
|
+
"status": line.status,
|
|
85
|
+
"lineCap": line.lineCap
|
|
86
|
+
}, null))]);
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
export {
|
|
90
|
+
TrafficDrivingLine
|
|
91
|
+
};
|
|
@@ -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/v3/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}`);
|