@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.
- package/dist/v2/api/gaodeDirectionDriving.js +2 -3
- package/dist/v2/api/gaodeDirectionWalking.js +2 -3
- package/dist/v2/api/gaodeRegeo.js +2 -3
- package/dist/v2/api/googleDirections.js +2 -3
- package/dist/v2/api/googleRoutes.d.ts +1 -0
- package/dist/v2/api/googleRoutes.js +8 -5
- package/dist/v2/api/googleSnapRoad.js +2 -3
- package/dist/v2/api/hongkongGovernDriving.js +2 -3
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +6 -1
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +8 -2
- package/dist/v2/business-components/DrivingRoute/DrivingRoute.d.ts +1 -0
- package/dist/v2/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
- package/dist/v2/hooks/useDrivingRoute.d.ts +3 -0
- package/dist/v2/hooks/useDrivingRoute.js +2 -1
- package/dist/v2/hooks/useDrivingTrackCorrection.d.ts +1 -0
- package/dist/v2/hooks/useMapPlace.js +3 -2
- package/dist/v2/types/interface.d.ts +1 -0
- package/dist/v2/utils/compatibleDrivingRoute.js +3 -3
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/url.d.ts +1 -0
- package/dist/v2/utils/url.js +9 -0
- package/dist/v3/api/gaodeDirectionDriving.js +2 -3
- package/dist/v3/api/gaodeDirectionWalking.js +2 -3
- package/dist/v3/api/gaodeRegeo.js +2 -3
- package/dist/v3/api/googleDirections.js +2 -3
- package/dist/v3/api/googleRoutes.d.ts +1 -0
- package/dist/v3/api/googleRoutes.js +8 -5
- package/dist/v3/api/googleSnapRoad.js +2 -3
- package/dist/v3/api/hongkongGovernDriving.js +2 -3
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +6 -1
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +8 -2
- package/dist/v3/business-components/DrivingRoute/DrivingRoute.d.ts +1 -0
- package/dist/v3/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
- package/dist/v3/hooks/useDrivingRoute.d.ts +3 -0
- package/dist/v3/hooks/useDrivingRoute.js +2 -1
- package/dist/v3/hooks/useDrivingTrackCorrection.d.ts +1 -0
- package/dist/v3/hooks/useMapPlace.js +3 -2
- package/dist/v3/types/interface.d.ts +1 -0
- package/dist/v3/utils/compatibleDrivingRoute.js +3 -3
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/url.d.ts +1 -0
- package/dist/v3/utils/url.js +9 -0
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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?: (
|
|
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",
|
|
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,
|
|
@@ -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 = []) => {
|
|
@@ -94,7 +94,8 @@ const useAmapPlace = (props) => {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const { formatted_address, addressComponent } = result.regeocode;
|
|
97
|
-
const
|
|
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
|
|
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);
|
|
@@ -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,
|
package/dist/v2/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.19.0-
|
|
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;
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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?: (
|
|
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",
|
|
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
|
|
@@ -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 = []) => {
|
|
@@ -94,7 +94,8 @@ const useAmapPlace = (props) => {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const { formatted_address, addressComponent } = result.regeocode;
|
|
97
|
-
const
|
|
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
|
|
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);
|
|
@@ -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,
|
package/dist/v3/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.19.0-
|
|
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;
|