@heycar/heycars-map 2.17.0-curve9 → 2.19.0-drivingRouteFail

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 (43) hide show
  1. package/dist/v2/App.js +1 -0
  2. package/dist/v2/Demo/DemoBusinessQuoting.js +2 -2
  3. package/dist/v2/api/gaodeRegeo.d.ts +7 -0
  4. package/dist/v2/api/gaodeRegeo.js +28 -0
  5. package/dist/v2/api/hongkongGovernDriving.d.ts +7 -1
  6. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +3 -2
  7. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +30 -25
  8. package/dist/v2/business-components/DrivingRoute/DrivingRoute.d.ts +1 -0
  9. package/dist/v2/business-components/DrivingRoute/DrivingRoute.js +8 -4
  10. package/dist/v2/components/MapProvider/MapProvider.d.ts +1 -1
  11. package/dist/v2/components/MapProvider/MapProvider.js +1 -1
  12. package/dist/v2/hooks/useDrivingRoute.d.ts +3 -0
  13. package/dist/v2/hooks/useDrivingRoute.js +16 -7
  14. package/dist/v2/hooks/useMapPlace.js +62 -30
  15. package/dist/v2/hooks/useMapSupplier.d.ts +1 -0
  16. package/dist/v2/hooks/useWalkingRoute.js +3 -3
  17. package/dist/v2/utils/compatibleDrivingRoute.js +2 -1
  18. package/dist/v2/utils/compatibleWatchPosition.js +1 -0
  19. package/dist/v2/utils/log.js +1 -1
  20. package/dist/v2/utils/transform.js +29 -8
  21. package/dist/v2/utils/typeChecking.js +1 -0
  22. package/dist/v3/App.js +1 -0
  23. package/dist/v3/Demo/DemoBusinessQuoting.js +2 -2
  24. package/dist/v3/api/gaodeRegeo.d.ts +7 -0
  25. package/dist/v3/api/gaodeRegeo.js +28 -0
  26. package/dist/v3/api/hongkongGovernDriving.d.ts +7 -1
  27. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +3 -2
  28. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +24 -19
  29. package/dist/v3/business-components/DrivingRoute/DrivingRoute.d.ts +1 -0
  30. package/dist/v3/business-components/DrivingRoute/DrivingRoute.js +8 -4
  31. package/dist/v3/components/MapProvider/MapProvider.d.ts +1 -1
  32. package/dist/v3/components/MapProvider/MapProvider.js +1 -1
  33. package/dist/v3/hooks/useDrivingRoute.d.ts +3 -0
  34. package/dist/v3/hooks/useDrivingRoute.js +16 -7
  35. package/dist/v3/hooks/useMapPlace.js +62 -30
  36. package/dist/v3/hooks/useMapSupplier.d.ts +1 -0
  37. package/dist/v3/hooks/useWalkingRoute.js +3 -3
  38. package/dist/v3/utils/compatibleDrivingRoute.js +2 -1
  39. package/dist/v3/utils/compatibleWatchPosition.js +1 -0
  40. package/dist/v3/utils/log.js +1 -1
  41. package/dist/v3/utils/transform.js +29 -8
  42. package/dist/v3/utils/typeChecking.js +1 -0
  43. package/package.json +1 -1
