@heycar/heycars-map 2.16.0-downgrade1 → 2.17.0-curve2

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.
Files changed (27) hide show
  1. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +1 -1
  2. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +21 -32
  3. package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +10 -0
  4. package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +100 -0
  5. package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
  6. package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
  7. package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.d.ts +3 -0
  8. package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
  9. package/dist/v2/components/AmapBezierCurve/index.d.ts +1 -0
  10. package/dist/v2/components/AmapBezierCurve/index.js +4 -0
  11. package/dist/v2/utils/geometryPolygon.d.ts +28 -0
  12. package/dist/v2/utils/geometryPolygon.js +57 -0
  13. package/dist/v2/utils/log.js +1 -1
  14. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +3 -3
  15. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +17 -26
  16. package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +16 -0
  17. package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +94 -0
  18. package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
  19. package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
  20. package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.d.ts +7 -0
  21. package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
  22. package/dist/v3/components/AmapBezierCurve/index.d.ts +1 -0
  23. package/dist/v3/components/AmapBezierCurve/index.js +4 -0
  24. package/dist/v3/utils/geometryPolygon.d.ts +28 -0
  25. package/dist/v3/utils/geometryPolygon.js +57 -0
  26. package/dist/v3/utils/log.js +1 -1
  27. package/package.json +1 -1
@@ -14,7 +14,7 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
14
14
  distance: number;
15
15
  duration: number;
16
16
  tolls?: number;
17
- }) => string;
17
+ }) => string | undefined;
18
18
  onClickStartPoint?: (value: CoordinatePlace) => void;
19
19
  onClickEndPoint?: (value: CoordinatePlace) => void;
20
20
  };
@@ -7,12 +7,12 @@ import { useMapFitView } from "../../hooks/useMapFitView.js";
7
7
  import { useMapSupplier, useMapAssertSupplier } from "../../hooks/useMapSupplier.js";
8
8
  import { defineSetup, defineLagecySetup } from "../../types/helper.js";
9
9
  import { generateCreateElementV2PropsOn } from "../../utils/compare.js";
10
+ import { distanceBetweenTwoPoints } from "../../utils/geometryPolygon.js";
10
11
  import { place2point, pipeDefer } from "../../utils/transform.js";
11
12
  import { toCoordinatePlaceType } from "../../utils/typeChecking.js";
12
- import { DrivingRoute } from "../DrivingRoute/DrivingRoute.js";
13
+ import { DrivingQuadraticBezierCurve } from "../DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js";
13
14
  import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
14
15
  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,
@@ -61,6 +61,7 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
61
61
  const toPlace = unCoordinatifyPlace(toCoordinatePlaceType(inputToPlace));
62
62
  const from = place2point(fromPlace);
63
63
  const to = place2point(toPlace);
