@heycar/heycars-map 2.7.2 → 2.8.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/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 +23 -14
- 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 +117 -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/useDeviationCorrectionDrivingRoute.js +6 -2
- 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 +6 -0
- package/dist/v2/utils/compatibleDrivingRoute.js +29 -2
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.d.ts +4 -1
- package/dist/v2/utils/transform.js +23 -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 +23 -14
- 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 +115 -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/useDeviationCorrectionDrivingRoute.js +6 -2
- 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 +6 -0
- package/dist/v3/utils/compatibleDrivingRoute.js +29 -2
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.d.ts +4 -1
- package/dist/v3/utils/transform.js +23 -1
- package/package.json +1 -1
|
@@ -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>;
|
|
@@ -134,7 +134,12 @@ const createSubRouteByPoint = (route, point, distanceOfLineFn) => {
|
|
|
134
134
|
count += step.path.length;
|
|
135
135
|
if (count <= index)
|
|
136
136
|
continue;
|
|
137
|
-
|
|
137
|
+
if (step.path.length + index - count + 1 < 0) {
|
|
138
|
+
console.error(
|
|
139
|
+
"`MyError: createSubRouteByPoint unexpected condition: step.path.length + index - count + 1 < 0"
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const firstStepPath = [point, ...step.path.slice(step.path.length + index - count + 1)];
|
|
138
143
|
const totalStepDistanceByMeasure = distanceOfLineFn(step.path);
|
|
139
144
|
const stepDistanceByMeasure = (_a = distanceOfLineFn(firstStepPath)) != null ? _a : 0;
|
|
140
145
|
const firstStepDistance = totalStepDistanceByMeasure ? step.distance * stepDistanceByMeasure / totalStepDistanceByMeasure : stepDistanceByMeasure;
|
|
@@ -153,7 +158,6 @@ const createSubRouteByPoint = (route, point, distanceOfLineFn) => {
|
|
|
153
158
|
distance += step.distance;
|
|
154
159
|
duration += step.duration;
|
|
155
160
|
}
|
|
156
|
-
console.log("point, index, distance, steps, route = ", point, index, distance, steps, route);
|
|
157
161
|
return { path, duration, distance, steps, index, baseRoute: route };
|
|
158
162
|
};
|
|
159
163
|
const createEmptySubRoute = () => {
|
|
@@ -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,8 @@ 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}`, {
|
|
111
|
+
before: TrafficStatus;
|
|
112
|
+
after: TrafficStatus;
|
|
113
|
+
}>;
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { apiGaodeDirectionDriving } from "../api/gaodeDirectionDriving.js";
|
|
2
2
|
import { apiGoogleDirections } from "../api/googleDirections.js";
|
|
3
|
+
import { amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
|
|
4
|
+
const amapTmcs2trafficJams = (tmcs) => {
|
|
5
|
+
const trafficJams = {};
|
|
6
|
+
let prevStatus = "UNKNOWN";
|
|
7
|
+
for (const tmc of tmcs) {
|
|
8
|
+
const { path } = tmc;
|
|
9
|
+
if (!path)
|
|
10
|
+
continue;
|
|
11
|
+
for (const { lng, lat } of path) {
|
|
12
|
+
const status = amapTraffic2trafficStatus(tmc.status);
|
|
13
|
+
trafficJams[stringifyPoint([lng, lat])] = {
|
|
14
|
+
before: prevStatus,
|
|
15
|
+
after: status
|
|
16
|
+
};
|
|
17
|
+
prevStatus = status;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return trafficJams;
|
|
21
|
+
};
|
|
3
22
|
function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
4
23
|
return new Promise((resolve, reject) => {
|
|
5
24
|
amapDriving.search(
|
|
@@ -7,9 +26,11 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
7
26
|
AMap.LngLat.from(to),
|
|
8
27
|
{ waypoints: [] },
|
|
9
28
|
(status, result) => {
|
|
29
|
+
const trafficJams = {};
|
|
10
30
|
switch (status) {
|
|
11
31
|
case "complete": {
|
|
12
32
|
let path = [];
|
|
33
|
+
let tmcs = [];
|
|
13
34
|
const drivingResult = result;
|
|
14
35
|
const routeSteps = [];
|
|
15
36
|
const firstRoute = drivingResult.routes[0];
|
|
@@ -19,18 +40,21 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
19
40
|
const basicStep = step;
|
|
20
41
|
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
21
42
|
path = path.concat(stepPath);
|
|
43
|
+
tmcs = tmcs.concat(basicStep.tmcs);
|
|
22
44
|
routeSteps.push({
|
|
23
45
|
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
24
46
|
duration: basicStep.time,
|
|
25
47
|
distance: basicStep.distance
|
|
26
48
|
});
|
|
27
49
|
}
|
|
50
|
+
Object.assign(trafficJams, amapTmcs2trafficJams(tmcs));
|
|
28
51
|
return resolve({
|
|
29
52
|
path,
|
|
30
53
|
distance: firstRoute.distance,
|
|
31
54
|
duration: firstRoute.time,
|
|
32
55
|
tolls: firstRoute.tolls,
|
|
33
|
-
steps: routeSteps
|
|
56
|
+
steps: routeSteps,
|
|
57
|
+
trafficJams
|
|
34
58
|
});
|
|
35
59
|
}
|
|
36
60
|
case "no_data":
|
|
@@ -48,6 +72,7 @@ async function gaodeServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
|
48
72
|
origin: [from],
|
|
49
73
|
destination: to
|
|
50
74
|
});
|
|
75
|
+
const trafficJams = {};
|
|
51
76
|
switch (status) {
|
|
52
77
|
case "complete": {
|
|
53
78
|
let path = [];
|
|
@@ -59,6 +84,7 @@ async function gaodeServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
|
59
84
|
const basicStep = step;
|
|
60
85
|
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
61
86
|
path = path.concat(stepPath);
|
|
87
|
+
Object.assign(trafficJams, amapTmcs2trafficJams(basicStep.tmcs));
|
|
62
88
|
routeSteps.push({
|
|
63
89
|
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
64
90
|
duration: basicStep.time,
|
|
@@ -70,7 +96,8 @@ async function gaodeServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
|
70
96
|
distance: firstRoute.distance,
|
|
71
97
|
duration: firstRoute.time,
|
|
72
98
|
tolls: firstRoute.tolls,
|
|
73
|
-
steps: routeSteps
|
|
99
|
+
steps: routeSteps,
|
|
100
|
+
trafficJams
|
|
74
101
|
};
|
|
75
102
|
}
|
|
76
103
|
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.1";
|
|
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 {
|
|
@@ -24,6 +25,7 @@ export declare const pipeAsync: <P extends any[]>(fn?: ((...args: P) => any) | u
|
|
|
24
25
|
export declare const pipeDefer: <P extends any[], R>(fn: (...args: P) => R) => (...args: P) => Promise<R>;
|
|
25
26
|
export declare const pipeOnlyLastEffect: <P extends any[], R>(fn: (...arg: P) => Promise<R>) => (...args: P) => Promise<R>;
|
|
26
27
|
export declare const isPlaceEqual: (p1: Place, p2?: Place) => boolean;
|
|
28
|
+
export declare const isPointExactEqual: (p1: Point, p2?: Point) => boolean;
|
|
27
29
|
export declare const isPointEqual: (p1: Point, p2?: Point) => boolean;
|
|
28
30
|
export declare const isGeoPositionEqual: (p1: GeolocationPosition, p2?: GeolocationPosition) => boolean;
|
|
29
31
|
export declare const isZoneEqual: (z1: Zone, z2?: Zone) => boolean;
|
|
@@ -45,4 +47,5 @@ export declare const maybeFunctionToFunction: <T>(value: T) => MaybeFunctionToFu
|
|
|
45
47
|
export declare const signal2promise: (signal?: AbortSignal) => Promise<any>;
|
|
46
48
|
export declare const googleEncodedPolyline2googleLatLng: (value: string) => google.maps.LatLng[];
|
|
47
49
|
export declare const gaodePolyline2amapLngLat: (value: string) => AMap.LngLat[];
|
|
50
|
+
export declare const amapTraffic2trafficStatus: (value?: AMap.TMC["status"]) => TrafficStatus;
|
|
48
51
|
export {};
|
|
@@ -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("*");
|
|
@@ -95,6 +96,9 @@ const pipeOnlyLastEffect = (fn) => {
|
|
|
95
96
|
const isPlaceEqual = (p1, p2) => {
|
|
96
97
|
return isAccuryEqual(p1.lng, p2 == null ? void 0 : p2.lng) && isAccuryEqual(p1.lat, p2 == null ? void 0 : p2.lat);
|
|
97
98
|
};
|
|
99
|
+
const isPointExactEqual = (p1, p2) => {
|
|
100
|
+
return p1[0] === (p2 == null ? void 0 : p2[0]) && p1[1] === (p2 == null ? void 0 : p2[1]);
|
|
101
|
+
};
|
|
98
102
|
const isPointEqual = (p1, p2) => {
|
|
99
103
|
return isAccuryEqual(p1[0], p2 == null ? void 0 : p2[0]) && isAccuryEqual(p1[1], p2 == null ? void 0 : p2[1]);
|
|
100
104
|
};
|
|
@@ -287,10 +291,26 @@ const gaodePolyline2amapLngLat = (value) => {
|
|
|
287
291
|
return { lng, lat };
|
|
288
292
|
});
|
|
289
293
|
};
|
|
294
|
+
const amapTraffic2trafficStatus = (value) => {
|
|
295
|
+
switch (value) {
|
|
296
|
+
case void 0:
|
|
297
|
+
case "未知":
|
|
298
|
+
return "UNKNOWN";
|
|
299
|
+
case "畅通":
|
|
300
|
+
return "NORMAL";
|
|
301
|
+
case "缓行":
|
|
302
|
+
return "SLOW";
|
|
303
|
+
case "拥堵":
|
|
304
|
+
return "TRAFFIC_JAM";
|
|
305
|
+
case "严重拥堵":
|
|
306
|
+
return "HEAVY_TRAFFIC_JAM";
|
|
307
|
+
}
|
|
308
|
+
};
|
|
290
309
|
export {
|
|
291
310
|
alipayMyGetLocationError2GeolocationPositionErrorCode,
|
|
292
311
|
alipayMyGetLocationSuccessResponse2GeolocationPosition,
|
|
293
312
|
amapPlaceName2DisplayName,
|
|
313
|
+
amapTraffic2trafficStatus,
|
|
294
314
|
businessCandidatesToAdsorptionPlace,
|
|
295
315
|
combineHandler,
|
|
296
316
|
decodeAsterisk,
|
|
@@ -306,6 +326,7 @@ export {
|
|
|
306
326
|
isGeoPositionEqual,
|
|
307
327
|
isPlaceEqual,
|
|
308
328
|
isPointEqual,
|
|
329
|
+
isPointExactEqual,
|
|
309
330
|
isZoneEqual,
|
|
310
331
|
lnglat2point,
|
|
311
332
|
maybeFunctionToFunction,
|
|
@@ -316,6 +337,7 @@ export {
|
|
|
316
337
|
property2emitEventName,
|
|
317
338
|
property2mapEventName,
|
|
318
339
|
signal2promise,
|
|
340
|
+
stringifyPoint,
|
|
319
341
|
trackPoints2amapGraspRoadPoints,
|
|
320
342
|
vec2lnglat,
|
|
321
343
|
wxGetLocationSuccessResponse2GeolocationPosition
|