package/dist/v2/App.js CHANGED
@@ -18,6 +18,7 @@ const App = defineComponent({
18
18
  "gmapKey": gmapApiKey,
19
19
  "language": "en",
20
20
  "supplier": supplierRef.value,
21
+ "gaodeRegeoProxyUrl": "/overseas/amap/regeo",
21
22
  "hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
22
23
  "googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
23
24
  "googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
@@ -47,7 +47,6 @@ const DemoBusinessQuoting = defineComponent({
47
47
  "class": demo,
48
48
  "attrs": {
49
49
  "from": from,
50
- "isBezierCurve": true,
51
50
  "to": {
52
51
  displayName: "CDG Engie Charging Station",
53
52
  name: "21 Kent Ridge Rd, Singapore 119220",
@@ -65,7 +64,8 @@ const DemoBusinessQuoting = defineComponent({
65
64
  },
66
65
  "on": {
67
66
  "clickStartPoint": (place) => console.log("点击起点时触发 palce = ", place),
68
- "clickEndPoint": (place) => console.log("点击终点时触发 palce = ", place)
67
+ "clickEndPoint": (place) => console.log("点击终点时触发 palce = ", place),
68
+ "drivingRouteDone": (hasRoute) => console.log("导航路线规划完成时触发 hasRoute = ", hasRoute)
69
69
  }
70
70
  }), h("div", ["经度 103.841974, 纬度 1.311295 在高德地图上的坐标类型是:", toAmapCoordinateType([103.841974, 1.311295])])]);
71
71
  }
@@ -0,0 +1,7 @@
1
+ export interface GaodeRegeoProps {
2
+ proxyUrl: string;
3
+ lng: number;
4
+ lat: number;
5
+ language: string;
6
+ }
7
+ export declare const apiGaodeRegeo: (props: GaodeRegeoProps) => Promise<any>;
@@ -0,0 +1,28 @@
1
+ import { isProxyServiceError } from "../utils/typeChecking.js";
2
+ import { guid } from "../utils/helper.js";
3
+ const apiGaodeRegeo = async (props) => {
4
+ const { proxyUrl, lng, lat, language } = props;
5
+ const { protocol, host } = location;
6
+ const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
7
+ const url = new URL(proxyUrl, baseUrl);
8
+ url.searchParams.set("language", language);
9
+ url.searchParams.set("location", `${lng.toString()},${lat.toString()}`);
10
+ url.searchParams.set("reqSid", guid());
11
+ const response = await fetch(url);
12
+ if (response.ok) {
13
+ const result = await response.json();
14
+ return result;
15
+ }
16
+ const error = await response.json();
17
+ if (isProxyServiceError(error)) {
18
+ const { code, msg } = error;
19
+ throw new Error(`apiGaodeRegeo proxy failed code: ${code}, msg:
20
+ ${msg}`);
21
+ }
22
+ throw new Error(
23
+ `apiGaodeRegeo failed with unrecognized server response: ${JSON.stringify(error)}`
24
+ );
25
+ };
26
+ export {
27
+ apiGaodeRegeo
28
+ };
@@ -1,4 +1,10 @@
1
- export declare const apiHongKongGovernDriving: (props: any) => Promise<{
1
+ export interface HongKongGovernDrivingProps {
2
+ proxyUrl: string;
3
+ lng: number;
4
+ lat: number;
5
+ language: string;
6
+ }
7
+ export declare const apiHongKongGovernDriving: (props: HongKongGovernDrivingProps) => Promise<{
2
8
  result: any;
3
9
  origin: {
4
10
  x: number;
@@ -18,6 +18,7 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
18
18
  }) => string | undefined;
19
19
  onClickStartPoint?: (value: CoordinatePlace) => void;
20
20
  onClickEndPoint?: (value: CoordinatePlace) => void;
21
+ onDrivingRouteDone?: (hasRoute: boolean) => void;
21
22
  };
22
- export declare const BusinessQuotingMapInner: import("vue/types/v3-define-component").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint", BusinessQuotingMapProps>;
23
- export declare const BusinessQuotingMap: import("vue/types/v3-define-component").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint", BusinessQuotingMapProps>;
23
+ export declare const BusinessQuotingMapInner: import("vue/types/v3-define-component").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint" | "drivingRouteDone", BusinessQuotingMapProps>;
24
+ export declare const BusinessQuotingMap: import("vue/types/v3-define-component").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint" | "drivingRouteDone", BusinessQuotingMapProps>;
@@ -120,30 +120,35 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
120
120
  distance: distance2,
121
121
  duration,
122
122
  tolls,
123
- trafficJams
124
- }) => [h(TrafficDrivingLine, {
125
- "attrs": {
126
- "path": path,
127
- "trafficJams": trafficJams
128
- }
129
- }), h(StartEndPoint, {
130
- "attrs": {
131
- "type": "end",
132
- "registerOverlay": fittableRegistryOverlay,
133
- "position": to,
134
- "title": toPlace.displayName,
135
- "description": renderDescription({
136
- distance: distance2,
137
- duration,
138
- tolls
139
- }),
140
- "withArrow": !disableEndPoint,
141
- "language": language
142
- },
143
- "on": {
144
- "click": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
145
- }
146
- })]
123
+ trafficJams,
124
+ init
125
+ }) => {
126
+ if (!init)
127
+ emit("drivingRouteDone", path.length !== 0);
128
+ return [h(TrafficDrivingLine, {
129
+ "attrs": {
130
+ "path": path,
131
+ "trafficJams": trafficJams
132
+ }
133
+ }), h(StartEndPoint, {
134
+ "attrs": {
135
+ "type": "end",
136
+ "registerOverlay": fittableRegistryOverlay,
137
+ "position": to,
138
+ "title": toPlace.displayName,
139
+ "description": renderDescription({
140
+ distance: distance2,
141
+ duration,
142
+ tolls
143
+ }),
144
+ "withArrow": !disableEndPoint,
145
+ "language": language
146
+ },
147
+ "on": {
148
+ "click": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
149
+ }
150
+ })];
151
+ }
147
152
  }
148
153
  }), h(FitViewOnce, {
149
154
  "attrs": {
@@ -168,7 +173,7 @@ const BusinessQuotingMap = defineLagecySetup("BusinessQuotingMap", function(prop
168
173
  } : {},
169
174
  attrs: props,
170
175
  key: `${payload.supplier}${instanceNo}`,
171
- on: generateCreateElementV2PropsOn(props, emit, ["clickStartPoint", "clickEndPoint"])
176
+ on: generateCreateElementV2PropsOn(props, emit, ["clickStartPoint", "clickEndPoint", "drivingRouteDone"])
172
177
  });
173
178
  }).props(["fallback", "from", "loading", "disableStartPoint", "disableEndPoint", "mapContext", "renderDescription", "to", "fromDescription", "log", "isBezierCurve"]);
174
179
  export {
@@ -8,6 +8,7 @@ export type DrivingRouteRenderProps = {
8
8
  duration: number;
9
9
  tolls?: number;
10
10
  trafficJams?: TrafficJams;
11
+ init: boolean;
11
12
  };
12
13
  export interface DrivingRouteProps extends UseDrivingRouteProps {
13
14
  render?: (props: DrivingRouteRenderProps) => VNodeChild;
@@ -15,7 +15,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
15
15
  distance,
16
16
  duration,
17
17
  tolls,
18
- trafficJams
18
+ trafficJams,
19
+ init
19
20
  } = toRefs(useADrivingRoute(props).route);
20
21
  const {
21
22
  angleRef
@@ -31,7 +32,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
31
32
  distance,
32
33
  duration,
33
34
  tolls,
34
- trafficJams
35
+ trafficJams,
36
+ init
35
37
  }))]);
36
38
  };
37
39
  });
@@ -42,7 +44,8 @@ const GDrivingRoute = defineSetup("GDrivingRoute", function(props, {
42
44
  const {
43
45
  path,
44
46
  distance,
45
- duration
47
+ duration,
48
+ init
46
49
  } = toRefs(useGDrivingRoute(props).route);
47
50
  const {
48
51
  angleRef
@@ -56,7 +59,8 @@ const GDrivingRoute = defineSetup("GDrivingRoute", function(props, {
56
59
  path,
57
60
  angle: angleRef,
58
61
  distance,
59
- duration
62
+ duration,
63
+ init
60
64
  }))]);
61
65
  };
62
66
  });
@@ -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" | "reportLog" | "hkGovernRegeoProxyUrl">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl" | "gaodeRegeoProxyUrl">;
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", "reportLog", "hkGovernRegeoProxyUrl"]);
53
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl", "gaodeRegeoProxyUrl"]);
54
54
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
55
55
  slots,
56
56
  emit,
@@ -16,6 +16,7 @@ export declare const useADrivingRoute: (props?: UseDrivingRouteProps) => {
16
16
  distance: number;
17
17
  }[];
18
18
  trafficJams?: import("../types/interface").TrafficJams | undefined;
19
+ init: boolean;
19
20
  };