64
+ const distance = distanceBetweenTwoPoints(from, to);
64
65
  return h(HeycarMap, {
65
66
  "class": attrs.class,
66
67
  "style": attrs.style,
@@ -85,39 +86,27 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
85
86
  "on": {
86
87
  "click": () => !disableStartPoint && emit("clickStartPoint", coordinatifyPlace(fromPlace))
87
88
  }
88
- }), h(DrivingRoute, {
89
+ }), h(DrivingQuadraticBezierCurve, {
89
90
  "attrs": {
90
- "to": to,
91
91
  "from": from,
92
- "render": ({
93
- path,
92
+ "to": to
93
+ }
94
+ }), h(StartEndPoint, {
95
+ "attrs": {
96
+ "type": "end",
97
+ "registerOverlay": fittableRegistryOverlay,
98
+ "position": to,
99
+ "title": toPlace.displayName,
100
+ "description": renderDescription({
94
101
  distance,
95
- duration,
96
- tolls,
97
- trafficJams
98
- }) => [h(TrafficDrivingLine, {
99
- "attrs": {
100
- "path": path,
101
- "trafficJams": trafficJams
102
- }
103
- }), h(StartEndPoint, {
104
- "attrs": {
105
- "type": "end",
106
- "registerOverlay": fittableRegistryOverlay,
107
- "position": to,
108
- "title": toPlace.displayName,
109
- "description": renderDescription({
110
- distance,
111
- duration,
112
- tolls
113
- }),
114
- "withArrow": !disableEndPoint,
115
- "language": language
116
- },
117
- "on": {
118
- "click": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
119
- }
120
- })]
102
+ duration: 0,
103
+ tolls: 0
104
+ }),
105
+ "withArrow": !disableEndPoint,
106
+ "language": language
107
+ },
108
+ "on": {
109
+ "click": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
121
110
  }
122
111
  }), h(FitViewOnce, {
123
112
  "attrs": {
@@ -0,0 +1,10 @@
1
+ import type { Point } from "../../types/interface";
2
+ export interface DrivingQuadraticBezierCurveProps {
3
+ from: Point;
4
+ to: Point;
5
+ lineCap?: AMap.LineSharedOptions["lineCap"];
6
+ color?: string;
7
+ }
8
+ export declare const ADrivingQuadraticBezierCurve: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingQuadraticBezierCurveProps>, 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<DrivingQuadraticBezierCurveProps, Required<DrivingQuadraticBezierCurveProps>>, never, DrivingQuadraticBezierCurveProps>;
9
+ export declare const GDrivingQuadraticBezierCurve: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingQuadraticBezierCurveProps>, 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<DrivingQuadraticBezierCurveProps, Required<DrivingQuadraticBezierCurveProps>>, never, DrivingQuadraticBezierCurveProps>;
10
+ export declare const DrivingQuadraticBezierCurve: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingQuadraticBezierCurveProps>, 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<DrivingQuadraticBezierCurveProps, Required<DrivingQuadraticBezierCurveProps>>, never, DrivingQuadraticBezierCurveProps>;
@@ -0,0 +1,100 @@
1
+ import { h } from "vue";
2
+ import { computed } from "vue-demi";
3
+ import { ZINDEX_LINE_LAYER } from "../../api/contants.js";
4
+ import { AmapBezierCurve } from "../../components/AmapBezierCurve/AmapBezierCurve.js";
5
+ import { GmapPolyline } from "../../components/GmapPolyline/GmapPolyline.js";
6
+ import { createElement } from "../../demi-polyfill/demi-polyfill.js";
7
+ import { useMapSupplier } from "../../hooks/useMapSupplier.js";
8
+ import { defineSetup } from "../../types/helper.js";
9
+ import { createQuadraticBezierCurvePoints, calculateLeftIsoscelesVertex } from "../../utils/geometryPolygon.js";
10
+ import { vec2lnglat } from "../../utils/transform.js";
11
+ const CONTROL_POINT_ANGLE = 30;
12
+ const OUTLINE_COLOR = "#FFFFFF";
13
+ const ADrivingQuadraticBezierCurve = defineSetup("ADrivingQuadraticBezierCurve", function(props) {
14
+ const pathRef = computed(() => {
15
+ const {
16
+ from,
17
+ to
18
+ } = props;
19
+ const controlPoint = calculateLeftIsoscelesVertex(from, to, CONTROL_POINT_ANGLE);
20
+ return [from, [...controlPoint, ...to]];
21
+ });
22
+ return () => {
23
+ const {
24
+ lineCap = "round",
25
+ color = "#4471FF"
26
+ } = props;
27
+ const vw = window.innerWidth * 0.01;
28
+ const strokeWidth = 1 * vw;
29
+ const borderWidth = 0.13 * vw;
30
+ const outlineWidth = 0.4 * vw;
31
+ return h("div", [h(AmapBezierCurve, {
32
+ "attrs": {
33
+ "path": pathRef.value,
34
+ "isOutline": true,
35
+ "borderWeight": outlineWidth,
36
+ "outlineColor": OUTLINE_COLOR,
37
+ "strokeWeight": strokeWidth + 2 * borderWidth,
38
+ "strokeOpacity": 1,
39
+ "strokeColor": color,
40
+ "lineJoin": "round",
41
+ "lineCap": lineCap,
42
+ "zIndex": ZINDEX_LINE_LAYER
43
+ }
44
+ })]);
45
+ };
46
+ });
47
+ const GDrivingQuadraticBezierCurve = defineSetup("GDrivingQuadraticBezierCurve", function(props) {
48
+ const pathRef = computed(() => {
49
+ const {
50
+ from,
51
+ to
52
+ } = props;
53
+ const controlPoint = calculateLeftIsoscelesVertex(from, to, CONTROL_POINT_ANGLE);
54
+ return createQuadraticBezierCurvePoints(from, to, controlPoint).map(vec2lnglat);
55
+ });
56
+ return () => {
57
+ const {
58
+ color = "#4471FF"
59
+ } = props;
60
+ const vw = window.innerWidth * 0.01;
61
+ const strokeWidth = 1.25 * vw * 0.65;
62
+ const borderWidth = 0.175 * vw * 0.65;
63
+ const outlineWidth = 0.45 * vw * 0.65;
64
+ return h("div", [h(GmapPolyline, {
65
+ "attrs": {
66
+ "path": pathRef.value,
67
+ "strokeWeight": strokeWidth + 2 * borderWidth + 2 * outlineWidth,
68
+ "strokeOpacity": 1,
69
+ "strokeColor": OUTLINE_COLOR,
70
+ "zIndex": ZINDEX_LINE_LAYER
71
+ }
72
+ }), h(GmapPolyline, {
73
+ "attrs": {
74
+ "path": pathRef.value,
75
+ "strokeWeight": strokeWidth + 2 * borderWidth,
76
+ "strokeOpacity": 1,
77
+ "strokeColor": color,
78
+ "zIndex": ZINDEX_LINE_LAYER
79
+ }
80
+ })]);
81
+ };
82
+ });
83
+ const DrivingQuadraticBezierCurve = defineSetup("DrivingQuadraticBezierCurve", function(props) {
84
+ const payload = useMapSupplier();
85
+ return () => {
86
+ var _a, _b;
87
+ const color = (_b = (_a = payload.themeVariables) == null ? void 0 : _a.TRAFFIC_UNKNOWN_BACKGROUND_COLOR) != null ? _b : props.color;
88
+ return createElement(payload.supplier === "gmap" ? GDrivingQuadraticBezierCurve : ADrivingQuadraticBezierCurve, {
89
+ attrs: {
90
+ ...props,
91
+ color
92
+ }
93
+ });
94
+ };
95
+ });
96
+ export {
97
+ ADrivingQuadraticBezierCurve,
98
+ DrivingQuadraticBezierCurve,
99
+ GDrivingQuadraticBezierCurve
100
+ };
@@ -0,0 +1 @@
1
+ export * from "./DrivingQuadraticBezierCurve";
@@ -0,0 +1,6 @@
1
+ import { ADrivingQuadraticBezierCurve, DrivingQuadraticBezierCurve, GDrivingQuadraticBezierCurve } from "./DrivingQuadraticBezierCurve.js";
2
+ export {
3
+ ADrivingQuadraticBezierCurve,
4
+ DrivingQuadraticBezierCurve,
5
+ GDrivingQuadraticBezierCurve
6
+ };
@@ -0,0 +1,3 @@
1
+ import { type AmapOverlay, type MapRegisterOverlayProps } from "../../hooks/useOverlay";
2
+ export type AmapBezierCurveProps = AMap.BezierCurveOptions & MapRegisterOverlayProps<AmapOverlay>;
3
+ export declare const AmapBezierCurve: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<AmapBezierCurveProps>, 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<AmapBezierCurveProps, Required<AmapBezierCurveProps>>, never, AmapBezierCurveProps>;
@@ -0,0 +1,57 @@
1
+ import { shallowRef, onMounted, onUnmounted, watchPostEffect } from "vue-demi";
2
+ import { useAmap } from "../../hooks/useMap.js";
3
+ import { useMapOverlay } from "../../hooks/useOverlay.js";
4
+ import { defineSetup } from "../../types/helper.js";
5
+ import { watchNoneImmediatePostEffectForMapProperty, watchNoneImmediatePostEffectForDeepOption } from "../../utils/compare.js";
6
+ import { referenceCount } from "../../utils/referenceCount.js";
7
+ const AmapBezierCurve = defineSetup(
8
+ "AmapBezierCurve",
9
+ function(props) {
10
+ const { registerOverlay } = props;
11
+ const bezierCurveRef = shallowRef();
12
+ const mapRef = useAmap();
13
+ onMounted(() => {
14
+ referenceCount.add();
15
+ const { registerOverlay: registerOverlay2, ...option } = props;
16
+ bezierCurveRef.value = new AMap.BezierCurve({ ...option });
17
+ });
18
+ useMapOverlay({ registerOverlay, overlayRef: bezierCurveRef });
19
+ onUnmounted(() => {
20
+ var _a, _b;
21
+ referenceCount.remove();
22
+ (_a = bezierCurveRef.value) == null ? void 0 : _a.setMap(null);
23
+ (_b = bezierCurveRef.value) == null ? void 0 : _b.destroy();
24
+ bezierCurveRef.value = void 0;
25
+ });
26
+ watchPostEffect((onCleanup) => {
27
+ var _a;
28
+ const map = mapRef == null ? void 0 : mapRef.value;
29
+ if (!(map == null ? void 0 : map.amap))
30
+ return;
31
+ (_a = bezierCurveRef.value) == null ? void 0 : _a.setMap(map.amap);
32
+ onCleanup(() => {
33
+ var _a2;
34
+ return (_a2 = bezierCurveRef.value) == null ? void 0 : _a2.setMap(null);
35
+ });
36
+ });
37
+ watchNoneImmediatePostEffectForMapProperty(bezierCurveRef, props, [
38
+ { name: "path", defaultValue: [[0, 0]] },
39
+ { name: "extData", defaultValue: void 0 },
40
+ { name: "draggable", defaultValue: false }
41
+ ]);
42
+ watchNoneImmediatePostEffectForDeepOption(
43
+ () => {
44
+ const { path, extData, draggable, ...otherOptions } = props;
45
+ return otherOptions;
46
+ },
47
+ (otherOptions) => {
48
+ var _a;
49
+ (_a = bezierCurveRef.value) == null ? void 0 : _a.setOptions({ ...otherOptions });
50
+ }
51
+ );
52
+ return () => null;
53
+ }
54
+ );
55
+ export {
56
+ AmapBezierCurve
57
+ };
@@ -0,0 +1 @@
1
+ export * from "./AmapBezierCurve";
@@ -0,0 +1,4 @@
1
+ import { AmapBezierCurve } from "./AmapBezierCurve.js";
2
+ export {
3
+ AmapBezierCurve
4
+ };
@@ -9,3 +9,31 @@ export declare const distanceBetweenTwoPoints: (from: Point, to: Point) => numbe
9
9
  * 计算折线(按顺序连接各点)总长度。
10
10
  */
11
11
  export declare const computeLineLength: (line: Point[]) => number;
12
+ /**
13
+ * 计算从起点指向终点的初始方位角(heading)。
14
+ * 说明:
15
+ * - 基于球面大圆航线计算(WGS84 半径近似),与常见地图 SDK 的 heading 含义一致
16
+ * - 返回范围为 [-180, 180](度):0 表示正北,正值为东偏北,负值为西偏南
17
+ * - 起终点经纬完全相同返回 0
18
+ * @returns 初始方位角(度)
19
+ */
20
+ export declare const computeLineAngle: (from: Point, to: Point) => number;
21
+ /**
22
+ * 根据指定的基线 (A -> B) 和底角 (angle),计算一个等腰三角形位于基线左侧的顶点。
23
+ *
24
+ * @param A 三角形基线的起始点, 格式为 [x, y]。
25
+ * @param B 三角形基线的终点, 格式为 [x, y]。
26
+ * @param angle 等腰三角形的底角 (∠PAB) 的大小,单位为角度 (degrees)。有效范围为 (-90, 90)。
27
+ * @returns 返回计算出的顶点 P 的坐标 [x, y];如果输入无效(例如 A、B 为同一点或 angle 超出范围),则返回 null。
28
+ */
29
+ export declare const calculateLeftIsoscelesVertex: (A: Point, B: Point, angle: number) => Point;
30
+ /**
31
+ * 根据给定的起始点、结束点和控制点,生成二次贝塞尔曲线的模拟点。
32
+ *
33
+ * @param from 起始点
34
+ * @param to 结束点
35
+ * @param controlPoint 控制点
36
+ * @param amount 要生成的模拟点的数量
37
+ * @returns 返回一个包含模拟点坐标的数组
38
+ */
39
+ export declare const createQuadraticBezierCurvePoints: (from: Point, to: Point, controlPoint: Point, amount?: number) => Point[];
@@ -47,8 +47,65 @@ const computeLineLength = (line) => {
47
47
  }
48
48
  return totalLength;
49
49
  };
50
+ const computeLineAngle = (from, to) => {
51
+ const [lng1, lat1] = from;
52
+ const [lng2, lat2] = to;
53
+ if (lng1 === lng2 && lat1 === lat2)
54
+ return 0;
55
+ const toRad = (deg) => deg * Math.PI / 180;
56
+ const toDeg = (rad) => rad * 180 / Math.PI;
57
+ const phi1 = toRad(lat1);
58
+ const phi2 = toRad(lat2);
59
+ const lambda1 = toRad(lng1);
60
+ const lambda2 = toRad(lng2);
61
+ const deltaLambda = lambda2 - lambda1;
62
+ const y = Math.sin(deltaLambda) * Math.cos(phi2);
63
+ const x = Math.cos(phi1) * Math.sin(phi2) - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda);
64
+ let heading = toDeg(Math.atan2(y, x));
65
+ heading = (heading + 540) % 360 - 180;
66
+ return heading;
67
+ };
68
+ const calculateLeftIsoscelesVertex = (A, B, angle) => {
69
+ const [x1, y1] = A;
70
+ const [x2, y2] = B;
71
+ const thetaInRadians = angle * Math.PI / 180;
72
+ const dx = x2 - x1;
73
+ const dy = y2 - y1;
74
+ if (dx === 0 && dy === 0)
75
+ return [x1, y1];
76
+ const midpointM = [(x1 + x2) / 2, (y1 + y2) / 2];
77
+ const tanTheta = Math.tan(thetaInRadians);
78
+ const vecMP_x = -0.5 * dy * tanTheta;
79
+ const vecMP_y = 0.5 * dx * tanTheta;
80
+ return [midpointM[0] + vecMP_x, midpointM[1] + vecMP_y];
81
+ };
82
+ const createQuadraticBezierCurvePoints = (from, to, controlPoint, amount = 50) => {
83
+ const points = [];
84
+ if (amount <= 0) {
85
+ return [];
86
+ }
87
+ if (amount === 1) {
88
+ return [from];
89
+ }
90
+ const [p0_x, p0_y] = from;
91
+ const [p1_x, p1_y] = controlPoint;
92
+ const [p2_x, p2_y] = to;
93
+ for (let i = 0; i < amount; i++) {
94
+ const t = i / (amount - 1);
95
+ const one_minus_t = 1 - t;
96
+ const t_squared = t * t;
97
+ const one_minus_t_squared = one_minus_t * one_minus_t;
98
+ const x = one_minus_t_squared * p0_x + 2 * one_minus_t * t * p1_x + t_squared * p2_x;
99
+ const y = one_minus_t_squared * p0_y + 2 * one_minus_t * t * p1_y + t_squared * p2_y;
100
+ points.push([x, y]);
101
+ }
102
+ return points;
103
+ };
50
104
  export {
105
+ calculateLeftIsoscelesVertex,
106
+ computeLineAngle,
51
107
  computeLineLength,
108
+ createQuadraticBezierCurvePoints,
52
109
  distanceBetweenTwoPoints,
53
110
  pointInPolygon
54
111
  };
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.16.0-downgrade1";
3
+ const pkgVersion = "2.17.0-curve2";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
@@ -14,7 +14,7 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
14
14
  distance: number;
15
15
  duration: number;
16
16
  tolls?: number;
17
- }) => string;
17
+ }) => string | undefined;
18
18
  onClickStartPoint?: (value: CoordinatePlace) => void;
