@heycar/heycars-map 2.16.0-downgrade2 → 2.16.0-downgrade4

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 (64) 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/Demo/DemoBusinessRecomendPlace.js +2 -2
  5. package/dist/v2/api/contants.d.ts +2 -0
  6. package/dist/v2/api/contants.js +4 -0
  7. package/dist/v2/api/hongkongGovernDriving.d.ts +7 -0
  8. package/dist/v2/api/hongkongGovernDriving.js +31 -0
  9. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +2 -1
  10. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +31 -5
  11. package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +10 -0
  12. package/dist/v2/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +100 -0
  13. package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
  14. package/dist/v2/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
  15. package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.d.ts +3 -0
  16. package/dist/v2/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
  17. package/dist/v2/components/AmapBezierCurve/index.d.ts +1 -0
  18. package/dist/v2/components/AmapBezierCurve/index.js +4 -0
  19. package/dist/v2/components/MapProvider/MapProvider.d.ts +1 -1
  20. package/dist/v2/components/MapProvider/MapProvider.js +1 -1
  21. package/dist/v2/hooks/useMapPlace.js +52 -6
  22. package/dist/v2/hooks/useMapRecomendPlace.js +1 -0
  23. package/dist/v2/hooks/useMapSupplier.d.ts +1 -0
  24. package/dist/v2/utils/geometryPolygon.d.ts +29 -0
  25. package/dist/v2/utils/geometryPolygon.js +65 -0
  26. package/dist/v2/utils/helper.d.ts +1 -0
  27. package/dist/v2/utils/helper.js +14 -0
  28. package/dist/v2/utils/hongkongGovernGeoCoder.d.ts +46 -0
  29. package/dist/v2/utils/hongkongGovernGeoCoder.js +134 -0
  30. package/dist/v2/utils/log.js +1 -1
  31. package/dist/v2/utils/transform.d.ts +15 -1
  32. package/dist/v2/utils/transform.js +81 -0
  33. package/dist/v3/App.js +7 -6
  34. package/dist/v3/Demo/DemoBusinessQuoting.js +7 -6
  35. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +2 -2
  36. package/dist/v3/api/contants.d.ts +2 -0
  37. package/dist/v3/api/contants.js +4 -0
  38. package/dist/v3/api/hongkongGovernDriving.d.ts +7 -0
  39. package/dist/v3/api/hongkongGovernDriving.js +31 -0
  40. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +4 -3
  41. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +25 -5
  42. package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.d.ts +16 -0
  43. package/dist/v3/business-components/DrivingQuadraticBezierCurve/DrivingQuadraticBezierCurve.js +94 -0
  44. package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.d.ts +1 -0
  45. package/dist/v3/business-components/DrivingQuadraticBezierCurve/index.js +6 -0
  46. package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.d.ts +7 -0
  47. package/dist/v3/components/AmapBezierCurve/AmapBezierCurve.js +57 -0
  48. package/dist/v3/components/AmapBezierCurve/index.d.ts +1 -0
  49. package/dist/v3/components/AmapBezierCurve/index.js +4 -0
  50. package/dist/v3/components/MapProvider/MapProvider.d.ts +1 -1
  51. package/dist/v3/components/MapProvider/MapProvider.js +1 -1
  52. package/dist/v3/hooks/useMapPlace.js +52 -6
  53. package/dist/v3/hooks/useMapRecomendPlace.js +1 -0
  54. package/dist/v3/hooks/useMapSupplier.d.ts +1 -0
  55. package/dist/v3/utils/geometryPolygon.d.ts +29 -0
  56. package/dist/v3/utils/geometryPolygon.js +65 -0
  57. package/dist/v3/utils/helper.d.ts +1 -0
  58. package/dist/v3/utils/helper.js +14 -0
  59. package/dist/v3/utils/hongkongGovernGeoCoder.d.ts +46 -0
  60. package/dist/v3/utils/hongkongGovernGeoCoder.js +134 -0
  61. package/dist/v3/utils/log.js +1 -1
  62. package/dist/v3/utils/transform.d.ts +15 -1
  63. package/dist/v3/utils/transform.js +81 -0
  64. 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