20
21
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
21
22
  };
@@ -31,6 +32,7 @@ export declare const useGDrivingRoute: (props?: UseDrivingRouteProps) => {
31
32
  distance: number;
32
33
  }[];
33
34
  trafficJams?: import("../types/interface").TrafficJams | undefined;
35
+ init: boolean;
34
36
  };
35
37
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
36
38
  };
@@ -46,6 +48,7 @@ export declare const useDrivingRoute: (props?: UseDrivingRouteProps) => {
46
48
  distance: number;
47
49
  }[];
48
50
  trafficJams?: import("../types/interface").TrafficJams | undefined;
51
+ init: boolean;
49
52
  };
50
53
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
51
54
  };
@@ -1,21 +1,22 @@
1
1
  import { reactive } from "vue-demi";
2
2
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
- import { googleServiceApiDrivingRoute, amapJsApiDrivingRoute, gaodeServiceApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
3
+ import { googleServiceApiDrivingRoute, gaodeServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
4
4
  import { inTaiwan, inKorean } from "./useMapInChina.js";
5
5
  import { useMapSupplier } from "./useMapSupplier.js";
6
6
  const useADrivingRoute = (props) => {
7
- const { googleRoutesProxyUrl } = useMapSupplier();
7
+ const { googleRoutesProxyUrl, gaodeDirectionDrivingProxyUrl } = useMapSupplier();
8
8
  const outputRoute = reactive({
9
9
  path: [],
10
10
  distance: 0,
11
11
  duration: 0,
12
12
  tolls: void 0,
13
13
  steps: [],
14
- trafficJams: void 0
14
+ trafficJams: void 0,
15
+ init: true
15
16
  });
16
17
  const amapDriving = new AMap.Driving({ ferry: 1 });
17
18
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
18
- return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
19
+ return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
19
20
  };
20
21
  watchPostEffectForDeepOption(
21
22
  () => {
@@ -25,14 +26,18 @@ const useADrivingRoute = (props) => {
25
26
  async ({ from, to, waypoints }) => {
26
27
  if (!from || !to)
27
28
  return;
28
- Object.assign(outputRoute, await apiMapDrivingRoute(from, to, waypoints));
29
+ try {
30
+ Object.assign(outputRoute, { init: false }, await apiMapDrivingRoute(from, to, waypoints));
31
+ } catch {
32
+ Object.assign(outputRoute, { init: false });
33
+ }
29
34
  }
30
35
  );
31
36
  return { route: outputRoute, apiMapDrivingRoute };
32
37
  };
33
38
  const useGDrivingRoute = (props) => {
34
39
  const { gaodeDirectionDrivingProxyUrl, googleRoutesProxyUrl } = useMapSupplier();
35
- const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [] });
40
+ const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [], init: true });
36
41
  const gmapDirectionsService = new google.maps.DirectionsService();
37
42
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
38
43
  return gaodeDirectionDrivingProxyUrl && inKorean(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
@@ -45,7 +50,11 @@ const useGDrivingRoute = (props) => {
45
50
  async ({ from, to, waypoints }) => {
46
51
  if (!from || !to)
47
52
  return;
48
- Object.assign(outputRoute, await apiMapDrivingRoute(from, to, waypoints));
53
+ try {
54
+ Object.assign(outputRoute, { init: false }, await apiMapDrivingRoute(from, to, waypoints));
55
+ } catch {
56
+ Object.assign(outputRoute, { init: false });
57
+ }
49
58
  }
50
59
  );
51
60
  return { route: outputRoute, apiMapDrivingRoute };
@@ -9,11 +9,12 @@ import { inChina, inTaiwan, inHongkong } from "./useMapInChina.js";
9
9
  import { useMapSupplier } from "./useMapSupplier.js";
10
10
  import { useUpdate } from "./useUdate.js";
11
11
  import { useMapGCJ02 } from "./useMapGCJ02.js";
12
+ import { apiGaodeRegeo } from "../api/gaodeRegeo.js";
12
13
  const useAmapPlace = (props) => {
13
14
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
14
15
  const defaultPoint = [...props.pointRef.value];
15
16
  const pointRef = ref(defaultPoint);
16
- const { readyPromise, language, hkGovernRegeoProxyUrl } = useMapSupplier();
17
+ const { readyPromise, language, hkGovernRegeoProxyUrl, gaodeRegeoProxyUrl } = useMapSupplier();
17
18
  const { toCoordinateType } = useMapGCJ02();
18
19
  const place = reactive({
19
20
  lng: pointRef.value[0],
@@ -41,7 +42,6 @@ const useAmapPlace = (props) => {
41
42
  resolve({ lng, lat, name, displayName });
42
43
  };
43
44
  readyPromise.then(() => {
44
- const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
45
45
  const pipeTw = createPipeTw(language === "zh-TW");
46
46
  const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
47
47
  const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
@@ -75,36 +75,68 @@ const useAmapPlace = (props) => {
75
75
  }
76
76
  });
77
77
  }
78
- geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
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
- }
90
- switch (status) {
91
- case "complete": {
92
- const { formattedAddress, addressComponent } = result.regeocode;
93
- const name = formattedAddress ? formattedAddress : emptyPlaceName;
94
- const displayName = amapPlaceName2DisplayName(name, {
95
- isChinese,
96
- ...addressComponent
97
- });
98
- amapReturned = true;
99
- resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
100
- return;
78
+ if (gaodeRegeoProxyUrl) {
79
+ apiGaodeRegeo({
80
+ proxyUrl: gaodeRegeoProxyUrl,
81
+ lng,
82
+ lat,
83
+ language: language === "en" ? "en" : "zh_cn"
84
+ }).then(async (result) => {
85
+ clearTimeout(timer);
86
+ if (isUseHKGovern) {
87
+ const diff = Date.now() - startTime;
88
+ console.log("==time of AmapReGeo==", diff);
89
+ const rest = HK_GOVERN_API_TIMEOUT - diff;
90
+ if (rest >= 0)
91
+ await sleep(rest);
92
+ console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
93
+ if (hkReturned)
94
+ return;
101
95
  }
102
- case "no_data":
103
- case "error": {
104
- handleFailed();
96
+ const { formatted_address, addressComponent } = result.regeocode;
97
+ const name = formatted_address || emptyPlaceName;
98
+ const displayName = amapPlaceName2DisplayName(name, {
99
+ isChinese,
100
+ ...addressComponent
101
+ });
102
+ amapReturned = true;
103
+ resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
104
+ }).catch(() => {
105
+ handleFailed();
106
+ });
107
+ } else {
108
+ const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
109
+ geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
110
+ clearTimeout(timer);
111
+ if (isUseHKGovern) {
112
+ const diff = Date.now() - startTime;
113
+ console.log("==time of AmapReGeo==", diff);
114
+ const rest = HK_GOVERN_API_TIMEOUT - diff;
115
+ if (rest >= 0)
116
+ await sleep(rest);
117
+ console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
118
+ if (hkReturned)
119
+ return;
105
120
  }
106
- }
107
- });
121
+ switch (status) {
122
+ case "complete": {
123
+ const { formattedAddress, addressComponent } = result.regeocode;
124
+ const name = formattedAddress ? formattedAddress : emptyPlaceName;
125
+ const displayName = amapPlaceName2DisplayName(name, {
126
+ isChinese,
127
+ ...addressComponent
128
+ });
129
+ amapReturned = true;
130
+ resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
131
+ return;
132
+ }
133
+ case "no_data":
134
+ case "error": {
135
+ handleFailed();
136
+ }
137
+ }
138
+ });
139
+ }
108
140
  }, handleFailed);