19
19
  onClickEndPoint?: (value: CoordinatePlace) => void;
20
20
  };
@@ -26,7 +26,7 @@ export declare const BusinessQuotingMapInner: import("@vue/runtime-core").Define
26
26
  distance: number;
27
27
  duration: number;
28
28
  tolls?: number;
29
- }) => string;
29
+ }) => string | undefined;
30
30
  } & {
31
31
  default?: import("../../demi-polyfill").Slot | undefined;
32
32
  }>>;
@@ -38,7 +38,7 @@ export declare const BusinessQuotingMap: import("@vue/runtime-core").DefineCompo
38
38
  distance: number;
39
39
  duration: number;
40
40
  tolls?: number;
41
- }) => string;
41
+ }) => string | undefined;
42
42
  } & {
43
43
  default?: import("../../demi-polyfill").Slot | undefined;
44
44
  }>>;
@@ -7,12 +7,12 @@ import { useMapFitView } from "../../hooks/useMapFitView.js";
7
7
  import { useMapSupplier, useMapAssertSupplier } from "../../hooks/useMapSupplier.js";
8
8
  import { defineSetup, defineLagecySetup } from "../../types/helper.js";
9
9
  import { generateCreateElementV2PropsOn } from "../../utils/compare.js";
10
+ import { distanceBetweenTwoPoints } from "../../utils/geometryPolygon.js";
10
11
  import { place2point, pipeDefer } from "../../utils/transform.js";
