@heycar/heycars-map 2.19.0-drivingRouteFail3 → 2.19.0-drivingRouteFail5

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/api/gaodeDirectionDriving.js +2 -3
  2. package/dist/v2/api/gaodeDirectionWalking.js +2 -3
  3. package/dist/v2/api/gaodeRegeo.js +2 -3
  4. package/dist/v2/api/googleDirections.js +2 -3
  5. package/dist/v2/api/googleRoutes.d.ts +1 -0
  6. package/dist/v2/api/googleRoutes.js +8 -5
  7. package/dist/v2/api/googleSnapRoad.js +2 -3
  8. package/dist/v2/api/hongkongGovernDriving.js +2 -3
  9. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +6 -1
  10. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +8 -2
  11. package/dist/v2/business-components/DrivingRoute/DrivingRoute.d.ts +1 -0
  12. package/dist/v2/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
  13. package/dist/v2/hooks/useDrivingRoute.d.ts +3 -0
  14. package/dist/v2/hooks/useDrivingRoute.js +2 -1
  15. package/dist/v2/hooks/useDrivingTrackCorrection.d.ts +1 -0
  16. package/dist/v2/hooks/useMapPlace.js +3 -2
  17. package/dist/v2/types/interface.d.ts +1 -0
  18. package/dist/v2/utils/compatibleDrivingRoute.js +3 -3
  19. package/dist/v2/utils/log.js +1 -1
  20. package/dist/v2/utils/url.d.ts +1 -0
  21. package/dist/v2/utils/url.js +9 -0
  22. package/dist/v3/api/gaodeDirectionDriving.js +2 -3
  23. package/dist/v3/api/gaodeDirectionWalking.js +2 -3
  24. package/dist/v3/api/gaodeRegeo.js +2 -3
  25. package/dist/v3/api/googleDirections.js +2 -3
  26. package/dist/v3/api/googleRoutes.d.ts +1 -0
  27. package/dist/v3/api/googleRoutes.js +8 -5
  28. package/dist/v3/api/googleSnapRoad.js +2 -3
  29. package/dist/v3/api/hongkongGovernDriving.js +2 -3
  30. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +6 -1
  31. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +8 -2
  32. package/dist/v3/business-components/DrivingRoute/DrivingRoute.d.ts +1 -0
  33. package/dist/v3/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
  34. package/dist/v3/hooks/useDrivingRoute.d.ts +3 -0
  35. package/dist/v3/hooks/useDrivingRoute.js +2 -1
  36. package/dist/v3/hooks/useDrivingTrackCorrection.d.ts +1 -0
  37. package/dist/v3/hooks/useMapPlace.js +3 -2
  38. package/dist/v3/types/interface.d.ts +1 -0
  39. package/dist/v3/utils/compatibleDrivingRoute.js +3 -3
  40. package/dist/v3/utils/log.js +1 -1
  41. package/dist/v3/utils/url.d.ts +1 -0
  42. package/dist/v3/utils/url.js +9 -0
  43. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { gaodePointsStringify, gaodePolyline2amapLngLat } from "../utils/transform.js";