109
141
  const timer = setTimeout(() => {
110
142
  console.warn("高德逆地理请求超时!");
@@ -13,6 +13,7 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
13
13
  googleRoutesProxyUrl?: string;
14
14
  googleSnapRoadProxyUrl?: string;
15
15
  hkGovernRegeoProxyUrl?: string;
16
+ gaodeRegeoProxyUrl?: string;
16
17
  themeVariables?: MapThemeVariables;
17
18
  renderLoadFailedTitle?: (status: Status) => string | undefined;
18
19
  renderLoadFailedDescription?: (status: Status) => string | undefined;
@@ -1,7 +1,7 @@
1
1
  import { shallowRef } from "vue-demi";
2
2
  import { MAX_DEVIATION_DISTANCE_WALKING } from "../api/contants.js";
3
3
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
4
- import { googleServiceApiWalkingRoute, amapJsApiWalkingRoute, gaodeServiceApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
4
+ import { googleServiceApiWalkingRoute, gaodeServiceApiWalkingRoute, amapJsApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
5
5
  import { findClosestPointInLine } from "../utils/geometry.js";
6
6
  import { distanceBetweenTwoPoints } from "../utils/geometryPolygon.js";
7
7
  import { spaceLog } from "../utils/log.js";
@@ -44,12 +44,12 @@ const findBestContinuation = (args, cacheEntries) => {
44
44
  const memoizeAmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
45
45
  const memoizeGmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
46
46
  const useAWalkingRoute = (props) => {
47
- const { googleRoutesProxyUrl } = useMapSupplier();
47
+ const { googleRoutesProxyUrl, gaodeDirectionWalkingProxyUrl } = useMapSupplier();
48
48
  const pathRef = shallowRef([]);
49
49
  const amapWalking = new AMap.Walking({});
50
50
  const apiMapWalkingRoute = memoizeAmapWalkingRoute((from, to) => {
51
51
  spaceLog("apiMapWalkingRoute", `amap from = ${from} to = ${to}`);
52
- return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
52
+ return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : gaodeDirectionWalkingProxyUrl ? gaodeServiceApiWalkingRoute(from, to, gaodeDirectionWalkingProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
53
53
  });
54
54
  watchPostEffectForDeepOption(
55
55
  () => {
@@ -72,7 +72,8 @@ async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
72
72
  proxyUrl,
73
73
  origin: [from],
74
74
  destination: to,
75
- waypoints
75
+ waypoints,
76
+ ferry: 1
76
77
  });
77
78
  const trafficJams = {};
78
79
  switch (status) {
@@ -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==", JSON.stringify(geoLocationPosition), typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function");
222
223
  geoErrorMessage = void 0;
223
224
  resolve(geoLocationPosition);
224
225
  },
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.17.0-curve9";
3
+ const pkgVersion = "2.19.0-drivingRouteFail";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
@@ -119,10 +119,22 @@ const amapPlaceName2DisplayName = (name, options) => {
119
119
  };
120
120
  function amapPlaceName2DisplayNameInChinese(name, options) {
121
121
  const { province, city, district, township, building, neighborhood } = options;
122
- if (building)
123
- return building;
124
- if (neighborhood)
125
- return neighborhood;
122
+ if (typeof building === "string") {
123
+ if (building)
124
+ return building;
125
+ } else {
126
+ const { name: name2 } = building;
127
+ if (typeof name2 === "string" && name2)
128
+ return name2;
129
+ }
130
+ if (typeof neighborhood === "string") {
131
+ if (neighborhood)
132
+ return neighborhood;
133
+ } else {
134
+ const { name: name2 } = neighborhood;
135
+ if (typeof name2 === "string" && name2)
136
+ return name2;
137
+ }
126
138
  let result = name;
127
139
  for (const item of [province, city, district]) {
128
140
  const replacedName2 = result.replace(item, "");
@@ -138,10 +150,19 @@ function amapPlaceName2DisplayNameInChinese(name, options) {
138
150
  const NOT_ONLY_NUMBERS_REGEX = /[^\d\s-]/;
139
151
  function amapPlaceName2DisplayNameOutChinese(name, options) {
140
152
  const { adcode, province, city, district, township, street, streetNumber } = options;
141
- if (street === "Unnamed Road")
142
- return name;
143
- if (street || streetNumber)
144
- return `${street} ${streetNumber}`;
153
+ if (typeof streetNumber === "string") {
154
+ if (street === "Unnamed Road")
155
+ return name;
156
+ if (street || streetNumber)
157
+ return `${street} ${streetNumber}`;
158
+ } else {
159
+ const { number, street: streetNumberStreet } = streetNumber;
160
+ if (streetNumberStreet === "Unnamed Road")
161
+ return name;
162
+ const streetNumberItem = typeof number === "string" ? number : "";
163
+ if (streetNumberStreet || streetNumberItem)
164
+ return `${streetNumberStreet} ${streetNumberItem}`;
165
+ }
145
166
  const idxs = [];
146
167
  for (const token of [adcode, province, city, district, township]) {
147
168
  if (!token)
@@ -150,6 +150,7 @@ function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
150
150
  });
151
151
  return;
152
152
  }
153
+ console.log("==injected geoPosition==", JSON.stringify(position));
153
154
  onSuccess(position);
154
155
  };
155
156
  const asseertedOnError = (error) => onError(toGeolocationPositionError(error, prefix));
package/dist/v3/App.js CHANGED
@@ -17,6 +17,7 @@ const App = /* @__PURE__ */ defineComponent({
17
17
  "gmapKey": gmapApiKey,
18
18
  "language": "en",
19
19
  "supplier": supplierRef.value,
20
+ "gaodeRegeoProxyUrl": "/overseas/amap/regeo",
20
21
  "hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
21
22
  "googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
22
23
  "googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
@@ -46,7 +46,6 @@ const DemoBusinessQuoting = /* @__PURE__ */ defineComponent({
46
46
  return createVNode("div", null, [createVNode(BusinessQuotingMap, {
47
47
  "class": demo,
48
48
  "from": from,
49
- "isBezierCurve": true,
50
49
  "to": {
51
50
  displayName: "CDG Engie Charging Station",
52
51
  name: "21 Kent Ridge Rd, Singapore 119220",
@@ -62,7 +61,8 @@ const DemoBusinessQuoting = /* @__PURE__ */ defineComponent({
62
61
  }) => `全程 *${distance / 1e3}公里* 约行驶 *${duration}* 高速费用 *${tolls != null ? tolls : 0}*元`,
63
62
  "mapContext": mapContext,
64
63
  "onClickStartPoint": (place) => console.log("点击起点时触发 palce = ", place),
65
- "onClickEndPoint": (place) => console.log("点击终点时触发 palce = ", place)
64
+ "onClickEndPoint": (place) => console.log("点击终点时触发 palce = ", place),
65
+ "onDrivingRouteDone": (hasRoute) => console.log("导航路线规划完成时触发 hasRoute = ", hasRoute)
66
66
  }, null), createVNode("div", null, [createTextVNode("经度 103.841974, 纬度 1.311295 在高德地图上的坐标类型是:"), toAmapCoordinateType([103.841974, 1.311295])])]);
67
67
  }
68
68
  });
@@ -0,0 +1,7 @@
1
+ export interface GaodeRegeoProps {
2
+ proxyUrl: string;
3
+ lng: number;
4
+ lat: number;
5
+ language: string;
6
+ }
7
+ export declare const apiGaodeRegeo: (props: GaodeRegeoProps) => Promise<any>;
@@ -0,0 +1,28 @@
1
+ import { isProxyServiceError } from "../utils/typeChecking.js";
2
+ import { guid } from "../utils/helper.js";
3
+ const apiGaodeRegeo = async (props) => {
4
+ const { proxyUrl, lng, lat, language } = props;
5
+ const { protocol, host } = location;
6
+ const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
7
+ const url = new URL(proxyUrl, baseUrl);
8
+ url.searchParams.set("language", language);
9
+ url.searchParams.set("location", `${lng.toString()},${lat.toString()}`);
10
+ url.searchParams.set("reqSid", guid());
11
+ const response = await fetch(url);
12
+ if (response.ok) {
13
+ const result = await response.json();
14
+ return result;
15
+ }
16
+ const error = await response.json();
17
+ if (isProxyServiceError(error)) {
18
+ const { code, msg } = error;
19
+ throw new Error(`apiGaodeRegeo proxy failed code: ${code}, msg:
20
+ ${msg}`);
21
+ }
22
+ throw new Error(
23
+ `apiGaodeRegeo failed with unrecognized server response: ${JSON.stringify(error)}`
24
+ );
25
+ };
26
+ export {
27
+ apiGaodeRegeo
28
+ };
@@ -1,4 +1,10 @@
1
- export declare const apiHongKongGovernDriving: (props: any) => Promise<{
1
+ export interface HongKongGovernDrivingProps {
2
+ proxyUrl: string;
3
+ lng: number;
4
+ lat: number;
5
+ language: string;
6
+ }
7
+ export declare const apiHongKongGovernDriving: (props: HongKongGovernDrivingProps) => Promise<{
2
8
  result: any;
3
9
  origin: {
4
10
  x: number;
@@ -18,8 +18,9 @@ export type BusinessQuotingMapProps = CoordinatifyProps<Omit<HeycarMapProps, "ce
18
18
  }) => string | undefined;
19
19
  onClickStartPoint?: (value: CoordinatePlace) => void;
20
20
  onClickEndPoint?: (value: CoordinatePlace) => void;
21
+ onDrivingRouteDone?: (hasRoute: boolean) => void;
21
22
  };
22
- export declare const BusinessQuotingMapInner: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint", import("@vue/runtime-core").PublicProps, BusinessQuotingMapProps, BusinessQuotingMapProps, import("@vue/runtime-core").SlotsType<{
23
+ export declare const BusinessQuotingMapInner: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint" | "drivingRouteDone", import("@vue/runtime-core").PublicProps, BusinessQuotingMapProps, BusinessQuotingMapProps, import("@vue/runtime-core").SlotsType<{
23
24
  fallback?: (() => import("vue").VNodeChild) | undefined;
24
25
  loading?: (() => import("vue").VNodeChild) | undefined;
25
26
  outerArea?: (() => import("vue").VNodeChild) | undefined;
@@ -31,7 +32,7 @@ export declare const BusinessQuotingMapInner: import("@vue/runtime-core").Define
31
32
  } & {
32
33
  default?: import("../../demi-polyfill").Slot | undefined;
33
34
  }>>;
34
- export declare const BusinessQuotingMap: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint", import("@vue/runtime-core").PublicProps, BusinessQuotingMapProps, BusinessQuotingMapProps, import("@vue/runtime-core").SlotsType<{
35
+ export declare const BusinessQuotingMap: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ComponentObjectPropsOptions<BusinessQuotingMapProps>, 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<BusinessQuotingMapProps, Required<BusinessQuotingMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "clickStartPoint" | "clickEndPoint" | "drivingRouteDone", import("@vue/runtime-core").PublicProps, BusinessQuotingMapProps, BusinessQuotingMapProps, import("@vue/runtime-core").SlotsType<{
35
36
  fallback?: (() => import("vue").VNodeChild) | undefined;
36
37
  loading?: (() => import("vue").VNodeChild) | undefined;
37
38
  outerArea?: (() => import("vue").VNodeChild) | undefined;
@@ -106,24 +106,29 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
106
106
  distance: distance2,
107
107
  duration,
108
108
  tolls,
109
- trafficJams
110
- }) => [createVNode(TrafficDrivingLine, {
111
- "path": path,
112
- "trafficJams": trafficJams
113
- }, null), createVNode(StartEndPoint, {
114
- "type": "end",
115
- "registerOverlay": fittableRegistryOverlay,
116
- "position": to,
117
- "title": toPlace.displayName,
118
- "description": renderDescription({
119
- distance: distance2,
120
- duration,
121
- tolls
122
- }),
123
- "withArrow": !disableEndPoint,
124
- "language": language,
125
- "onClick": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
126
- }, null)]
109
+ trafficJams,
110
+ init
111
+ }) => {
112
+ if (!init)
113
+ emit("drivingRouteDone", path.length !== 0);
114
+ return [createVNode(TrafficDrivingLine, {
115
+ "path": path,
116
+ "trafficJams": trafficJams
117
+ }, null), createVNode(StartEndPoint, {
118
+ "type": "end",
119
+ "registerOverlay": fittableRegistryOverlay,
120
+ "position": to,
121
+ "title": toPlace.displayName,
122
+ "description": renderDescription({
123
+ distance: distance2,
124
+ duration,
125
+ tolls
126
+ }),
127
+ "withArrow": !disableEndPoint,
128
+ "language": language,
129
+ "onClick": () => !disableEndPoint && emit("clickEndPoint", coordinatifyPlace(toPlace))
130
+ }, null)];
131
+ }
127
132
  }, null), createVNode(FitViewOnce, {
128
133
  "registerOverlay": registerOverlay,
129
134
  "immediate": true
@@ -146,7 +151,7 @@ const BusinessQuotingMap = defineLagecySetup("BusinessQuotingMap", function(prop
146
151
  } : {},
147
152
  attrs: props,
148
153
  key: `${payload.supplier}${instanceNo}`,
149
- on: generateCreateElementV2PropsOn(props, emit, ["clickStartPoint", "clickEndPoint"])
154
+ on: generateCreateElementV2PropsOn(props, emit, ["clickStartPoint", "clickEndPoint", "drivingRouteDone"])
150
155
  });
151
156
  }).props(["fallback", "from", "loading", "disableStartPoint", "disableEndPoint", "mapContext", "renderDescription", "to", "fromDescription", "log", "isBezierCurve"]);
152
157
  export {
@@ -8,6 +8,7 @@ export type DrivingRouteRenderProps = {
8
8
  duration: number;
9
9
  tolls?: number;
10
10
  trafficJams?: TrafficJams;
11
+ init: boolean;
11
12
  };
12
13
  export interface DrivingRouteProps extends UseDrivingRouteProps {
13
14
  render?: (props: DrivingRouteRenderProps) => VNodeChild;
@@ -15,7 +15,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
15
15
  distance,
16
16
  duration,
17
17
  tolls,
18
- trafficJams
18
+ trafficJams,
19
+ init
19
20
  } = toRefs(useADrivingRoute(props).route);
20
21
  const {
21
22
  angleRef
@@ -31,7 +32,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
31
32
  distance,
32
33
  duration,
33
34
  tolls,
34
- trafficJams
35
+ trafficJams,
36
+ init
35
37
  }))]);