11
12
  import { toCoordinatePlaceType } from "../../utils/typeChecking.js";
12
- import { DrivingRoute } from "../DrivingRoute/DrivingRoute.js";
13
+ import { DrivingQuadraticBezierCurve } from "../DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js";
13
14
  import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
14
15
  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,
@@ -61,6 +61,7 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
61
61
  const toPlace = unCoordinatifyPlace(toCoordinatePlaceType(inputToPlace));
62
62
  const from = place2point(fromPlace);
63
63
  const to = place2point(toPlace);
64
+ const distance = distanceBetweenTwoPoints(from, to);
64
65
  return createVNode(HeycarMap, {
65
66
  "class": attrs.class,
66
67
  "style": attrs.style,
@@ -78,32 +79,22 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
78
79
  "withArrow": !disableStartPoint,
79
80
  "language": language,
80
81
  "onClick": () => !disableStartPoint && emit("clickStartPoint", coordinatifyPlace(fromPlace))
81
- }, null), createVNode(DrivingRoute, {
82
- "to": to,
82
+ }, null), createVNode(DrivingQuadraticBezierCurve, {
83
83
  "from": from,
84
- "render": ({
85
- path,
84
+ "to": to
85
+ }, null), createVNode(StartEndPoint, {
86
+ "type": "end",
87
+ "registerOverlay": fittableRegistryOverlay,
88
+ "position": to,
89
+ "title": toPlace.displayName,
90
+ "description": renderDescription({
86
91
  distance,
87
- duration,
88
- tolls,
89
- trafficJams
90
- }) => [createVNode(TrafficDrivingLine, {
91
- "path": path,
92
- "trafficJams": trafficJams
93
- }, null), createVNode(StartEndPoint, {
94
- "type": "end",
95
- "registerOverlay": fittableRegistryOverlay,
96
- "position": to,
97
- "title": toPlace.displayName,
98
- "description": renderDescription({
99
- distance,
100
- duration,
101
- tolls
102
- }),
103
- "withArrow": !disableEndPoint,
104
- "language": language,
105
- "onClick": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
106
- }, null)]
92
+ duration: 0,
93
+ tolls: 0
94
+ }),
95
+ "withArrow": !disableEndPoint,
96
+ "language": language,
97
+ "onClick": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
107
98
  }, null), createVNode(FitViewOnce, {
108
99
  "registerOverlay": registerOverlay,
109
100
  "immediate": true
@@ -0,0 +1,16 @@
1
+ import type { Point } from "../../types/interface";
2
+ export interface DrivingQuadraticBezierCurveProps {
3
+ from: Point;
4
+ to: Point;
5
+ lineCap?: AMap.LineSharedOptions["lineCap"];
6
+ color?: string;
7
+ }
8
+ export declare const ADrivingQuadraticBezierCurve: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<DrivingQuadraticBezierCurveProps>, 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<DrivingQuadraticBezierCurveProps, Required<DrivingQuadraticBezierCurveProps>>, never, import("vue-demi").PublicProps, DrivingQuadraticBezierCurveProps, DrivingQuadraticBezierCurveProps, import("vue-demi").SlotsType<{} & {
9
+ default?: import("../../demi-polyfill").Slot | undefined;
10
+ }>>;
11
+ export declare const GDrivingQuadraticBezierCurve: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<DrivingQuadraticBezierCurveProps>, 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<DrivingQuadraticBezierCurveProps, Required<DrivingQuadraticBezierCurveProps>>, never, import("vue-demi").PublicProps, DrivingQuadraticBezierCurveProps, DrivingQuadraticBezierCurveProps, import("vue-demi").SlotsType<{} & {
12
+ default?: import("../../demi-polyfill").Slot | undefined;
13
+ }>>;
14
+ export declare const DrivingQuadraticBezierCurve: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<DrivingQuadraticBezierCurveProps>, 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<DrivingQuadraticBezierCurveProps, Required<DrivingQuadraticBezierCurveProps>>, never, import("vue-demi").PublicProps, DrivingQuadraticBezierCurveProps, DrivingQuadraticBezierCurveProps, import("vue-demi").SlotsType<{} & {
15
+ default?: import("../../demi-polyfill").Slot | undefined;
16
+ }>>;
@@ -0,0 +1,94 @@
1
+ import { createVNode } from "vue";
2
+ import { computed } from "vue-demi";
3
+ import { ZINDEX_LINE_LAYER } from "../../api/contants.js";
4
+ import { AmapBezierCurve } from "../../components/AmapBezierCurve/AmapBezierCurve.js";
5
+ import { GmapPolyline } from "../../components/GmapPolyline/GmapPolyline.js";
6
+ import { createElement } from "../../demi-polyfill/demi-polyfill.js";
7
+ import { useMapSupplier } from "../../hooks/useMapSupplier.js";
8
+ import { defineSetup } from "../../types/helper.js";
9
+ import { createQuadraticBezierCurvePoints, calculateLeftIsoscelesVertex } from "../../utils/geometryPolygon.js";
10
+ import { vec2lnglat } from "../../utils/transform.js";
11
+ const CONTROL_POINT_ANGLE = 30;
12
+ const OUTLINE_COLOR = "#FFFFFF";
13
+ const ADrivingQuadraticBezierCurve = defineSetup("ADrivingQuadraticBezierCurve", function(props) {
14
+ const pathRef = computed(() => {
15
+ const {
16
+ from,
17
+ to
18
+ } = props;
19
+ const controlPoint = calculateLeftIsoscelesVertex(from, to, CONTROL_POINT_ANGLE);
20
+ return [from, [...controlPoint, ...to]];
21
+ });
22
+ return () => {
23
+ const {
24
+ lineCap = "round",
25
+ color = "#4471FF"
26
+ } = props;
27
+ const vw = window.innerWidth * 0.01;
28
+ const strokeWidth = 1 * vw;
29
+ const borderWidth = 0.13 * vw;
30
+ const outlineWidth = 0.4 * vw;
31
+ return createVNode("div", null, [createVNode(AmapBezierCurve, {
32
+ "path": pathRef.value,
33
+ "isOutline": true,
34
+ "borderWeight": outlineWidth,
35
+ "outlineColor": OUTLINE_COLOR,
36
+ "strokeWeight": strokeWidth + 2 * borderWidth,
37
+ "strokeOpacity": 1,
38
+ "strokeColor": color,
39
+ "lineJoin": "round",
40
+ "lineCap": lineCap,
41
+ "zIndex": ZINDEX_LINE_LAYER
42
+ }, null)]);
43
+ };
44
+ });
45
+ const GDrivingQuadraticBezierCurve = defineSetup("GDrivingQuadraticBezierCurve", function(props) {
46
+ const pathRef = computed(() => {
47
+ const {
48
+ from,
49
+ to
50
+ } = props;
51
+ const controlPoint = calculateLeftIsoscelesVertex(from, to, CONTROL_POINT_ANGLE);
52
+ return createQuadraticBezierCurvePoints(from, to, controlPoint).map(vec2lnglat);
53
+ });
54
+ return () => {
55
+ const {
56
+ color = "#4471FF"
57
+ } = props;
58
+ const vw = window.innerWidth * 0.01;
59
+ const strokeWidth = 1.25 * vw * 0.65;
60
+ const borderWidth = 0.175 * vw * 0.65;
61
+ const outlineWidth = 0.45 * vw * 0.65;
62
+ return createVNode("div", null, [createVNode(GmapPolyline, {
63
+ "path": pathRef.value,
64
+ "strokeWeight": strokeWidth + 2 * borderWidth + 2 * outlineWidth,
65
+ "strokeOpacity": 1,
66
+ "strokeColor": OUTLINE_COLOR,
67
+ "zIndex": ZINDEX_LINE_LAYER
68
+ }, null), createVNode(GmapPolyline, {
69
+ "path": pathRef.value,
70
+ "strokeWeight": strokeWidth + 2 * borderWidth,
71
+ "strokeOpacity": 1,
72
+ "strokeColor": color,
73
+ "zIndex": ZINDEX_LINE_LAYER
74
+ }, null)]);
75
+ };
76
+ });
77
+ const DrivingQuadraticBezierCurve = defineSetup("DrivingQuadraticBezierCurve", function(props) {
78
+ const payload = useMapSupplier();
79
+ return () => {
80
+ var _a, _b;
81
+ const color = (_b = (_a = payload.themeVariables) == null ? void 0 : _a.TRAFFIC_UNKNOWN_BACKGROUND_COLOR) != null ? _b : props.color;
82
+ return createElement(payload.supplier === "gmap" ? GDrivingQuadraticBezierCurve : ADrivingQuadraticBezierCurve, {
83
+ attrs: {
84
+ ...props,
85
+ color
86
+ }
87
+ });
88
+ };
89
+ });
90
+ export {
91
+ ADrivingQuadraticBezierCurve,
92
+ DrivingQuadraticBezierCurve,
93
+ GDrivingQuadraticBezierCurve
94
+ };
@@ -0,0 +1 @@
1
+ export * from "./DrivingQuadraticBezierCurve";
@@ -0,0 +1,6 @@
1
+ import { ADrivingQuadraticBezierCurve, DrivingQuadraticBezierCurve, GDrivingQuadraticBezierCurve } from "./DrivingQuadraticBezierCurve.js";
2
+ export {
3
+ ADrivingQuadraticBezierCurve,
4
+ DrivingQuadraticBezierCurve,
5
+ GDrivingQuadraticBezierCurve
6
+ };
@@ -0,0 +1,7 @@
1
+ import { type AmapOverlay, type MapRegisterOverlayProps } from "../../hooks/useOverlay";
2
+ export type AmapBezierCurveProps = AMap.BezierCurveOptions & MapRegisterOverlayProps<AmapOverlay>;
3
+ export declare const AmapBezierCurve: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<AmapBezierCurveProps>, 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<AmapBezierCurveProps, Required<AmapBezierCurveProps>>, never, import("vue-demi").PublicProps, AmapBezierCurveProps, AmapBezierCurveProps, import("vue-demi").SlotsType<{
4
+ extData?: any;
5
+ } & {
6
+ default?: import("../../demi-polyfill").Slot | undefined;
7
+ }>>;
@@ -0,0 +1,57 @@
1
+ import { shallowRef, onMounted, onUnmounted, watchPostEffect } from "vue-demi";
2
+ import { useAmap } from "../../hooks/useMap.js";
3
+ import { useMapOverlay } from "../../hooks/useOverlay.js";
4
+ import { defineSetup } from "../../types/helper.js";
5
+ import { watchNoneImmediatePostEffectForMapProperty, watchNoneImmediatePostEffectForDeepOption } from "../../utils/compare.js";
6
+ import { referenceCount } from "../../utils/referenceCount.js";
7
+ const AmapBezierCurve = defineSetup(
8
+ "AmapBezierCurve",
9
+ function(props) {
10
+ const { registerOverlay } = props;
11
+ const bezierCurveRef = shallowRef();
12
+ const mapRef = useAmap();
13
+ onMounted(() => {
14
+ referenceCount.add();
15
+ const { registerOverlay: registerOverlay2, ...option } = props;
16
+ bezierCurveRef.value = new AMap.BezierCurve({ ...option });
17
+ });
18
+ useMapOverlay({ registerOverlay, overlayRef: bezierCurveRef });
19
+ onUnmounted(() => {
20
+ var _a, _b;
21
+ referenceCount.remove();
22
+ (_a = bezierCurveRef.value) == null ? void 0 : _a.setMap(null);
23
+ (_b = bezierCurveRef.value) == null ? void 0 : _b.destroy();
24
+ bezierCurveRef.value = void 0;
25
+ });
26
+ watchPostEffect((onCleanup) => {
27
+ var _a;
28
+ const map = mapRef == null ? void 0 : mapRef.value;
29
+ if (!(map == null ? void 0 : map.amap))
30
+ return;
31
+ (_a = bezierCurveRef.value) == null ? void 0 : _a.setMap(map.amap);
32
+ onCleanup(() => {
33
+ var _a2;
34
+ return (_a2 = bezierCurveRef.value) == null ? void 0 : _a2.setMap(null);
35
+ });
36
+ });
37
+ watchNoneImmediatePostEffectForMapProperty(bezierCurveRef, props, [
38
+ { name: "path", defaultValue: [[0, 0]] },
39
+ { name: "extData", defaultValue: void 0 },
40
+ { name: "draggable", defaultValue: false }
41
+ ]);
42
+ watchNoneImmediatePostEffectForDeepOption(
43
+ () => {
44
+ const { path, extData, draggable, ...otherOptions } = props;
45
+ return otherOptions;
46
+ },
47
+ (otherOptions) => {
48
+ var _a;
49
+ (_a = bezierCurveRef.value) == null ? void 0 : _a.setOptions({ ...otherOptions });
50
+ }
51
+ );
52
+ return () => null;
53
+ }
54
+ );
55
+ export {
56
+ AmapBezierCurve
57
+ };
@@ -0,0 +1 @@
1
+ export * from "./AmapBezierCurve";
@@ -0,0 +1,4 @@
1
+ import { AmapBezierCurve } from "./AmapBezierCurve.js";
2
+ export {
3
+ AmapBezierCurve
4
+ };
@@ -9,3 +9,31 @@ export declare const distanceBetweenTwoPoints: (from: Point, to: Point) => numbe
9
9
  * 计算折线(按顺序连接各点)总长度。
10
10
  */
11
11
  export declare const computeLineLength: (line: Point[]) => number;
12
+ /**
13
+ * 计算从起点指向终点的初始方位角(heading)。
14
+ * 说明:
15
+ * - 基于球面大圆航线计算(WGS84 半径近似),与常见地图 SDK 的 heading 含义一致
16
+ * - 返回范围为 [-180, 180](度):0 表示正北,正值为东偏北,负值为西偏南
17
+ * - 起终点经纬完全相同返回 0
18
+ * @returns 初始方位角(度)
19
+ */
20
+ export declare const computeLineAngle: (from: Point, to: Point) => number;
21
+ /**
22
+ * 根据指定的基线 (A -> B) 和底角 (angle),计算一个等腰三角形位于基线左侧的顶点。
23
+ *
24
+ * @param A 三角形基线的起始点, 格式为 [x, y]。
25
+ * @param B 三角形基线的终点, 格式为 [x, y]。
26
+ * @param angle 等腰三角形的底角 (∠PAB) 的大小,单位为角度 (degrees)。有效范围为 (-90, 90)。
27
+ * @returns 返回计算出的顶点 P 的坐标 [x, y];如果输入无效(例如 A、B 为同一点或 angle 超出范围),则返回 null。
28
+ */
29
+ export declare const calculateLeftIsoscelesVertex: (A: Point, B: Point, angle: number) => Point;
30
+ /**
31
+ * 根据给定的起始点、结束点和控制点,生成二次贝塞尔曲线的模拟点。
32
+ *
33
+ * @param from 起始点
34
+ * @param to 结束点
35
+ * @param controlPoint 控制点
36
+ * @param amount 要生成的模拟点的数量
37
+ * @returns 返回一个包含模拟点坐标的数组
38
+ */
39
+ export declare const createQuadraticBezierCurvePoints: (from: Point, to: Point, controlPoint: Point, amount?: number) => Point[];
@@ -47,8 +47,65 @@ const computeLineLength = (line) => {
47
47
  }
48
48
  return totalLength;
49
49
  };
50
+ const computeLineAngle = (from, to) => {
51
+ const [lng1, lat1] = from;
52
+ const [lng2, lat2] = to;
53
+ if (lng1 === lng2 && lat1 === lat2)
54
+ return 0;
55
+ const toRad = (deg) => deg * Math.PI / 180;
56
+ const toDeg = (rad) => rad * 180 / Math.PI;
57
+ const phi1 = toRad(lat1);
58
+ const phi2 = toRad(lat2);
59
+ const lambda1 = toRad(lng1);
60
+ const lambda2 = toRad(lng2);
61
+ const deltaLambda = lambda2 - lambda1;
62
+ const y = Math.sin(deltaLambda) * Math.cos(phi2);
63
+ const x = Math.cos(phi1) * Math.sin(phi2) - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda);
64
+ let heading = toDeg(Math.atan2(y, x));
65
+ heading = (heading + 540) % 360 - 180;
66
+ return heading;
67
+ };
68
+ const calculateLeftIsoscelesVertex = (A, B, angle) => {
69
+ const [x1, y1] = A;
70
+ const [x2, y2] = B;
71
+ const thetaInRadians = angle * Math.PI / 180;
72
+ const dx = x2 - x1;
73
+ const dy = y2 - y1;
74
+ if (dx === 0 && dy === 0)
75
+ return [x1, y1];
76
+ const midpointM = [(x1 + x2) / 2, (y1 + y2) / 2];
77
+ const tanTheta = Math.tan(thetaInRadians);
78
+ const vecMP_x = -0.5 * dy * tanTheta;
79
+ const vecMP_y = 0.5 * dx * tanTheta;
80
+ return [midpointM[0] + vecMP_x, midpointM[1] + vecMP_y];
81
+ };
82
+ const createQuadraticBezierCurvePoints = (from, to, controlPoint, amount = 50) => {
83
+ const points = [];
84
+ if (amount <= 0) {
85
+ return [];
86
+ }
87
+ if (amount === 1) {
88
+ return [from];
89
+ }
90
+ const [p0_x, p0_y] = from;
91
+ const [p1_x, p1_y] = controlPoint;
92
+ const [p2_x, p2_y] = to;
93
+ for (let i = 0; i < amount; i++) {
94
+ const t = i / (amount - 1);
95
+ const one_minus_t = 1 - t;
96
+ const t_squared = t * t;
97
+ const one_minus_t_squared = one_minus_t * one_minus_t;
98
+ const x = one_minus_t_squared * p0_x + 2 * one_minus_t * t * p1_x + t_squared * p2_x;
99
+ const y = one_minus_t_squared * p0_y + 2 * one_minus_t * t * p1_y + t_squared * p2_y;
100
+ points.push([x, y]);
101
+ }
102
+ return points;
103
+ };
50
104
  export {
105
+ calculateLeftIsoscelesVertex,
106
+ computeLineAngle,
51
107
  computeLineLength,
108
+ createQuadraticBezierCurvePoints,
52
109
  distanceBetweenTwoPoints,
53
110
  pointInPolygon
54
111
  };
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.16.0-downgrade1";
3
+ const pkgVersion = "2.17.0-curve2";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.16.0-downgrade1",
3
+ "version": "2.17.0-curve2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",