@@ -1,14 +1,14 @@
1
1
  import { h } from "vue";
2
2
  import { defineComponent, ref } from "vue-demi";
3
- import { DemoBusinessQuoting } from "./Demo/DemoBusinessQuoting.js";
4
3
  import { MapProvider } from "./components/MapProvider/MapProvider.js";
5
- const gmapApiKey = "AIzaSyCCOe8MAeS3EYvSraKsBX6ztVyLxj69z94";
6
- const gmapId = "d0af0c05331af64a";
7
- const amapApiKey = "fcb7b14c930354a248e21f4031dfa179";
8
- const amapApiSecret = "11ad0e3d585b80d18b1ada5b0d947c4a";
4
+ import { DemoBusinessQuoting } from "./Demo/DemoBusinessQuoting.js";
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": {
@@ -18,6 +18,7 @@ const App = defineComponent({
18
18
  "gmapKey": gmapApiKey,
19
19
  "language": "en",
20
20
  "supplier": supplierRef.value,
21
+ "hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
21
22
  "googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
22
23
  "googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
23
24
  "themeVariables": {
@@ -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": ({
@@ -60,8 +60,8 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
60
60
  setCenterPlaceByUserSpecifiedInZone
61
61
  } = useBusinessRecomendPlaceMap();
62
62
  window.changeUserSpecifiedPlace = () => setCenterPlaceByUserSpecified({
63
- lng: 139.55,
64
- lat: 35.55,
63
+ lng: 114.226288,
64
+ lat: 22.27965,
65
65
  type: "gcj02",
66
66
  name: "user specified place",
67
67
  displayName: "user specified place"
@@ -17,8 +17,10 @@ export declare const ZINDEX_PASSENGER_LAYER = 20;
17
17
  export declare const ZINDEX_AUXILIARY_GRASP = 14;
18
18
  export declare const ZINDEX_LINE_LAYER = 12;
19
19
  export declare const ZINDEX_GREEN_ZONE = 10;
20
+ export declare const HK_GOVERN_API_DISTANCE_MAX = 20;
20
21
  export declare const TRACKS_MATCH_MAX_LENGTH = 3;
21
22
  export declare const REGEO_TIMEOUT = 5000;
23
+ export declare const HK_GOVERN_API_TIMEOUT = 1000;
22
24
  export declare const GET_RECOMMEND_PLACE_TIMEOUT = 5000;
23
25
  export declare const GET_DEFAULT_CENTER_PLACE_TIMEOUT = 5000;
24
26
  export declare const AMAP_TO_GCJ02_TIMEOUT = 2000;
@@ -16,8 +16,10 @@ const ZINDEX_PASSENGER_LAYER = 20;
16
16
  const ZINDEX_AUXILIARY_GRASP = 14;
17
17
  const ZINDEX_LINE_LAYER = 12;
18
18
  const ZINDEX_GREEN_ZONE = 10;
19
+ const HK_GOVERN_API_DISTANCE_MAX = 20;
19
20
  const TRACKS_MATCH_MAX_LENGTH = 3;
20
21
  const REGEO_TIMEOUT = 5e3;
22
+ const HK_GOVERN_API_TIMEOUT = 1e3;
21
23
  const GET_RECOMMEND_PLACE_TIMEOUT = 5e3;
22
24
  const GET_DEFAULT_CENTER_PLACE_TIMEOUT = 5e3;
23
25
  const AMAP_TO_GCJ02_TIMEOUT = 2e3;
@@ -31,6 +33,8 @@ export {
31
33
  CAR_DISTANCE_MIN,
32
34
  GET_DEFAULT_CENTER_PLACE_TIMEOUT,
33
35
  GET_RECOMMEND_PLACE_TIMEOUT,
36
+ HK_GOVERN_API_DISTANCE_MAX,
37
+ HK_GOVERN_API_TIMEOUT,
34
38
  MAX_ANIMATION_DISTANCE_VW,
35
39
  MAX_DEVIATION_DISTANCE,
36
40
  MAX_DEVIATION_DISTANCE_WALKING,
@@ -0,0 +1,7 @@
1
+ export declare const apiHongKongGovernDriving: (props: any) => Promise<{
2
+ result: any;
3
+ origin: {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ }>;
@@ -0,0 +1,31 @@
1
+ import { isProxyServiceError } from "../utils/typeChecking.js";
2
+ import { guid } from "../utils/helper.js";
3
+ import { wgs84ToHK80 } from "../utils/transform.js";
4
+ const apiHongKongGovernDriving = async (props) => {
5
+ const { proxyUrl, lng, lat, language } = props;
6
+ const { protocol, host } = location;
7
+ const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
8
+ const url = new URL(proxyUrl, baseUrl);
9
+ const hk80Coord = wgs84ToHK80(lat, lng);
10
+ url.searchParams.set("lang", language);
11
+ url.searchParams.set("x", hk80Coord.x.toString());
12
+ url.searchParams.set("y", hk80Coord.y.toString());
13
+ url.searchParams.set("reqSid", guid());
14
+ const response = await fetch(url);
15
+ if (response.ok) {
16
+ const result = await response.json();
17
+ return { result, origin: hk80Coord };
18
+ }
19
+ const error = await response.json();
20
+ if (isProxyServiceError(error)) {
21
+ const { code, msg } = error;
22
+ throw new Error(`apiHongKongGovernDriving proxy failed code: ${code}, msg:
23
+ ${msg}`);
24
+ }
25
+ throw new Error(
26
+ `apiHongKongGovernDriving failed with unrecognized server response: ${JSON.stringify(error)}`
27
+ );
28
+ };
29
+ export {
30
+ apiHongKongGovernDriving
31
+ };
@@ -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">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "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"]);
53
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "hkGovernRegeoProxyUrl"]);
54
54
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
55
55
  slots,
56
56
  emit,
@@ -1,16 +1,20 @@
1
1
  import { ref, reactive, watch } from "vue-demi";
2
- import { REGEO_TIMEOUT } from "../api/contants.js";
2
+ import { REGEO_TIMEOUT, HK_GOVERN_API_TIMEOUT } from "../api/contants.js";
3
+ import { apiHongKongGovernDriving } from "../api/hongkongGovernDriving.js";
3
4
  import { createPipeTw } from "../utils/cn2tw.js";
4
- import { equalAssign, AbortSignalAny } from "../utils/helper.js";
5
- import { amapPlaceName2DisplayName, signal2promise, gmapPlaceName2DisplayName } from "../utils/transform.js";
6
- import { inChina, inTaiwan } from "./useMapInChina.js";
5
+ import { equalAssign, AbortSignalAny, sleep } from "../utils/helper.js";
6
+ import { getHKGovernResult } from "../utils/hongkongGovernGeoCoder.js";
7
+ import { toLocalWgs84Force, amapPlaceName2DisplayName, signal2promise, gmapPlaceName2DisplayName } from "../utils/transform.js";
8
+ import { inChina, inTaiwan, inHongkong } from "./useMapInChina.js";
7
9
  import { useMapSupplier } from "./useMapSupplier.js";
8
10
  import { useUpdate } from "./useUdate.js";
11
+ import { useMapGCJ02 } from "./useMapGCJ02.js";
9
12
  const useAmapPlace = (props) => {
10
13
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
11
14
  const defaultPoint = [...props.pointRef.value];
12
15
  const pointRef = ref(defaultPoint);
13
- const { readyPromise, language } = useMapSupplier();
16
+ const { readyPromise, language, hkGovernRegeoProxyUrl } = useMapSupplier();
17
+ const { toCoordinateType } = useMapGCJ02();
14
18
  const place = reactive({
15
19
  lng: pointRef.value[0],
16
20
  lat: pointRef.value[1],
@@ -40,8 +44,49 @@ const useAmapPlace = (props) => {
40
44
  const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
41
45
  const pipeTw = createPipeTw(language === "zh-TW");
42
46
  const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
43
- geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
47
+ const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
48
+ const startTime = Date.now();
49
+ let hkReturned = !isUseHKGovern;
50
+ let amapReturned = false;
51
+ if (isUseHKGovern) {
52
+ const [finalLng, finalLat] = toLocalWgs84Force([lng, lat], toCoordinateType([lng, lat]));
53
+ console.log("lng:", lng, finalLng);
54
+ console.log("lat:", lat, finalLat);
55
+ apiHongKongGovernDriving({
56
+ proxyUrl: hkGovernRegeoProxyUrl,
57
+ lng: finalLng,
58
+ lat: finalLat,
59
+ language: language === "zh-TW" ? "zh" : language
60
+ }).then(({ result, origin }) => {
61
+ var _a, _b;
62
+ const hkGovernRes = getHKGovernResult((_b = (_a = result == null ? void 0 : result.data) == null ? void 0 : _a.rawResponse) == null ? void 0 : _b.results, origin);
63
+ const diff = Date.now() - startTime;
64
+ console.log("==return value of hkGovernApi==", hkGovernRes);
65
+ console.log("==time of hkGovernApi==", diff);
66
+ if (!amapReturned && hkGovernRes) {
67
+ const name = language === "en" ? hkGovernRes.ename : hkGovernRes.cname;
68
+ hkReturned = true;
69
+ resolve({
70
+ lng,
71
+ lat,
72
+ name,
73
+ displayName: name
74
+ });
75
+ }
76
+ });
77
+ }
78
+ geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
44
79
  clearTimeout(timer);
80
+ if (isUseHKGovern) {
81
+ const diff = Date.now() - startTime;
82
+ console.log("==time of AmapReGeo==", diff);
83
+ const rest = HK_GOVERN_API_TIMEOUT - diff;
84
+ if (rest >= 0)
85
+ await sleep(rest);
86
+ console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
87
+ if (hkReturned)
88
+ return;
89
+ }
45
90
  switch (status) {
46
91
  case "complete": {
47
92
  const { formattedAddress, addressComponent } = result.regeocode;
@@ -50,6 +95,7 @@ const useAmapPlace = (props) => {
50
95
  isChinese,
51
96
  ...addressComponent
52
97
  });
98
+ amapReturned = true;
53
99
  resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
54
100
  return;
55
101
  }
@@ -117,6 +117,7 @@ const useMapRecomendPlace = (props) => {
117
117
  return { place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
118
118
  }
119
119
  const regeoPlace = await reGeoPlacePromiseIgnored.recover();
120
+ console.log(54566544, regeoPlace);
120
121
  return { place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
121
122
  }
122
123
  if (type === "Forbidden") {
@@ -12,6 +12,7 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
12
12
  googleDirectionsProxyUrl?: string;
13
13
  googleRoutesProxyUrl?: string;
14
14
  googleSnapRoadProxyUrl?: string;
15
+ hkGovernRegeoProxyUrl?: string;
15
16
  themeVariables?: MapThemeVariables;
16
17
  renderLoadFailedTitle?: (status: Status) => string | undefined;
17
18
  renderLoadFailedDescription?: (status: Status) => string | undefined;
@@ -5,7 +5,36 @@ import type { Point } from "../types/interface";
5
5
  */
6
6
  export declare function pointInPolygon(point: Point, polygon: Point[]): 1 | 0 | -1;
7
7
  export declare const distanceBetweenTwoPoints: (from: Point, to: Point) => number;
8
+ export declare const distanceTwoHK80Points: (from: Point, to: Point) => number;
8
9
  /**
9
10
  * 计算折线(按顺序连接各点)总长度。
10
11
  */
11
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[];