36
38
  };
37
39
  });
@@ -42,7 +44,8 @@ const GDrivingRoute = defineSetup("GDrivingRoute", function(props, {
42
44
  const {
43
45
  path,
44
46
  distance,
45
- duration
47
+ duration,
48
+ init
46
49
  } = toRefs(useGDrivingRoute(props).route);
47
50
  const {
48
51
  angleRef
@@ -56,7 +59,8 @@ const GDrivingRoute = defineSetup("GDrivingRoute", function(props, {
56
59
  path,
57
60
  angle: angleRef,
58
61
  distance,
59
- duration
62
+ duration,
63
+ init
60
64
  }))]);
61
65
  };
62
66
  });
@@ -5,7 +5,7 @@ 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" | "reportLog" | "hkGovernRegeoProxyUrl">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl" | "gaodeRegeoProxyUrl">;
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;
@@ -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", "reportLog", "hkGovernRegeoProxyUrl"]);
56
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl", "gaodeRegeoProxyUrl"]);
57
57
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
58
58
  slots,
59
59
  emit,
@@ -16,6 +16,7 @@ export declare const useADrivingRoute: (props?: UseDrivingRouteProps) => {
16
16
  distance: number;
17
17
  }[];
18
18
  trafficJams?: import("../types/interface").TrafficJams | undefined;