2
2
  import { createTypeError, isProxyServiceError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const GAODE_POLYLINE_REGEX = /^(?:-?\d*\.\d+,-?\d*\.\d+)?(?:;-?\d*\.\d+,-?\d*\.\d+)*$/;
4
5
  var GaodeDirectionStatus = /* @__PURE__ */ ((GaodeDirectionStatus2) => {
5
6
  GaodeDirectionStatus2["SUCCESS"] = "1";
@@ -104,9 +105,7 @@ async function apiGaodeDirectionDriving(props) {
104
105
  console.warn(error_message);
105
106
  return { status: "no_data", routes: [], error_message };
106
107
  }
107
- const { protocol, host } = location;
108
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
109
- const url = new URL(proxyUrl, baseUrl);
108
+ const url = createUrlObject(proxyUrl);
110
109
  url.searchParams.set("origin", gaodePointsStringify(origin));
111
110
  url.searchParams.set("destination", gaodePointsStringify([destination]));
112
111
  url.searchParams.set("extensions", extensions);
@@ -1,5 +1,6 @@
1
1
  import { gaodePointsStringify, gaodePolyline2amapLngLat } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  import { gaodeDirectionStatus2amapDirectionCallbackStatus, isGaodeDirectionResponse, isGaodeMeasurableObject, isGaodeDirectionBasicStep } from "./gaodeDirectionDriving.js";
4
5
  function assertGaodoDirectionWalkingStep(value) {
5
6
  if (isGaodeDirectionBasicStep(value))
@@ -58,9 +59,7 @@ async function apiGaodeDirectionWalking(props) {
58
59
  error_message
59
60
  };
60
61
  }
61
- const { protocol, host } = location;
62
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
63
- const url = new URL(proxyUrl, baseUrl);
62
+ const url = createUrlObject(proxyUrl);
64
63
  url.searchParams.set("origin", gaodePointsStringify([origin]));
65
64
  url.searchParams.set("destination", gaodePointsStringify([destination]));
66
65
  for (const key of [
@@ -1,10 +1,9 @@
1
1
  import { isProxyServiceError } from "../utils/typeChecking.js";
2
2
  import { guid } from "../utils/helper.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const apiGaodeRegeo = async (props) => {
4
5
  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);
6
+ const url = createUrlObject(proxyUrl);
8
7
  url.searchParams.set("language", language);
9
8
  url.searchParams.set("location", `${lng.toString()},${lat.toString()}`);
10
9
  url.searchParams.set("reqSid", guid());
@@ -1,5 +1,6 @@
1
1
  import { googlePointsStringify, googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const ALL_DIRECTIONS_STATUS = [
4
5
  "INVALID_REQUEST",
5
6
  "MAX_WAYPOINTS_EXCEEDED",
@@ -92,9 +93,7 @@ async function apiGoogleDirections(props) {
92
93
  error_message
93
94
  };
94
95
  }
95
- const { protocol, host } = location;
96
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
97
- const url = new URL(proxyUrl, baseUrl);
96
+ const url = createUrlObject(proxyUrl);
98
97
  url.searchParams.set("origin", googlePointsStringify([origin]));
99
98
  url.searchParams.set("destination", googlePointsStringify([destination]));
100
99
  if (waypoints && waypoints.length > 0)
@@ -19,6 +19,7 @@ type GoogleRoutesRoute = Omit<protos.google.maps.routing.v2.IRoute, "legs" | "st
19
19
  };
20
20
  export interface GoogleRoutesResponse {
21
21
  routes: GoogleRoutesRoute[];
22
+ isCrossBorder?: boolean;
22
23
  }
23
24
  interface ApiGoogleRoutesProps extends protos.google.maps.routing.v2.IComputeRoutesRequest {
24
25
  proxyUrl?: string;
@@ -1,5 +1,6 @@
1
1
  import { googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const DEFAULT_GOOGLE_ROUTES_FIELDS = ["routes.polyline", "routes.legs"];
4
5
  const ALL_ROUTES_STATUS = [
5
6
  "OK",
@@ -85,7 +86,11 @@ function assertGoogleRoutesRoute(value) {
85
86
  }
86
87
  }
87
88
  function assertGoogleRoutesResponse(value) {
88
- if (typeof value !== "object" || value === null || !("routes" in value) || !Array.isArray(value.routes))
89
+ if (typeof value !== "object" || value === null)
90
+ throw createTypeError("GoogleRoutesResponse", value);
91
+ if ("isCrossBorder" in value && value.isCrossBorder)
92
+ return;
93
+ if (!("routes" in value) || !Array.isArray(value.routes))
89
94
  throw createTypeError("GoogleRoutesResponse", value);
90
95
  try {
91
96
  for (const route of value.routes) {
@@ -100,11 +105,9 @@ async function apiGoogleRoutes(props) {
100
105
  const { proxyUrl, ...request } = props;
101
106
  if (!proxyUrl) {
102
107
  console.warn("Warning: google routes service is bypassed due to proxyUrl is not provided!");
103
- return { routes: [] };
108
+ return { routes: [], isCrossBorder: false };
104
109
  }
105
- const { protocol, host } = location;
106
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
107
- const url = new URL(proxyUrl, baseUrl);
110
+ const url = createUrlObject(proxyUrl);
108
111
  url.searchParams.set("fields", DEFAULT_GOOGLE_ROUTES_FIELDS.join(","));
109
112
  const response = await fetch(url, {
110
113
  method: "POST",
@@ -1,5 +1,6 @@
1
1
  import { googlePointsStringify } from "../utils/transform.js";
2
2
  import { isProxyServiceError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const point2snappedPoint = (point) => {
4
5
  const [longitude, latitude] = point;
5
6
  return { location: { longitude, latitude }, placeId: "" };
@@ -37,9 +38,7 @@ async function apiGoogleSnapRoad(props) {
37
38
  snappedPoints: path.map(point2snappedPoint),
38
39
  warningMessage: "Warning: snapRoad service is bypassed due to proxyUrl is not provided!"
39
40
  };
40
- const { protocol, host } = location;
41
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
42
- const url = new URL(proxyUrl, baseUrl);
41
+ const url = createUrlObject(proxyUrl);
43
42
  if (interpolate !== void 0)
44
43
  url.searchParams.set("interpolate", String(interpolate));
45
44
  url.searchParams.set("path", googlePointsStringify(path));
@@ -1,11 +1,10 @@
1
1
  import { isProxyServiceError } from "../utils/typeChecking.js";
2
2
  import { guid } from "../utils/helper.js";
3
3
  import { wgs84ToHK80 } from "../utils/transform.js";
4
+ import { createUrlObject } from "../utils/url.js";
4
5
  const apiHongKongGovernDriving = async (props) => {
5
6
  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);
7
+ const url = createUrlObject(proxyUrl);
9
8
  const hk80Coord = wgs84ToHK80(lat, lng);
10
9
  url.searchParams.set("lang", language);
11
10
  url.searchParams.set("x", hk80Coord.x.toString());
@@ -18,7 +18,12 @@ 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
+ onDrivingRouteDone?: (drivingRouteDoneProps: {
22
+ hasRoute: boolean;
23
+ distance: number;
24
+ duration: number;
25
+ isCrossBorder: boolean;
26
+ }) => void;
22
27
  };
23
28
  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
29
  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>;
@@ -121,10 +121,16 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
121
121
  duration,
122
122
  tolls,
123
123
  trafficJams,
124
- init
124
+ init,
125
+ isCrossBorder = false
125
126
  }) => {
126
127
  if (!init)
127
- emit("drivingRouteDone", path.length !== 0);
128
+ emit("drivingRouteDone", {
129
+ hasRoute: path.length !== 0,
130
+ distance: distance2,
131
+ duration,
132
+ isCrossBorder
133
+ });
128
134
  return [h(TrafficDrivingLine, {
129
135
  "attrs": {
130
136
  "path": path,
@@ -8,6 +8,7 @@ export type DrivingRouteRenderProps = {
8
8
  duration: number;
9
9
  tolls?: number;
10
10
  trafficJams?: TrafficJams;
11
+ isCrossBorder?: boolean;
11
12
  init: boolean;
12
13
  };
13
14
  export interface DrivingRouteProps extends UseDrivingRouteProps {
@@ -29,6 +29,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
29
29
  distance: number;
30
30
  }[];
31
31
  trafficJams?: import("../types/interface").TrafficJams | undefined;
32
+ isCrossBorder?: boolean | undefined;
32
33
  };
33
34
  index: number;
34
35
  path: [number, number][];
@@ -41,6 +42,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
41
42
  distance: number;
42
43
  }[];
43
44
  trafficJams?: import("../types/interface").TrafficJams | undefined;
45
+ isCrossBorder?: boolean | undefined;
44
46
  };
45
47
  angleRef: import("vue-demi").Ref<number>;
46
48
  graspRoadPathRef: import("vue-demi").Ref<Point[] | undefined>;
@@ -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
+ isCrossBorder?: boolean | undefined;
19
20
  init: boolean;
20
21
  };
21
22
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
@@ -32,6 +33,7 @@ export declare const useGDrivingRoute: (props?: UseDrivingRouteProps) => {
32
33
  distance: number;
33
34
  }[];
34
35
  trafficJams?: import("../types/interface").TrafficJams | undefined;
36
+ isCrossBorder?: boolean | undefined;
35
37
  init: boolean;
36
38
  };
37
39
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
@@ -48,6 +50,7 @@ export declare const useDrivingRoute: (props?: UseDrivingRouteProps) => {
48
50
  distance: number;
49
51
  }[];
50
52
  trafficJams?: import("../types/interface").TrafficJams | undefined;
53
+ isCrossBorder?: boolean | undefined;
51
54
  init: boolean;
52
55
  };
53
56
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
@@ -12,7 +12,8 @@ const useADrivingRoute = (props) => {
12
12
  tolls: void 0,
13
13
  steps: [],
14
14
  trafficJams: void 0,
15
- init: true
15
+ init: true,
16
+ isCrossBorder: false
16
17
  });
17
18
  const amapDriving = new AMap.Driving({ ferry: 1 });
18
19
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
@@ -15,5 +15,6 @@ export declare const useDrivingTrackCorrection: (props: UseDrivingTrackCorrectio
15
15
  distance: number;
16
16
  }[];
17
17
  trafficJams?: import("../types/interface").TrafficJams | undefined;
18
+ isCrossBorder?: boolean | undefined;
18
19
  };
19
20
  export {};
@@ -94,7 +94,8 @@ const useAmapPlace = (props) => {
94
94
  return;
95
95
  }
96
96
  const { formatted_address, addressComponent } = result.regeocode;
97
- const name = formatted_address || emptyPlaceName;
97
+ const _formmatted_address = typeof formatted_address === "string" ? formatted_address : "";
98
+ const name = _formmatted_address || emptyPlaceName;
98
99
  const displayName = amapPlaceName2DisplayName(name, {
99
100
  isChinese,
100
101
  ...addressComponent
@@ -201,7 +202,7 @@ const useGmapPlace = (props) => {
201
202
  }
202
203
  });
203
204
  geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
204
- const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
205
+ const name = results[0].formatted_address || emptyPlaceName;
205
206
  const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
206
207
  resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
207
208
  }).catch(handleFailed);
@@ -79,6 +79,7 @@ export interface Route {
79
79
  tolls?: number;
80
80
  steps: RouteStep[];
81
81
  trafficJams?: TrafficJams;
82
+ isCrossBorder?: boolean;
82
83
  }
83
84
  export interface TrackPoint {
84
85
  lng: number;
@@ -195,7 +195,7 @@ async function googleServiceApiDrivingDirection(from, to, waypoints, proxyUrl) {
195
195
  }
196
196
  async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
197
197
  var _a, _b, _c, _d, _e;
198
- const { routes } = await apiGoogleRoutes({
198
+ const { routes, isCrossBorder } = await apiGoogleRoutes({
199
199
  proxyUrl,
200
200
  origin: {
201
201
  location: {
@@ -225,7 +225,7 @@ async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
225
225
  });
226
226
  const firstRoute = routes == null ? void 0 : routes[0];
227
227
  if (!firstRoute)
228
- return { path: [], distance: 0, duration: 0, steps: [] };
228
+ return { path: [], distance: 0, duration: 0, steps: [], isCrossBorder };
229
229
  let path = [];
230
230
  let distance = 0;
231
231
  let duration = 0;
@@ -244,7 +244,7 @@ async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
244
244
  });
245
245
  }
246
246
  }
247
- return { path, distance, duration, steps: routeSteps };
247
+ return { path, distance, duration, steps: routeSteps, isCrossBorder };
248
248
  }
249
249
  export {
250
250
  amapJsApiDrivingRoute,
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.19.0-drivingRouteFail3";
3
+ const pkgVersion = "2.19.0-drivingRouteFail5";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
@@ -0,0 +1 @@
1
+ export declare const createUrlObject: (proxyUrl: string) => URL;
@@ -0,0 +1,9 @@
1
+ const createUrlObject = (proxyUrl) => {
2
+ const { protocol, host } = window.location;
3
+ const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
4
+ const url = new URL(proxyUrl, baseUrl);
5
+ return url;
6
+ };
7
+ export {
8
+ createUrlObject
9
+ };
@@ -1,5 +1,6 @@
1
1
  import { gaodePointsStringify, gaodePolyline2amapLngLat } from "../utils/transform.js";
2
2
  import { createTypeError, isProxyServiceError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const GAODE_POLYLINE_REGEX = /^(?:-?\d*\.\d+,-?\d*\.\d+)?(?:;-?\d*\.\d+,-?\d*\.\d+)*$/;
4
5
  var GaodeDirectionStatus = /* @__PURE__ */ ((GaodeDirectionStatus2) => {
5
6
  GaodeDirectionStatus2["SUCCESS"] = "1";
@@ -104,9 +105,7 @@ async function apiGaodeDirectionDriving(props) {
104
105
  console.warn(error_message);
105
106
  return { status: "no_data", routes: [], error_message };
106
107
  }
107
- const { protocol, host } = location;
108
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
109
- const url = new URL(proxyUrl, baseUrl);
108
+ const url = createUrlObject(proxyUrl);
110
109
  url.searchParams.set("origin", gaodePointsStringify(origin));
111
110
  url.searchParams.set("destination", gaodePointsStringify([destination]));
112
111
  url.searchParams.set("extensions", extensions);
@@ -1,5 +1,6 @@
1
1
  import { gaodePointsStringify, gaodePolyline2amapLngLat } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  import { gaodeDirectionStatus2amapDirectionCallbackStatus, isGaodeDirectionResponse, isGaodeMeasurableObject, isGaodeDirectionBasicStep } from "./gaodeDirectionDriving.js";
4
5
  function assertGaodoDirectionWalkingStep(value) {
5
6
  if (isGaodeDirectionBasicStep(value))
@@ -58,9 +59,7 @@ async function apiGaodeDirectionWalking(props) {
58
59
  error_message
59
60
  };
60
61
  }
61
- const { protocol, host } = location;
62
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
63
- const url = new URL(proxyUrl, baseUrl);
62
+ const url = createUrlObject(proxyUrl);
64
63
  url.searchParams.set("origin", gaodePointsStringify([origin]));
65
64
  url.searchParams.set("destination", gaodePointsStringify([destination]));
66
65
  for (const key of [
@@ -1,10 +1,9 @@
1
1
  import { isProxyServiceError } from "../utils/typeChecking.js";
2
2
  import { guid } from "../utils/helper.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const apiGaodeRegeo = async (props) => {
4
5
  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);
6
+ const url = createUrlObject(proxyUrl);
8
7
  url.searchParams.set("language", language);
9
8
  url.searchParams.set("location", `${lng.toString()},${lat.toString()}`);
10
9
  url.searchParams.set("reqSid", guid());
@@ -1,5 +1,6 @@
1
1
  import { googlePointsStringify, googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const ALL_DIRECTIONS_STATUS = [
4
5
  "INVALID_REQUEST",
5
6
  "MAX_WAYPOINTS_EXCEEDED",
@@ -92,9 +93,7 @@ async function apiGoogleDirections(props) {
92
93
  error_message
93
94
  };
94
95
  }
95
- const { protocol, host } = location;
96
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
97
- const url = new URL(proxyUrl, baseUrl);
96
+ const url = createUrlObject(proxyUrl);
98
97
  url.searchParams.set("origin", googlePointsStringify([origin]));
99
98
  url.searchParams.set("destination", googlePointsStringify([destination]));
100
99
  if (waypoints && waypoints.length > 0)
@@ -19,6 +19,7 @@ type GoogleRoutesRoute = Omit<protos.google.maps.routing.v2.IRoute, "legs" | "st
19
19
  };
20
20
  export interface GoogleRoutesResponse {
21
21
  routes: GoogleRoutesRoute[];
22
+ isCrossBorder?: boolean;
22
23
  }
23
24
  interface ApiGoogleRoutesProps extends protos.google.maps.routing.v2.IComputeRoutesRequest {
24
25
  proxyUrl?: string;
@@ -1,5 +1,6 @@
1
1
  import { googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const DEFAULT_GOOGLE_ROUTES_FIELDS = ["routes.polyline", "routes.legs"];
4
5
  const ALL_ROUTES_STATUS = [
5
6
  "OK",
@@ -85,7 +86,11 @@ function assertGoogleRoutesRoute(value) {
85
86
  }
86
87
  }
87
88
  function assertGoogleRoutesResponse(value) {
88
- if (typeof value !== "object" || value === null || !("routes" in value) || !Array.isArray(value.routes))
89
+ if (typeof value !== "object" || value === null)
90
+ throw createTypeError("GoogleRoutesResponse", value);
91
+ if ("isCrossBorder" in value && value.isCrossBorder)
92
+ return;
93
+ if (!("routes" in value) || !Array.isArray(value.routes))
89
94
  throw createTypeError("GoogleRoutesResponse", value);
90
95
  try {
91
96
  for (const route of value.routes) {
@@ -100,11 +105,9 @@ async function apiGoogleRoutes(props) {
100
105
  const { proxyUrl, ...request } = props;
101
106
  if (!proxyUrl) {
102
107
  console.warn("Warning: google routes service is bypassed due to proxyUrl is not provided!");
103
- return { routes: [] };
108
+ return { routes: [], isCrossBorder: false };
104
109
  }
105
- const { protocol, host } = location;
106
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
107
- const url = new URL(proxyUrl, baseUrl);
110
+ const url = createUrlObject(proxyUrl);
108
111
  url.searchParams.set("fields", DEFAULT_GOOGLE_ROUTES_FIELDS.join(","));
109
112
  const response = await fetch(url, {
110
113
  method: "POST",
@@ -1,5 +1,6 @@
1
1
  import { googlePointsStringify } from "../utils/transform.js";
2
2
  import { isProxyServiceError } from "../utils/typeChecking.js";
3
+ import { createUrlObject } from "../utils/url.js";
3
4
  const point2snappedPoint = (point) => {
4
5
  const [longitude, latitude] = point;
5
6
  return { location: { longitude, latitude }, placeId: "" };
@@ -37,9 +38,7 @@ async function apiGoogleSnapRoad(props) {
37
38
  snappedPoints: path.map(point2snappedPoint),
38
39
  warningMessage: "Warning: snapRoad service is bypassed due to proxyUrl is not provided!"
39
40
  };
40
- const { protocol, host } = location;
41
- const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
42
- const url = new URL(proxyUrl, baseUrl);
41
+ const url = createUrlObject(proxyUrl);
43
42
  if (interpolate !== void 0)
44
43
  url.searchParams.set("interpolate", String(interpolate));
45
44
  url.searchParams.set("path", googlePointsStringify(path));
@@ -1,11 +1,10 @@
1
1
  import { isProxyServiceError } from "../utils/typeChecking.js";
2
2
  import { guid } from "../utils/helper.js";
3
3
  import { wgs84ToHK80 } from "../utils/transform.js";
4
+ import { createUrlObject } from "../utils/url.js";
4
5
  const apiHongKongGovernDriving = async (props) => {
5
6
  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);
7
+ const url = createUrlObject(proxyUrl);
9
8
  const hk80Coord = wgs84ToHK80(lat, lng);
10
9
  url.searchParams.set("lang", language);
11
10
  url.searchParams.set("x", hk80Coord.x.toString());
@@ -18,7 +18,12 @@ 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
+ onDrivingRouteDone?: (drivingRouteDoneProps: {
22
+ hasRoute: boolean;
23
+ distance: number;
24
+ duration: number;
25
+ isCrossBorder: boolean;
26
+ }) => void;
22
27
  };
23
28
  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<{
24
29
  fallback?: (() => import("vue").VNodeChild) | undefined;
@@ -107,10 +107,16 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
107
107
  duration,
108
108
  tolls,
109
109
  trafficJams,
110
- init
110
+ init,
111
+ isCrossBorder = false
111
112
  }) => {
112
113
  if (!init)
113
- emit("drivingRouteDone", path.length !== 0);
114
+ emit("drivingRouteDone", {
115
+ hasRoute: path.length !== 0,
116
+ distance: distance2,
117
+ duration,
118
+ isCrossBorder
119
+ });
114
120
  return [createVNode(TrafficDrivingLine, {
115
121
  "path": path,
116
122
  "trafficJams": trafficJams
@@ -8,6 +8,7 @@ export type DrivingRouteRenderProps = {
8
8
  duration: number;
9
9
  tolls?: number;
10
10
  trafficJams?: TrafficJams;
11
+ isCrossBorder?: boolean;
11
12
  init: boolean;
12
13
  };
13
14
  export interface DrivingRouteProps extends UseDrivingRouteProps {
@@ -29,6 +29,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
29
29
  distance: number;
30
30
  }[];
31
31
  trafficJams?: import("../types/interface").TrafficJams | undefined;
32
+ isCrossBorder?: boolean | undefined;
32
33
  };
33
34
  index: number;
34
35
  path: [number, number][];
@@ -41,6 +42,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
41
42
  distance: number;
42
43
  }[];
43
44
  trafficJams?: import("../types/interface").TrafficJams | undefined;
45
+ isCrossBorder?: boolean | undefined;
44
46
  };
45
47
  angleRef: import("vue-demi").Ref<number>;
46
48
  graspRoadPathRef: import("vue-demi").Ref<Point[] | undefined>;
@@ -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
+ isCrossBorder?: boolean | undefined;
19
20
  init: boolean;
20
21
  };
21
22
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
@@ -32,6 +33,7 @@ export declare const useGDrivingRoute: (props?: UseDrivingRouteProps) => {
32
33
  distance: number;
33
34
  }[];
34
35
  trafficJams?: import("../types/interface").TrafficJams | undefined;
36
+ isCrossBorder?: boolean | undefined;
35
37
  init: boolean;
36
38
  };
37
39
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
@@ -48,6 +50,7 @@ export declare const useDrivingRoute: (props?: UseDrivingRouteProps) => {
48
50
  distance: number;
49
51
  }[];
50
52
  trafficJams?: import("../types/interface").TrafficJams | undefined;
53
+ isCrossBorder?: boolean | undefined;
51
54
  init: boolean;
52
55
  };
53
56
  apiMapDrivingRoute: (from: Point, to: Point, waypoints?: Point[]) => Promise<Route>;
@@ -12,7 +12,8 @@ const useADrivingRoute = (props) => {
12
12
  tolls: void 0,
13
13
  steps: [],
14
14
  trafficJams: void 0,
15
- init: true
15
+ init: true,
16
+ isCrossBorder: false
16
17
  });
17
18
  const amapDriving = new AMap.Driving({ ferry: 1 });
18
19
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
@@ -15,5 +15,6 @@ export declare const useDrivingTrackCorrection: (props: UseDrivingTrackCorrectio
15
15
  distance: number;
16
16
  }[];
17
17
  trafficJams?: import("../types/interface").TrafficJams | undefined;
18
+ isCrossBorder?: boolean | undefined;
18
19
  };
19
20
  export {};
@@ -94,7 +94,8 @@ const useAmapPlace = (props) => {
94
94
  return;
95
95
  }
96
96
  const { formatted_address, addressComponent } = result.regeocode;
97
- const name = formatted_address || emptyPlaceName;
97
+ const _formmatted_address = typeof formatted_address === "string" ? formatted_address : "";
98
+ const name = _formmatted_address || emptyPlaceName;
98
99
  const displayName = amapPlaceName2DisplayName(name, {
99
100
  isChinese,
100
101
  ...addressComponent
@@ -201,7 +202,7 @@ const useGmapPlace = (props) => {
201
202
  }
202
203
  });
203
204
  geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
204
- const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
205
+ const name = results[0].formatted_address || emptyPlaceName;
205
206
  const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
206
207
  resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
207
208
  }).catch(handleFailed);
@@ -79,6 +79,7 @@ export interface Route {
79
79
  tolls?: number;
80
80
  steps: RouteStep[];
81
81
  trafficJams?: TrafficJams;
82
+ isCrossBorder?: boolean;
82
83
  }
83
84
  export interface TrackPoint {
84
85
  lng: number;
@@ -195,7 +195,7 @@ async function googleServiceApiDrivingDirection(from, to, waypoints, proxyUrl) {
195
195
  }
196
196
  async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
197
197
  var _a, _b, _c, _d, _e;
198
- const { routes } = await apiGoogleRoutes({
198
+ const { routes, isCrossBorder } = await apiGoogleRoutes({
199
199
  proxyUrl,
200
200
  origin: {
201
201
  location: {
@@ -225,7 +225,7 @@ async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
225
225
  });
226
226
  const firstRoute = routes == null ? void 0 : routes[0];
227
227
  if (!firstRoute)
228
- return { path: [], distance: 0, duration: 0, steps: [] };
228
+ return { path: [], distance: 0, duration: 0, steps: [], isCrossBorder };
229
229
  let path = [];
230
230
  let distance = 0;
231
231
  let duration = 0;
@@ -244,7 +244,7 @@ async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
244
244
  });
245
245
  }
246
246
  }
247
- return { path, distance, duration, steps: routeSteps };
247
+ return { path, distance, duration, steps: routeSteps, isCrossBorder };
248
248
  }
249
249
  export {
250
250
  amapJsApiDrivingRoute,
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.19.0-drivingRouteFail3";
3
+ const pkgVersion = "2.19.0-drivingRouteFail5";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
@@ -0,0 +1 @@
1
+ export declare const createUrlObject: (proxyUrl: string) => URL;
@@ -0,0 +1,9 @@
1
+ const createUrlObject = (proxyUrl) => {
2
+ const { protocol, host } = window.location;
3
+ const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
4
+ const url = new URL(proxyUrl, baseUrl);
5
+ return url;
6
+ };
7
+ export {
8
+ createUrlObject
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.19.0-drivingRouteFail3",
3
+ "version": "2.19.0-drivingRouteFail5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",