@heycar/heycars-map 2.16.0-downgrade3 → 2.16.0-downgrade5

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 (44) hide show
  1. package/README.md +1 -0
  2. package/dist/v2/App.js +7 -6
  3. package/dist/v2/Demo/DemoBusinessQuoting.js +7 -6
  4. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +2 -1
  5. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +31 -5
  6. package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +10 -0
  7. package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +100 -0
  8. package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
  9. package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
  10. package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.d.ts +3 -0
  11. package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
  12. package/dist/v2/components/AmapBezierCurve/index.d.ts +1 -0
  13. package/dist/v2/components/AmapBezierCurve/index.js +4 -0
  14. package/dist/v2/components/MapProvider/MapProvider.d.ts +1 -1
  15. package/dist/v2/components/MapProvider/MapProvider.js +1 -1
  16. package/dist/v2/hooks/useMapPlace.js +10 -1
  17. package/dist/v2/hooks/useMapSupplier.d.ts +1 -0
  18. package/dist/v2/utils/compatibleWatchPosition.js +1 -0
  19. package/dist/v2/utils/geometryPolygon.d.ts +28 -0
  20. package/dist/v2/utils/geometryPolygon.js +57 -0
  21. package/dist/v2/utils/log.js +1 -1
  22. package/dist/v2/utils/typeChecking.js +1 -0
  23. package/dist/v3/App.js +7 -6
  24. package/dist/v3/Demo/DemoBusinessQuoting.js +7 -6
  25. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +4 -3
  26. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +25 -5
  27. package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +16 -0
  28. package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +94 -0
  29. package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
  30. package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
  31. package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.d.ts +7 -0
  32. package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
  33. package/dist/v3/components/AmapBezierCurve/index.d.ts +1 -0
  34. package/dist/v3/components/AmapBezierCurve/index.js +4 -0
  35. package/dist/v3/components/MapProvider/MapProvider.d.ts +2 -1
  36. package/dist/v3/components/MapProvider/MapProvider.js +1 -1
  37. package/dist/v3/hooks/useMapPlace.js +10 -1
  38. package/dist/v3/hooks/useMapSupplier.d.ts +1 -0
  39. package/dist/v3/utils/compatibleWatchPosition.js +1 -0
  40. package/dist/v3/utils/geometryPolygon.d.ts +28 -0
  41. package/dist/v3/utils/geometryPolygon.js +57 -0
  42. package/dist/v3/utils/log.js +1 -1
  43. package/dist/v3/utils/typeChecking.js +1 -0
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -583,6 +583,7 @@ export default defineComponent({
583
583
  <div>
584
584
  <BusinessQuotingMap
585
585
  class={"demo"}
586
+ isBezierCurve
586
587
  from={{
587
588
  displayName: "The Malayan Council",
588
589
  name: "10 Winstedt Rd, #01-17, Singapore 227977",
package/dist/v2/App.js CHANGED
@@ -2,13 +2,13 @@ import { h } from "vue";
2
2
  import { defineComponent, ref } from "vue-demi";
3
3
  import { MapProvider } from "./components/MapProvider/MapProvider.js";
4
4
  import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace.js";
5
- const gmapApiKey = "AIzaSyCCOe8MAeS3EYvSraKsBX6ztVyLxj69z94";
6
- const gmapId = "d0af0c05331af64a";
7
- const amapApiKey = "fcb7b14c930354a248e21f4031dfa179";
8
- const amapApiSecret = "11ad0e3d585b80d18b1ada5b0d947c4a";
5
+ const gmapApiKey = {}.VITE_GMAP_API_KEY;
6
+ const gmapId = {}.VITE_GMAP_MAP_ID;
7
+ const amapApiKey = {}.VITE_AMAP_API_KEY;
8
+ const amapApiSecret = {}.VITE_AMAP_API_SECRET;
9
9
  const App = defineComponent({
10
10
  setup() {
11
- const supplierRef = ref("gmap");
11
+ const supplierRef = ref("amap");
12
12
  window.supplierRef = supplierRef;
13
13
  return () => h(MapProvider, {
14
14
  "attrs": {
@@ -42,7 +42,8 @@ const App = defineComponent({
42
42
  // ZONE_FORBIDDEN_BORDER_COLOR: "#F41717",
43
43
  },
44
44
  "renderLoadFailedTitle": () => supplierRef.value === "gmap" ? "未能成功访问谷歌地图" : "高德地图加载失败",
45
- "renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0
45
+ "renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0,
46
+ "reportLog": () => console.log("reportLog function is called")
46
47
  },
47
48
  "on": {
48
49
  "success": () => console.log(`${supplierRef.value} load success`),
@@ -20,9 +20,9 @@ const DemoBusinessQuoting = defineComponent({
20
20
  from: {
21
21
  displayName: "my",
22
22
  name: "my",
23
- type: "wgs84",
24
- lat: 1.311295,
25
- lng: 103.841974
23
+ type: "gcj02",
24
+ lat: 31.205478,
25
+ lng: 121.409535
26
26
  }
27
27
  };
28
28
  },
@@ -47,12 +47,13 @@ const DemoBusinessQuoting = defineComponent({
47
47
  "class": demo,
48
48
  "attrs": {
49
49
  "from": from,
50
+ "isBezierCurve": true,
50
51
  "to": {
51
52
  displayName: "CDG Engie Charging Station",
52
53
  name: "21 Kent Ridge Rd, Singapore 119220",
53
- type: "wgs84",
54
- lat: 1.2966426,
55
- lng: 103.7763939
54
+ type: "gcj02",
55
+ lat: 31.207082,
56
+ lng: 121.407967
56
57
  },
57
58
  "fromDescription": "您将在此上车",
58
59
  "renderDescription": ({
@@ -7,6 +7,7 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
7
7
  to: CoordinatePlace;
8
8
  fromDescription: string;
9
9
  log?: boolean;
10
+ isBezierCurve?: boolean;
10
11
  disableStartPoint?: boolean;
11
12
  disableEndPoint?: boolean;
12
13
  mapContext: CoordinatifyProps<BusinessQuotingContext>;
@@ -14,7 +15,7 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
14
15
  distance: number;
15
16
  duration: number;
16
17
  tolls?: number;
17
- }) => string;
18
+ }) => string | undefined;
18
19
  onClickStartPoint?: (value: CoordinatePlace) => void;
19
20
  onClickEndPoint?: (value: CoordinatePlace) => void;
20
21
  };
@@ -7,8 +7,10 @@ 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";
13
+ import { DrivingQuadraticBezierCurve } from "../DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js";
12
14
  import { DrivingRoute } from "../DrivingRoute/DrivingRoute.js";
13
15
  import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
14
16
  import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
@@ -55,12 +57,14 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
55
57
  to: inputToPlace,
56
58
  fromDescription,
57
59
  disableStartPoint,
58
- disableEndPoint
60
+ disableEndPoint,
61
+ isBezierCurve
59
62
  } = props;
60
63
  const fromPlace = unCoordinatifyPlace(toCoordinatePlaceType(inputFromPlace));
61
64
  const toPlace = unCoordinatifyPlace(toCoordinatePlaceType(inputToPlace));
62
65
  const from = place2point(fromPlace);
63
66
  const to = place2point(toPlace);
67
+ const distance = distanceBetweenTwoPoints(from, to);
64
68
  return h(HeycarMap, {
65
69
  "class": attrs.class,
66
70
  "style": attrs.style,
@@ -85,13 +89,35 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
85
89
  "on": {
86
90
  "click": () => !disableStartPoint && emit("clickStartPoint", coordinatifyPlace(fromPlace))
87
91
  }
88
- }), h(DrivingRoute, {
92
+ }), isBezierCurve && h(DrivingQuadraticBezierCurve, {
93
+ "attrs": {
94
+ "from": from,
95
+ "to": to
96
+ }
97
+ }), isBezierCurve ? h(StartEndPoint, {
98
+ "attrs": {
99
+ "type": "end",
100
+ "registerOverlay": fittableRegistryOverlay,
101
+ "position": to,
102
+ "title": toPlace.displayName,
103
+ "description": renderDescription({
104
+ distance,
105
+ duration: 0,
106
+ tolls: 0
107
+ }),
108
+ "withArrow": !disableEndPoint,
109
+ "language": language
110
+ },
111
+ "on": {
112
+ "click": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
113
+ }
114
+ }) : h(DrivingRoute, {
89
115
  "attrs": {
90
116
  "to": to,
91
117
  "from": from,
92
118
  "render": ({
93
119
  path,
94
- distance,
120
+ distance: distance2,
95
121
  duration,
96
122
  tolls,
97
123
  trafficJams
@@ -107,7 +133,7 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
107
133
  "position": to,
108
134
  "title": toPlace.displayName,
109
135
  "description": renderDescription({
110
- distance,
136
+ distance: distance2,
111
137
  duration,
112
138
  tolls
113
139
  }),
@@ -144,7 +170,7 @@ const BusinessQuotingMap = defineLagecySetup("BusinessQuotingMap", function(prop
144
170
  key: `${payload.supplier}${instanceNo}`,
145
171
  on: generateCreateElementV2PropsOn(props, emit, ["clickStartPoint", "clickEndPoint"])
146
172
  });
147
- }).props(["fallback", "from", "loading", "disableStartPoint", "disableEndPoint", "mapContext", "renderDescription", "to", "fromDescription", "log"]);
173
+ }).props(["fallback", "from", "loading", "disableStartPoint", "disableEndPoint", "mapContext", "renderDescription", "to", "fromDescription", "log", "isBezierCurve"]);
148
174
  export {
149
175
  BusinessQuotingMap,
150
176
  BusinessQuotingMapInner
@@ -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 createQuadraticBezierCurvePoints(from, to, controlPoint);
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
+ };
@@ -5,7 +5,7 @@ import { type GmapLoaderProps, type UseMapLoaderProps } from "../../hooks/useMap
5
5
  import { type MapSupplierPayolad } from "../../hooks/useMapSupplier";
6
6
  import type { AmapMap } from "../../types/interface";
7
7
  import { type AmapProps } from "../Amap";
8
- export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "hkGovernRegeoProxyUrl">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl">;
9
9
  export declare const MapProvider: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<MapProviderProps>, 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<MapProviderProps, Required<MapProviderProps>>, "success" | "fail" | "downloadOptimizeEnd", MapProviderProps>;
10
10
  export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
11
11
  mapRef?: SetMap<AmapMap> | SetMap<google.maps.Map>;
@@ -50,7 +50,7 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
50
50
  var _a;
51
51
  return h("div", [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
52
52
  };
53
- }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "hkGovernRegeoProxyUrl"]);
53
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl"]);
54
54
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
55
55
  slots,
56
56
  emit,
@@ -128,7 +128,7 @@ const useGmapPlace = (props) => {
128
128
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
129
129
  const defaultPoint = [...props.pointRef.value];
130
130
  const pointRef = ref(defaultPoint);
131
- const { readyPromise, language } = useMapSupplier();
131
+ const { readyPromise, language, reportLog } = useMapSupplier();
132
132
  const { idx: placeKey, update } = useUpdate();
133
133
  const place = reactive({
134
134
  lng: pointRef.value[0],
@@ -159,6 +159,15 @@ const useGmapPlace = (props) => {
159
159
  readyPromise.then(() => {
160
160
  const geocoder = new google.maps.Geocoder();
161
161
  const pipeTw = createPipeTw(language === "zh-TW");
162
+ reportLog == null ? void 0 : reportLog({
163
+ operation: "google_regeo",
164
+ eventType: "ServiceLogic",
165
+ message: {
166
+ lng,
167
+ lat,
168
+ language
169
+ }
170
+ });
162
171
  geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
163
172
  const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
164
173
  const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
@@ -16,6 +16,7 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
16
16
  themeVariables?: MapThemeVariables;
17
17
  renderLoadFailedTitle?: (status: Status) => string | undefined;
18
18
  renderLoadFailedDescription?: (status: Status) => string | undefined;
19
+ reportLog?: (data: any) => void;
19
20
  }
20
21
  export declare const useMapSupplier: () => MapSupplierPayolad;
21
22
  export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
@@ -219,6 +219,7 @@ function androidWatchPosition(onSuccess, onError, option, getLocationFn) {
219
219
  if (isHandled)
220
220
  return;
221
221
  isHandled = true;
222
+ console.log("==GeoLocation assert==", geoLocationPosition, typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function");
222
223
  geoErrorMessage = void 0;
223
224
  resolve(geoLocationPosition);
224
225
  },
@@ -10,3 +10,31 @@ export declare const distanceTwoHK80Points: (from: Point, to: Point) => number;
10
10
  * 计算折线(按顺序连接各点)总长度。
11
11
  */
12
12
  export declare const computeLineLength: (line: Point[]) => number;
13
+ /**
14
+ * 计算从起点指向终点的初始方位角(heading)。
15
+ * 说明:
16
+ * - 基于球面大圆航线计算(WGS84 半径近似),与常见地图 SDK 的 heading 含义一致
17
+ * - 返回范围为 [-180, 180](度):0 表示正北,正值为东偏北,负值为西偏南
18
+ * - 起终点经纬完全相同返回 0
19
+ * @returns 初始方位角(度)
20
+ */
21
+ export declare const computeLineAngle: (from: Point, to: Point) => number;
22
+ /**
23
+ * 根据指定的基线 (A -> B) 和底角 (angle),计算一个等腰三角形位于基线左侧的顶点。
24
+ *
25
+ * @param A 三角形基线的起始点, 格式为 [x, y]。
26
+ * @param B 三角形基线的终点, 格式为 [x, y]。
27
+ * @param angle 等腰三角形的底角 (∠PAB) 的大小,单位为角度 (degrees)。有效范围为 (-90, 90)。
28
+ * @returns 返回计算出的顶点 P 的坐标 [x, y];如果输入无效(例如 A、B 为同一点或 angle 超出范围),则返回 null。
29
+ */
30
+ export declare const calculateLeftIsoscelesVertex: (A: Point, B: Point, angle: number) => Point;
31
+ /**
32
+ * 根据给定的起始点、结束点和控制点,生成二次贝塞尔曲线的模拟点。
33
+ *
34
+ * @param from 起始点
35
+ * @param to 结束点
36
+ * @param controlPoint 控制点
37
+ * @param amount 要生成的模拟点的数量
38
+ * @returns 返回一个包含模拟点坐标的数组
39
+ */
40
+ export declare const createQuadraticBezierCurvePoints: (from: Point, to: Point, controlPoint: Point, amount?: number) => Point[];
@@ -54,8 +54,65 @@ const computeLineLength = (line) => {
54
54
  }
55
55
  return totalLength;
56
56
  };
57
+ const computeLineAngle = (from, to) => {
58
+ const [lng1, lat1] = from;
59
+ const [lng2, lat2] = to;
60
+ if (lng1 === lng2 && lat1 === lat2)
61
+ return 0;
62
+ const toRad = (deg) => deg * Math.PI / 180;
63
+ const toDeg = (rad) => rad * 180 / Math.PI;
64
+ const phi1 = toRad(lat1);
65
+ const phi2 = toRad(lat2);
66
+ const lambda1 = toRad(lng1);
67
+ const lambda2 = toRad(lng2);
68
+ const deltaLambda = lambda2 - lambda1;
69
+ const y = Math.sin(deltaLambda) * Math.cos(phi2);
70
+ const x = Math.cos(phi1) * Math.sin(phi2) - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda);
71
+ let heading = toDeg(Math.atan2(y, x));
72
+ heading = (heading + 540) % 360 - 180;
73
+ return heading;
74
+ };
75
+ const calculateLeftIsoscelesVertex = (A, B, angle) => {
76
+ const [x1, y1] = A;
77
+ const [x2, y2] = B;
78
+ const thetaInRadians = angle * Math.PI / 180;
79
+ const dx = x2 - x1;
80
+ const dy = y2 - y1;
81
+ if (dx === 0 && dy === 0)
82
+ return [x1, y1];
83
+ const midpointM = [(x1 + x2) / 2, (y1 + y2) / 2];
84
+ const tanTheta = Math.tan(thetaInRadians);
85
+ const vecMP_x = -0.5 * dy * tanTheta;
86
+ const vecMP_y = 0.5 * dx * tanTheta;
87
+ return [midpointM[0] + vecMP_x, midpointM[1] + vecMP_y];
88
+ };
89
+ const createQuadraticBezierCurvePoints = (from, to, controlPoint, amount = 50) => {
90
+ const points = [];
91
+ if (amount <= 0) {
92
+ return [];
93
+ }
94
+ if (amount === 1) {
95
+ return [from];
96
+ }
97
+ const [p0_x, p0_y] = from;
98
+ const [p1_x, p1_y] = controlPoint;
99
+ const [p2_x, p2_y] = to;
100
+ for (let i = 0; i < amount; i++) {
101
+ const t = i / (amount - 1);
102
+ const one_minus_t = 1 - t;
103
+ const t_squared = t * t;
104
+ const one_minus_t_squared = one_minus_t * one_minus_t;
105
+ const x = one_minus_t_squared * p0_x + 2 * one_minus_t * t * p1_x + t_squared * p2_x;
106
+ const y = one_minus_t_squared * p0_y + 2 * one_minus_t * t * p1_y + t_squared * p2_y;
107
+ points.push([x, y]);
108
+ }
109
+ return points;
110
+ };
57
111
  export {
112
+ calculateLeftIsoscelesVertex,
113
+ computeLineAngle,
58
114
  computeLineLength,
115
+ createQuadraticBezierCurvePoints,
59
116
  distanceBetweenTwoPoints,
60
117
  distanceTwoHK80Points,
61
118
  pointInPolygon
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.16.0-downgrade3";
3
+ const pkgVersion = "2.16.0-downgrade5";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
@@ -150,6 +150,7 @@ function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
150
150
  });
151
151
  return;
152
152
  }
153
+ console.log("==外部注入 geoPosition==", position);
153
154
  onSuccess(position);
154
155
  };
155
156
  const asseertedOnError = (error) => onError(toGeolocationPositionError(error, prefix));
package/dist/v3/App.js CHANGED
@@ -2,13 +2,13 @@ import { createVNode } from "vue";
2
2
  import { defineComponent, ref } from "vue-demi";
3
3
  import { MapProvider } from "./components/MapProvider/MapProvider.js";
4
4
  import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace.js";
5
- const gmapApiKey = "AIzaSyCCOe8MAeS3EYvSraKsBX6ztVyLxj69z94";
6
- const gmapId = "d0af0c05331af64a";
7
- const amapApiKey = "fcb7b14c930354a248e21f4031dfa179";
8
- const amapApiSecret = "11ad0e3d585b80d18b1ada5b0d947c4a";
5
+ const gmapApiKey = {}.VITE_GMAP_API_KEY;
6
+ const gmapId = {}.VITE_GMAP_MAP_ID;
7
+ const amapApiKey = {}.VITE_AMAP_API_KEY;
8
+ const amapApiSecret = {}.VITE_AMAP_API_SECRET;
9
9
  const App = /* @__PURE__ */ defineComponent({
10
10
  setup() {
11
- const supplierRef = ref("gmap");
11
+ const supplierRef = ref("amap");
12
12
  window.supplierRef = supplierRef;
13
13
  return () => createVNode(MapProvider, {
14
14
  "amapKey": amapApiKey,
@@ -44,7 +44,8 @@ const App = /* @__PURE__ */ defineComponent({
44
44
  "renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0,
45
45
  "onSuccess": () => console.log(`${supplierRef.value} load success`),
46
46
  "onFail": () => console.log(`${supplierRef.value} load failed`),
47
- "onDownloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`)
47
+ "onDownloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`),
48
+ "reportLog": () => console.log("reportLog function is called")
48
49
  }, {
49
50
  default: () => [createVNode(DemoBusinessRecomendPlace, null, null)]
50
51
  });
@@ -20,9 +20,9 @@ const DemoBusinessQuoting = /* @__PURE__ */ defineComponent({
20
20
  from: {
21
21
  displayName: "my",
22
22
  name: "my",
23
- type: "wgs84",
24
- lat: 1.311295,
25
- lng: 103.841974
23
+ type: "gcj02",
24
+ lat: 31.205478,
25
+ lng: 121.409535
26
26
  }
27
27
  };
28
28
  },
@@ -46,12 +46,13 @@ const DemoBusinessQuoting = /* @__PURE__ */ defineComponent({
46
46
  return createVNode("div", null, [createVNode(BusinessQuotingMap, {
47
47
  "class": demo,
48
48
  "from": from,
49
+ "isBezierCurve": true,
49
50
  "to": {
50
51
  displayName: "CDG Engie Charging Station",
51
52
  name: "21 Kent Ridge Rd, Singapore 119220",
52
- type: "wgs84",
53
- lat: 1.2966426,
54
- lng: 103.7763939
53
+ type: "gcj02",
54
+ lat: 31.207082,
55
+ lng: 121.407967
55
56
  },
56
57
  "fromDescription": "您将在此上车",
57
58
  "renderDescription": ({
@@ -7,6 +7,7 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
7
7
  to: CoordinatePlace;
8
8
  fromDescription: string;
9
9
  log?: boolean;
10
+ isBezierCurve?: boolean;
10
11
  disableStartPoint?: boolean;
11
12
  disableEndPoint?: boolean;
12
13
  mapContext: CoordinatifyProps<BusinessQuotingContext>;
@@ -14,7 +15,7 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
14
15
  distance: number;
15
16
  duration: number;
16
17
  tolls?: number;
17
- }) => string;
18
+ }) => string | undefined;
18
19
  onClickStartPoint?: (value: CoordinatePlace) => void;
19
20
  onClickEndPoint?: (value: CoordinatePlace) => void;
20
21
  };
@@ -26,7 +27,7 @@ export declare const BusinessQuotingMapInner: import("@vue/runtime-core").Define
26
27
  distance: number;
27
28
  duration: number;
28
29
  tolls?: number;
29
- }) => string;
30
+ }) => string | undefined;
30
31
  } & {
31
32
  default?: import("../../demi-polyfill").Slot | undefined;
32
33
  }>>;
@@ -38,7 +39,7 @@ export declare const BusinessQuotingMap: import("@vue/runtime-core").DefineCompo
38
39
  distance: number;
39
40
  duration: number;
40
41
  tolls?: number;
41
- }) => string;
42
+ }) => string | undefined;
42
43
  } & {
43
44
  default?: import("../../demi-polyfill").Slot | undefined;
44
45
  }>>;
@@ -7,8 +7,10 @@ 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";
13
+ import { DrivingQuadraticBezierCurve } from "../DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js";
12
14
  import { DrivingRoute } from "../DrivingRoute/DrivingRoute.js";
13
15
  import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
14
16
  import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
@@ -55,12 +57,14 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
55
57
  to: inputToPlace,
56
58
  fromDescription,
57
59
  disableStartPoint,
58
- disableEndPoint
60
+ disableEndPoint,
61
+ isBezierCurve
59
62
  } = props;
60
63
  const fromPlace = unCoordinatifyPlace(toCoordinatePlaceType(inputFromPlace));
61
64
  const toPlace = unCoordinatifyPlace(toCoordinatePlaceType(inputToPlace));
62
65
  const from = place2point(fromPlace);
63
66
  const to = place2point(toPlace);
67
+ const distance = distanceBetweenTwoPoints(from, to);
64
68
  return createVNode(HeycarMap, {
65
69
  "class": attrs.class,
66
70
  "style": attrs.style,
@@ -78,12 +82,28 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
78
82
  "withArrow": !disableStartPoint,
79
83
  "language": language,
80
84
  "onClick": () => !disableStartPoint && emit("clickStartPoint", coordinatifyPlace(fromPlace))
81
- }, null), createVNode(DrivingRoute, {
85
+ }, null), isBezierCurve && createVNode(DrivingQuadraticBezierCurve, {
86
+ "from": from,
87
+ "to": to
88
+ }, null), isBezierCurve ? createVNode(StartEndPoint, {
89
+ "type": "end",
90
+ "registerOverlay": fittableRegistryOverlay,
91
+ "position": to,
92
+ "title": toPlace.displayName,
93
+ "description": renderDescription({
94
+ distance,
95
+ duration: 0,
96
+ tolls: 0
97
+ }),
98
+ "withArrow": !disableEndPoint,
99
+ "language": language,
100
+ "onClick": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
101
+ }, null) : createVNode(DrivingRoute, {
82
102
  "to": to,
83
103
  "from": from,
84
104
  "render": ({
85
105
  path,
86
- distance,
106
+ distance: distance2,
87
107
  duration,
88
108
  tolls,
89
109
  trafficJams
@@ -96,7 +116,7 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
96
116
  "position": to,
97
117
  "title": toPlace.displayName,
98
118
  "description": renderDescription({
99
- distance,
119
+ distance: distance2,
100
120
  duration,
101
121
  tolls
102
122
  }),
@@ -128,7 +148,7 @@ const BusinessQuotingMap = defineLagecySetup("BusinessQuotingMap", function(prop
128
148
  key: `${payload.supplier}${instanceNo}`,
129
149
  on: generateCreateElementV2PropsOn(props, emit, ["clickStartPoint", "clickEndPoint"])
130
150
  });
131
- }).props(["fallback", "from", "loading", "disableStartPoint", "disableEndPoint", "mapContext", "renderDescription", "to", "fromDescription", "log"]);
151
+ }).props(["fallback", "from", "loading", "disableStartPoint", "disableEndPoint", "mapContext", "renderDescription", "to", "fromDescription", "log", "isBezierCurve"]);
132
152
  export {
133
153
  BusinessQuotingMap,
134
154
  BusinessQuotingMapInner
@@ -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 createQuadraticBezierCurvePoints(from, to, controlPoint);
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
+ };
@@ -5,10 +5,11 @@ import { Status, type GmapLoaderProps, type UseMapLoaderProps } from "../../hook
5
5
  import { type MapSupplierPayolad } from "../../hooks/useMapSupplier";
6
6
  import type { AmapMap } from "../../types/interface";
7
7
  import { type AmapProps } from "../Amap";
8
- export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "hkGovernRegeoProxyUrl">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl">;
9
9
  export declare const MapProvider: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<MapProviderProps>, 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<MapProviderProps, Required<MapProviderProps>>, "success" | "fail" | "downloadOptimizeEnd", import("vue-demi").PublicProps, MapProviderProps, MapProviderProps, import("vue-demi").SlotsType<{
10
10
  renderLoadFailedTitle?: ((status: Status) => string | undefined) | undefined;
11
11
  renderLoadFailedDescription?: ((status: Status) => string | undefined) | undefined;
12
+ reportLog?: ((data: any) => void) | undefined;
12
13
  } & {
13
14
  default?: import("../../demi-polyfill").Slot | undefined;
14
15
  }>>;
@@ -53,7 +53,7 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
53
53
  var _a;
54
54
  return createVNode("div", null, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
55
55
  };
56
- }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "hkGovernRegeoProxyUrl"]);
56
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl"]);
57
57
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
58
58
  slots,
59
59
  emit,
@@ -128,7 +128,7 @@ const useGmapPlace = (props) => {
128
128
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
129
129
  const defaultPoint = [...props.pointRef.value];
130
130
  const pointRef = ref(defaultPoint);
131
- const { readyPromise, language } = useMapSupplier();
131
+ const { readyPromise, language, reportLog } = useMapSupplier();
132
132
  const { idx: placeKey, update } = useUpdate();
133
133
  const place = reactive({
134
134
  lng: pointRef.value[0],
@@ -159,6 +159,15 @@ const useGmapPlace = (props) => {
159
159
  readyPromise.then(() => {
160
160
  const geocoder = new google.maps.Geocoder();
161
161
  const pipeTw = createPipeTw(language === "zh-TW");
162
+ reportLog == null ? void 0 : reportLog({
163
+ operation: "google_regeo",
164
+ eventType: "ServiceLogic",
165
+ message: {
166
+ lng,
167
+ lat,
168
+ language
169
+ }
170
+ });
162
171
  geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
163
172
  const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
164
173
  const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
@@ -16,6 +16,7 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
16
16
  themeVariables?: MapThemeVariables;
17
17
  renderLoadFailedTitle?: (status: Status) => string | undefined;
18
18
  renderLoadFailedDescription?: (status: Status) => string | undefined;
19
+ reportLog?: (data: any) => void;
19
20
  }
20
21
  export declare const useMapSupplier: () => MapSupplierPayolad;
21
22
  export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
@@ -219,6 +219,7 @@ function androidWatchPosition(onSuccess, onError, option, getLocationFn) {
219
219
  if (isHandled)
220
220
  return;
221
221
  isHandled = true;
222
+ console.log("==GeoLocation assert==", geoLocationPosition, typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function");
222
223
  geoErrorMessage = void 0;
223
224
  resolve(geoLocationPosition);
224
225
  },
@@ -10,3 +10,31 @@ export declare const distanceTwoHK80Points: (from: Point, to: Point) => number;
10
10
  * 计算折线(按顺序连接各点)总长度。
11
11
  */
12
12
  export declare const computeLineLength: (line: Point[]) => number;
13
+ /**
14
+ * 计算从起点指向终点的初始方位角(heading)。
15
+ * 说明:
16
+ * - 基于球面大圆航线计算(WGS84 半径近似),与常见地图 SDK 的 heading 含义一致
17
+ * - 返回范围为 [-180, 180](度):0 表示正北,正值为东偏北,负值为西偏南
18
+ * - 起终点经纬完全相同返回 0
19
+ * @returns 初始方位角(度)
20
+ */
21
+ export declare const computeLineAngle: (from: Point, to: Point) => number;
22
+ /**
23
+ * 根据指定的基线 (A -> B) 和底角 (angle),计算一个等腰三角形位于基线左侧的顶点。
24
+ *
25
+ * @param A 三角形基线的起始点, 格式为 [x, y]。
26
+ * @param B 三角形基线的终点, 格式为 [x, y]。
27
+ * @param angle 等腰三角形的底角 (∠PAB) 的大小,单位为角度 (degrees)。有效范围为 (-90, 90)。
28
+ * @returns 返回计算出的顶点 P 的坐标 [x, y];如果输入无效(例如 A、B 为同一点或 angle 超出范围),则返回 null。
29
+ */
30
+ export declare const calculateLeftIsoscelesVertex: (A: Point, B: Point, angle: number) => Point;
31
+ /**
32
+ * 根据给定的起始点、结束点和控制点,生成二次贝塞尔曲线的模拟点。
33
+ *
34
+ * @param from 起始点
35
+ * @param to 结束点
36
+ * @param controlPoint 控制点
37
+ * @param amount 要生成的模拟点的数量
38
+ * @returns 返回一个包含模拟点坐标的数组
39
+ */
40
+ export declare const createQuadraticBezierCurvePoints: (from: Point, to: Point, controlPoint: Point, amount?: number) => Point[];
@@ -54,8 +54,65 @@ const computeLineLength = (line) => {
54
54
  }
55
55
  return totalLength;
56
56
  };
57
+ const computeLineAngle = (from, to) => {
58
+ const [lng1, lat1] = from;
59
+ const [lng2, lat2] = to;
60
+ if (lng1 === lng2 && lat1 === lat2)
61
+ return 0;
62
+ const toRad = (deg) => deg * Math.PI / 180;
63
+ const toDeg = (rad) => rad * 180 / Math.PI;
64
+ const phi1 = toRad(lat1);
65
+ const phi2 = toRad(lat2);
66
+ const lambda1 = toRad(lng1);
67
+ const lambda2 = toRad(lng2);
68
+ const deltaLambda = lambda2 - lambda1;
69
+ const y = Math.sin(deltaLambda) * Math.cos(phi2);
70
+ const x = Math.cos(phi1) * Math.sin(phi2) - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda);
71
+ let heading = toDeg(Math.atan2(y, x));
72
+ heading = (heading + 540) % 360 - 180;
73
+ return heading;
74
+ };
75
+ const calculateLeftIsoscelesVertex = (A, B, angle) => {
76
+ const [x1, y1] = A;
77
+ const [x2, y2] = B;
78
+ const thetaInRadians = angle * Math.PI / 180;
79
+ const dx = x2 - x1;
80
+ const dy = y2 - y1;
81
+ if (dx === 0 && dy === 0)
82
+ return [x1, y1];
83
+ const midpointM = [(x1 + x2) / 2, (y1 + y2) / 2];
84
+ const tanTheta = Math.tan(thetaInRadians);
85
+ const vecMP_x = -0.5 * dy * tanTheta;
86
+ const vecMP_y = 0.5 * dx * tanTheta;
87
+ return [midpointM[0] + vecMP_x, midpointM[1] + vecMP_y];
88
+ };
89
+ const createQuadraticBezierCurvePoints = (from, to, controlPoint, amount = 50) => {
90
+ const points = [];
91
+ if (amount <= 0) {
92
+ return [];
93
+ }
94
+ if (amount === 1) {
95
+ return [from];
96
+ }
97
+ const [p0_x, p0_y] = from;
98
+ const [p1_x, p1_y] = controlPoint;
99
+ const [p2_x, p2_y] = to;
100
+ for (let i = 0; i < amount; i++) {
101
+ const t = i / (amount - 1);
102
+ const one_minus_t = 1 - t;
103
+ const t_squared = t * t;
104
+ const one_minus_t_squared = one_minus_t * one_minus_t;
105
+ const x = one_minus_t_squared * p0_x + 2 * one_minus_t * t * p1_x + t_squared * p2_x;
106
+ const y = one_minus_t_squared * p0_y + 2 * one_minus_t * t * p1_y + t_squared * p2_y;
107
+ points.push([x, y]);
108
+ }
109
+ return points;
110
+ };
57
111
  export {
112
+ calculateLeftIsoscelesVertex,
113
+ computeLineAngle,
58
114
  computeLineLength,
115
+ createQuadraticBezierCurvePoints,
59
116
  distanceBetweenTwoPoints,
60
117
  distanceTwoHK80Points,
61
118
  pointInPolygon
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.16.0-downgrade3";
3
+ const pkgVersion = "2.16.0-downgrade5";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
@@ -150,6 +150,7 @@ function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
150
150
  });
151
151
  return;
152
152
  }
153
+ console.log("==外部注入 geoPosition==", position);
153
154
  onSuccess(position);
154
155
  };
155
156
  const asseertedOnError = (error) => onError(toGeolocationPositionError(error, prefix));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.16.0-downgrade3",
3
+ "version": "2.16.0-downgrade5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",