19
+ init: boolean;
19
20
  };
20
21
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
21
22
  };
@@ -31,6 +32,7 @@ export declare const useGDrivingRoute: (props?: UseDrivingRouteProps) => {
31
32
  distance: number;
32
33
  }[];
33
34
  trafficJams?: import("../types/interface").TrafficJams | undefined;
35
+ init: boolean;
34
36
  };
35
37
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
36
38
  };
@@ -46,6 +48,7 @@ export declare const useDrivingRoute: (props?: UseDrivingRouteProps) => {
46
48
  distance: number;
47
49
  }[];
48
50
  trafficJams?: import("../types/interface").TrafficJams | undefined;
51
+ init: boolean;
49
52
  };
50
53
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
51
54
  };
@@ -1,21 +1,22 @@
1
1
  import { reactive } from "vue-demi";
2
2
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
- import { googleServiceApiDrivingRoute, amapJsApiDrivingRoute, gaodeServiceApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
3
+ import { googleServiceApiDrivingRoute, gaodeServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
4
4
  import { inTaiwan, inKorean } from "./useMapInChina.js";
5
5
  import { useMapSupplier } from "./useMapSupplier.js";
6
6
  const useADrivingRoute = (props) => {
7
- const { googleRoutesProxyUrl } = useMapSupplier();
7
+ const { googleRoutesProxyUrl, gaodeDirectionDrivingProxyUrl } = useMapSupplier();
8
8
  const outputRoute = reactive({
9
9
  path: [],
10
10
  distance: 0,
11
11
  duration: 0,
12
12
  tolls: void 0,
13
13
  steps: [],
14
- trafficJams: void 0
14
+ trafficJams: void 0,
15
+ init: true
15
16
  });
16
17
  const amapDriving = new AMap.Driving({ ferry: 1 });
17
18
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
18
- return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
19
+ return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
19
20
  };
20
21
  watchPostEffectForDeepOption(
21
22
  () => {
@@ -25,14 +26,18 @@ const useADrivingRoute = (props) => {
25
26
  async ({ from, to, waypoints }) => {
26
27
  if (!from || !to)
27
28
  return;
28
- Object.assign(outputRoute, await apiMapDrivingRoute(from, to, waypoints));
29
+ try {
30
+ Object.assign(outputRoute, { init: false }, await apiMapDrivingRoute(from, to, waypoints));
31
+ } catch {
32
+ Object.assign(outputRoute, { init: false });
33
+ }
29
34
  }
30
35
  );
31
36
  return { route: outputRoute, apiMapDrivingRoute };
32
37
  };
33
38
  const useGDrivingRoute = (props) => {
34
39
  const { gaodeDirectionDrivingProxyUrl, googleRoutesProxyUrl } = useMapSupplier();
35
- const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [] });
40
+ const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [], init: true });
36
41
  const gmapDirectionsService = new google.maps.DirectionsService();
