@heycar/heycars-map 2.15.0-sgn1 → 2.17.0-curve1
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/README.md +1 -1
- package/dist/v2/App.js +2 -2
- package/dist/v2/api/googleRoutes.js +2 -0
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +1 -1
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +20 -33
- package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +10 -0
- package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +100 -0
- package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
- package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
- package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.d.ts +3 -0
- package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
- package/dist/v2/components/AmapBezierCurve/index.d.ts +1 -0
- package/dist/v2/components/AmapBezierCurve/index.js +4 -0
- package/dist/v2/utils/geometryPolygon.d.ts +28 -0
- package/dist/v2/utils/geometryPolygon.js +57 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v3/App.js +2 -2
- package/dist/v3/api/googleRoutes.js +2 -0
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +3 -3
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +16 -27
- package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +16 -0
- package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +94 -0
- package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
- package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
- package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.d.ts +7 -0
- package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
- package/dist/v3/components/AmapBezierCurve/index.d.ts +1 -0
- package/dist/v3/components/AmapBezierCurve/index.js +4 -0
- package/dist/v3/utils/geometryPolygon.d.ts +28 -0
- package/dist/v3/utils/geometryPolygon.js +57 -0
- package/dist/v3/utils/log.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -204,7 +204,7 @@ export type DriverStatus =
|
|
|
204
204
|
// 弃用,谷歌路线规划代理地址
|
|
205
205
|
googleDirectionsProxyUrl="/overseas/maps/directions/json"
|
|
206
206
|
// 可选,谷歌路由服务代理地址
|
|
207
|
-
googleRoutesProxyUrl="/overseas/maps/routes/directions"
|
|
207
|
+
googleRoutesProxyUrl="/overseas/maps/routes/directions/v2"
|
|
208
208
|
// 可选,自定义地图颜色
|
|
209
209
|
themeVariables={
|
|
210
210
|
{
|
package/dist/v2/App.js
CHANGED
|
@@ -8,7 +8,7 @@ const amapApiKey = "fcb7b14c930354a248e21f4031dfa179";
|
|
|
8
8
|
const amapApiSecret = "11ad0e3d585b80d18b1ada5b0d947c4a";
|
|
9
9
|
const App = defineComponent({
|
|
10
10
|
setup() {
|
|
11
|
-
const supplierRef = ref("
|
|
11
|
+
const supplierRef = ref("gmap");
|
|
12
12
|
window.supplierRef = supplierRef;
|
|
13
13
|
return () => h(MapProvider, {
|
|
14
14
|
"attrs": {
|
|
@@ -19,7 +19,7 @@ const App = defineComponent({
|
|
|
19
19
|
"language": "en",
|
|
20
20
|
"supplier": supplierRef.value,
|
|
21
21
|
"googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
|
|
22
|
-
"googleRoutesProxyUrl": "/overseas/maps/routes/directions",
|
|
22
|
+
"googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
|
|
23
23
|
"themeVariables": {
|
|
24
24
|
// 默认主题
|
|
25
25
|
// TRAFFIC_UNKNOWN_BACKGROUND_COLOR: "#00C875",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
|
|
2
2
|
import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
|
|
3
|
+
const DEFAULT_GOOGLE_ROUTES_FIELDS = ["routes.polyline", "routes.legs"];
|
|
3
4
|
const ALL_ROUTES_STATUS = [
|
|
4
5
|
"OK",
|
|
5
6
|
"CANCELLED",
|
|
@@ -104,6 +105,7 @@ async function apiGoogleRoutes(props) {
|
|
|
104
105
|
const { protocol, host } = location;
|
|
105
106
|
const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
|
|
106
107
|
const url = new URL(proxyUrl, baseUrl);
|
|
108
|
+
url.searchParams.set("fields", DEFAULT_GOOGLE_ROUTES_FIELDS.join(","));
|
|
107
109
|
const response = await fetch(url, {
|
|
108
110
|
method: "POST",
|
|
109
111
|
headers: { "Content-Type": "application/json" },
|
|
@@ -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
|
};
|
|
@@ -9,10 +9,9 @@ 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 {
|
|
12
|
+
import { DrivingQuadraticBezierCurve } from "../DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js";
|
|
13
13
|
import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
|
|
14
14
|
import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
|
|
15
|
-
import { TrafficDrivingLine } from "../TrafficDrivingLine/TrafficDrivingLine.js";
|
|
16
15
|
const BUSINESS_QUOTING_FITVIEW_PANDING = [26, 26, 19, 26];
|
|
17
16
|
const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(props, {
|
|
18
17
|
emit,
|
|
@@ -85,39 +84,27 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
|
|
|
85
84
|
"on": {
|
|
86
85
|
"click": () => !disableStartPoint && emit("clickStartPoint", coordinatifyPlace(fromPlace))
|
|
87
86
|
}
|
|
88
|
-
}), h(
|
|
87
|
+
}), h(DrivingQuadraticBezierCurve, {
|
|
89
88
|
"attrs": {
|
|
90
|
-
"to": to,
|
|
91
89
|
"from": from,
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
})]
|
|
90
|
+
"to": to
|
|
91
|
+
}
|
|
92
|
+
}), h(StartEndPoint, {
|
|
93
|
+
"attrs": {
|
|
94
|
+
"type": "end",
|
|
95
|
+
"registerOverlay": fittableRegistryOverlay,
|
|
96
|
+
"position": to,
|
|
97
|
+
"title": toPlace.displayName,
|
|
98
|
+
"description": renderDescription({
|
|
99
|
+
distance: 0,
|
|
100
|
+
duration: 0,
|
|
101
|
+
tolls: 0
|
|
102
|
+
}),
|
|
103
|
+
"withArrow": !disableEndPoint,
|
|
104
|
+
"language": language
|
|
105
|
+
},
|
|
106
|
+
"on": {
|
|
107
|
+
"click": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
|
|
121
108
|
}
|
|
122
109
|
}), h(FitViewOnce, {
|
|
123
110
|
"attrs": {
|
package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts
ADDED
|
@@ -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>;
|
package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js
ADDED
|
@@ -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,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";
|
|
@@ -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
|
};
|
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.17.0-curve1";
|
|
4
4
|
const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
|
|
5
5
|
const enableSessionLogKey = (key) => {
|
|
6
6
|
const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
|
package/dist/v3/App.js
CHANGED
|
@@ -8,7 +8,7 @@ const amapApiKey = "fcb7b14c930354a248e21f4031dfa179";
|
|
|
8
8
|
const amapApiSecret = "11ad0e3d585b80d18b1ada5b0d947c4a";
|
|
9
9
|
const App = /* @__PURE__ */ defineComponent({
|
|
10
10
|
setup() {
|
|
11
|
-
const supplierRef = ref("
|
|
11
|
+
const supplierRef = ref("gmap");
|
|
12
12
|
window.supplierRef = supplierRef;
|
|
13
13
|
return () => createVNode(MapProvider, {
|
|
14
14
|
"amapKey": amapApiKey,
|
|
@@ -18,7 +18,7 @@ const App = /* @__PURE__ */ defineComponent({
|
|
|
18
18
|
"language": "en",
|
|
19
19
|
"supplier": supplierRef.value,
|
|
20
20
|
"googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
|
|
21
|
-
"googleRoutesProxyUrl": "/overseas/maps/routes/directions",
|
|
21
|
+
"googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
|
|
22
22
|
"themeVariables": {
|
|
23
23
|
// 默认主题
|
|
24
24
|
// TRAFFIC_UNKNOWN_BACKGROUND_COLOR: "#00C875",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
|
|
2
2
|
import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
|
|
3
|
+
const DEFAULT_GOOGLE_ROUTES_FIELDS = ["routes.polyline", "routes.legs"];
|
|
3
4
|
const ALL_ROUTES_STATUS = [
|
|
4
5
|
"OK",
|
|
5
6
|
"CANCELLED",
|
|
@@ -104,6 +105,7 @@ async function apiGoogleRoutes(props) {
|
|
|
104
105
|
const { protocol, host } = location;
|
|
105
106
|
const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
|
|
106
107
|
const url = new URL(proxyUrl, baseUrl);
|
|
108
|
+
url.searchParams.set("fields", DEFAULT_GOOGLE_ROUTES_FIELDS.join(","));
|
|
107
109
|
const response = await fetch(url, {
|
|
108
110
|
method: "POST",
|
|
109
111
|
headers: { "Content-Type": "application/json" },
|
|
@@ -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
|
}>>;
|
|
@@ -9,10 +9,9 @@ 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 {
|
|
12
|
+
import { DrivingQuadraticBezierCurve } from "../DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js";
|
|
13
13
|
import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
|
|
14
14
|
import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
|
|
15
|
-
import { TrafficDrivingLine } from "../TrafficDrivingLine/TrafficDrivingLine.js";
|
|
16
15
|
const BUSINESS_QUOTING_FITVIEW_PANDING = [26, 26, 19, 26];
|
|
17
16
|
const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(props, {
|
|
18
17
|
emit,
|
|
@@ -78,32 +77,22 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
|
|
|
78
77
|
"withArrow": !disableStartPoint,
|
|
79
78
|
"language": language,
|
|
80
79
|
"onClick": () => !disableStartPoint && emit("clickStartPoint", coordinatifyPlace(fromPlace))
|
|
81
|
-
}, null), createVNode(
|
|
82
|
-
"to": to,
|
|
80
|
+
}, null), createVNode(DrivingQuadraticBezierCurve, {
|
|
83
81
|
"from": from,
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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)]
|
|
82
|
+
"to": to
|
|
83
|
+
}, null), createVNode(StartEndPoint, {
|
|
84
|
+
"type": "end",
|
|
85
|
+
"registerOverlay": fittableRegistryOverlay,
|
|
86
|
+
"position": to,
|
|
87
|
+
"title": toPlace.displayName,
|
|
88
|
+
"description": renderDescription({
|
|
89
|
+
distance: 0,
|
|
90
|
+
duration: 0,
|
|
91
|
+
tolls: 0
|
|
92
|
+
}),
|
|
93
|
+
"withArrow": !disableEndPoint,
|
|
94
|
+
"language": language,
|
|
95
|
+
"onClick": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
|
|
107
96
|
}, null), createVNode(FitViewOnce, {
|
|
108
97
|
"registerOverlay": registerOverlay,
|
|
109
98
|
"immediate": true
|
package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts
ADDED
|
@@ -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
|
+
}>>;
|
package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js
ADDED
|
@@ -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,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";
|
|
@@ -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
|
};
|
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.17.0-curve1";
|
|
4
4
|
const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
|
|
5
5
|
const enableSessionLogKey = (key) => {
|
|
6
6
|
const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
|