37
42
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
38
43
  return gaodeDirectionDrivingProxyUrl && inKorean(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
@@ -45,7 +50,11 @@ const useGDrivingRoute = (props) => {
45
50
  async ({ from, to, waypoints }) => {
46
51
  if (!from || !to)
47
52
  return;
48
- Object.assign(outputRoute, await apiMapDrivingRoute(from, to, waypoints));
53
+ try {
54
+ Object.assign(outputRoute, { init: false }, await apiMapDrivingRoute(from, to, waypoints));
55
+ } catch {
56
+ Object.assign(outputRoute, { init: false });
57
+ }
49
58
  }
50
59
  );
51
60
  return { route: outputRoute, apiMapDrivingRoute };
@@ -9,11 +9,12 @@ import { inChina, inTaiwan, inHongkong } from "./useMapInChina.js";
9
9
  import { useMapSupplier } from "./useMapSupplier.js";
10
10
  import { useUpdate } from "./useUdate.js";
11
11
  import { useMapGCJ02 } from "./useMapGCJ02.js";
12
+ import { apiGaodeRegeo } from "../api/gaodeRegeo.js";
12
13
  const useAmapPlace = (props) => {
13
14
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
14
15
  const defaultPoint = [...props.pointRef.value];
15
16
  const pointRef = ref(defaultPoint);
16
- const { readyPromise, language, hkGovernRegeoProxyUrl } = useMapSupplier();
17
+ const { readyPromise, language, hkGovernRegeoProxyUrl, gaodeRegeoProxyUrl } = useMapSupplier();
17
18
  const { toCoordinateType } = useMapGCJ02();
18
19
  const place = reactive({
19
20
  lng: pointRef.value[0],
@@ -41,7 +42,6 @@ const useAmapPlace = (props) => {
41
42
  resolve({ lng, lat, name, displayName });
42
43
  };
43
44
  readyPromise.then(() => {
44
- const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
45
45
  const pipeTw = createPipeTw(language === "zh-TW");
46
46
  const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
47
47
  const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
@@ -75,36 +75,68 @@ const useAmapPlace = (props) => {
75
75
  }
76
76
  });
77
77
  }
78
- geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
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
- }
90
- switch (status) {
91
- case "complete": {
92
- const { formattedAddress, addressComponent } = result.regeocode;
93
- const name = formattedAddress ? formattedAddress : emptyPlaceName;
94
- const displayName = amapPlaceName2DisplayName(name, {
95
- isChinese,
96
- ...addressComponent
97
- });
98
- amapReturned = true;
99
- resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
100
- return;
78
+ if (gaodeRegeoProxyUrl) {
79
+ apiGaodeRegeo({
80
+ proxyUrl: gaodeRegeoProxyUrl,
81
+ lng,
82
+ lat,
83
+ language: language === "en" ? "en" : "zh_cn"
84
+ }).then(async (result) => {
85
+ clearTimeout(timer);
86
+ if (isUseHKGovern) {
87
+ const diff = Date.now() - startTime;
88
+ console.log("==time of AmapReGeo==", diff);
89
+ const rest = HK_GOVERN_API_TIMEOUT - diff;
90
+ if (rest >= 0)
91
+ await sleep(rest);
92
+ console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
93
+ if (hkReturned)
94
+ return;
101
95
  }
102
- case "no_data":
103
- case "error": {
104
- handleFailed();
96
+ const { formatted_address, addressComponent } = result.regeocode;
97
+ const name = formatted_address || emptyPlaceName;
98
+ const displayName = amapPlaceName2DisplayName(name, {
99
+ isChinese,
100
+ ...addressComponent
101
+ });
102
+ amapReturned = true;
103
+ resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
104
+ }).catch(() => {
105
+ handleFailed();
106
+ });
107
+ } else {
108
+ const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
109
+ geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
110
+ clearTimeout(timer);
111
+ if (isUseHKGovern) {
112
+ const diff = Date.now() - startTime;
113
+ console.log("==time of AmapReGeo==", diff);
114
+ const rest = HK_GOVERN_API_TIMEOUT - diff;
115
+ if (rest >= 0)
116
+ await sleep(rest);
117
+ console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
118
+ if (hkReturned)
119
+ return;
105
120
  }
106
- }
107
- });
121
+ switch (status) {
122
+ case "complete": {
123
+ const { formattedAddress, addressComponent } = result.regeocode;
124
+ const name = formattedAddress ? formattedAddress : emptyPlaceName;
125
+ const displayName = amapPlaceName2DisplayName(name, {
126
+ isChinese,
127
+ ...addressComponent
128
+ });
129
+ amapReturned = true;
130
+ resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
131
+ return;
132
+ }
133
+ case "no_data":
134
+ case "error": {
135
+ handleFailed();
136
+ }
137
+ }
138
+ });
139
+ }
108
140
  }, handleFailed);
109
141
  const timer = setTimeout(() => {
110
142
  console.warn("高德逆地理请求超时!");
@@ -13,6 +13,7 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
13
13
  googleRoutesProxyUrl?: string;
14
14
  googleSnapRoadProxyUrl?: string;
15
15
  hkGovernRegeoProxyUrl?: string;
16
+ gaodeRegeoProxyUrl?: string;
16
17
  themeVariables?: MapThemeVariables;
17
18
  renderLoadFailedTitle?: (status: Status) => string | undefined;
18
19
  renderLoadFailedDescription?: (status: Status) => string | undefined;
@@ -1,7 +1,7 @@
1
1
  import { shallowRef } from "vue-demi";
2
2
  import { MAX_DEVIATION_DISTANCE_WALKING } from "../api/contants.js";
3
3
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
4
- import { googleServiceApiWalkingRoute, amapJsApiWalkingRoute, gaodeServiceApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
4
+ import { googleServiceApiWalkingRoute, gaodeServiceApiWalkingRoute, amapJsApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
5
5
  import { findClosestPointInLine } from "../utils/geometry.js";
6
6
  import { distanceBetweenTwoPoints } from "../utils/geometryPolygon.js";
7
7
  import { spaceLog } from "../utils/log.js";
@@ -44,12 +44,12 @@ const findBestContinuation = (args, cacheEntries) => {
44
44
  const memoizeAmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
45
45
  const memoizeGmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
46
46
  const useAWalkingRoute = (props) => {
47
- const { googleRoutesProxyUrl } = useMapSupplier();
47
+ const { googleRoutesProxyUrl, gaodeDirectionWalkingProxyUrl } = useMapSupplier();
48
48
  const pathRef = shallowRef([]);
49
49
  const amapWalking = new AMap.Walking({});
50
50
  const apiMapWalkingRoute = memoizeAmapWalkingRoute((from, to) => {
51
51
  spaceLog("apiMapWalkingRoute", `amap from = ${from} to = ${to}`);
52
- return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
52
+ return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : gaodeDirectionWalkingProxyUrl ? gaodeServiceApiWalkingRoute(from, to, gaodeDirectionWalkingProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
53
53
  });
54
54
  watchPostEffectForDeepOption(
55
55
  () => {
@@ -72,7 +72,8 @@ async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
72
72
  proxyUrl,
73
73
  origin: [from],
74
74
  destination: to,
75
- waypoints
75
+ waypoints,
76
+ ferry: 1
76
77
  });
77
78
  const trafficJams = {};
78
79
  switch (status) {
@@ -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==", JSON.stringify(geoLocationPosition), typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function");
222
223
  geoErrorMessage = void 0;
223
224
  resolve(geoLocationPosition);
224
225
  },
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.17.0-curve9";
3
+ const pkgVersion = "2.19.0-drivingRouteFail";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
@@ -119,10 +119,22 @@ const amapPlaceName2DisplayName = (name, options) => {
119
119
  };
120
120
  function amapPlaceName2DisplayNameInChinese(name, options) {
121
121
  const { province, city, district, township, building, neighborhood } = options;
122
- if (building)
123
- return building;
124
- if (neighborhood)
125
- return neighborhood;
122
+ if (typeof building === "string") {
123
+ if (building)
124
+ return building;
125
+ } else {
126
+ const { name: name2 } = building;
127
+ if (typeof name2 === "string" && name2)
128
+ return name2;
129
+ }
130
+ if (typeof neighborhood === "string") {
131
+ if (neighborhood)
132
+ return neighborhood;
133
+ } else {
134
+ const { name: name2 } = neighborhood;
135
+ if (typeof name2 === "string" && name2)
136
+ return name2;
137
+ }
126
138
  let result = name;
127
139
  for (const item of [province, city, district]) {
128
140
  const replacedName2 = result.replace(item, "");
@@ -138,10 +150,19 @@ function amapPlaceName2DisplayNameInChinese(name, options) {
138
150
  const NOT_ONLY_NUMBERS_REGEX = /[^\d\s-]/;
139
151
  function amapPlaceName2DisplayNameOutChinese(name, options) {
140
152
  const { adcode, province, city, district, township, street, streetNumber } = options;
141
- if (street === "Unnamed Road")
142
- return name;
143
- if (street || streetNumber)
144
- return `${street} ${streetNumber}`;
153
+ if (typeof streetNumber === "string") {
154
+ if (street === "Unnamed Road")
155
+ return name;
156
+ if (street || streetNumber)
157
+ return `${street} ${streetNumber}`;
158
+ } else {
159
+ const { number, street: streetNumberStreet } = streetNumber;
160
+ if (streetNumberStreet === "Unnamed Road")
161
+ return name;
162
+ const streetNumberItem = typeof number === "string" ? number : "";
163
+ if (streetNumberStreet || streetNumberItem)
164
+ return `${streetNumberStreet} ${streetNumberItem}`;
165
+ }
145
166
  const idxs = [];
146
167
  for (const token of [adcode, province, city, district, township]) {
147
168
  if (!token)
@@ -150,6 +150,7 @@ function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
150
150
  });
151
151
  return;
152
152
  }
153
+ console.log("==injected geoPosition==", JSON.stringify(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.17.0-curve9",
3
+ "version": "2.19.0-drivingRouteFail",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",