@heycar/heycars-map 2.20.0-pointSource5 → 2.21.0-gmapCost

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/App.js CHANGED
@@ -19,6 +19,7 @@ const App = defineComponent({
19
19
  "language": "en",
20
20
  "supplier": supplierRef.value,
21
21
  "gaodeRegeoProxyUrl": "/overseas/amap/regeo",
22
+ "googleRegeoProxyUrl": "/overseas/maps/regeo",
22
23
  "hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
23
24
  "googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
24
25
  "googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
@@ -0,0 +1,7 @@
1
+ export interface GoogleRegeoProps {
2
+ proxyUrl: string;
3
+ lng: number;
4
+ lat: number;
5
+ language: string;
6
+ }
7
+ export declare const apiGoogleRegeo: (props: GoogleRegeoProps) => Promise<any>;
@@ -0,0 +1,28 @@
1
+ import { isProxyServiceError } from "../utils/typeChecking.js";
2
+ import { guid } from "../utils/helper.js";
3
+ import { createUrlObject } from "../utils/url.js";
4
+ const apiGoogleRegeo = async (props) => {
5
+ const { proxyUrl, lng, lat, language } = props;
6
+ const url = createUrlObject(proxyUrl);
7
+ url.searchParams.set("lang", language);
8
+ url.searchParams.set("lng", lng.toString());
9
+ url.searchParams.set("lat", 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
+ apiGoogleRegeo
28
+ };
@@ -1,6 +1,7 @@
1
1
  import { googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
3
  import { createUrlObject } from "../utils/url.js";
4
+ import { guid } from "../utils/helper.js";
4
5
  const DEFAULT_GOOGLE_ROUTES_FIELDS = ["routes.polyline", "routes.legs"];
5
6
  const ALL_ROUTES_STATUS = [
6
7
  "OK",
@@ -109,6 +110,7 @@ async function apiGoogleRoutes(props) {
109
110
  }
110
111
  const url = createUrlObject(proxyUrl);
111
112
  url.searchParams.set("fields", DEFAULT_GOOGLE_ROUTES_FIELDS.join(","));
113
+ url.searchParams.set("reqSid", guid());
112
114
  const response = await fetch(url, {
113
115
  method: "POST",
114
116
  headers: { "Content-Type": "application/json" },
@@ -116,7 +118,8 @@ async function apiGoogleRoutes(props) {
116
118
  });
117
119
  if (response.ok) {
118
120
  const result = await response.json();
119
- assertGoogleRoutesResponse(result);
121
+ if (!result.isCrossBorder)
122
+ assertGoogleRoutesResponse(result);
120
123
  return result;
121
124
  }
122
125
  const error = await response.json();
@@ -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" | "gaodeRegeoProxyUrl">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl" | "gaodeRegeoProxyUrl" | "googleRegeoProxyUrl">;
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", "gaodeRegeoProxyUrl"]);
53
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl", "gaodeRegeoProxyUrl", "googleRegeoProxyUrl"]);
54
54
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
55
55
  slots,
56
56
  emit,
@@ -1,7 +1,7 @@
1
1
  import { reactive } from "vue-demi";
2
2
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
3
  import { googleServiceApiDrivingRoute, gaodeServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
4
- import { inTaiwan, inKorean } from "./useMapInChina.js";
4
+ import { inTaiwan } from "./useMapInChina.js";
5
5
  import { useMapSupplier } from "./useMapSupplier.js";
6
6
  const useADrivingRoute = (props) => {
7
7
  const { googleRoutesProxyUrl, gaodeDirectionDrivingProxyUrl } = useMapSupplier();
@@ -48,7 +48,7 @@ const useGDrivingRoute = (props) => {
48
48
  });
49
49
  const gmapDirectionsService = new google.maps.DirectionsService();
50
50
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
51
- return gaodeDirectionDrivingProxyUrl && inKorean(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
51
+ return gaodeDirectionDrivingProxyUrl && !inTaiwan(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
52
52
  };
53
53
  watchPostEffectForDeepOption(
54
54
  () => {
@@ -5,6 +5,7 @@ export interface UseMapPlaceProps {
5
5
  pointRef: Ref<Point>;
6
6
  emptyPlaceName: string;
7
7
  signal?: AbortSignal;
8
+ findAttachedPlaceDone?: Ref<boolean>;
8
9
  onChange?: (value: Place) => any;
9
10
  }
10
11
  export declare const useAmapPlace: (props: UseMapPlaceProps) => {
@@ -5,18 +5,18 @@ import { PointSource } from "../types/interface.js";
5
5
  import { createPipeTw } from "../utils/cn2tw.js";
6
6
  import { equalAssign, AbortSignalAny, sleep } from "../utils/helper.js";
7
7
  import { getHKGovernResult } from "../utils/hongkongGovernGeoCoder.js";
8
- import { toLocalWgs84Force, amapPlaceName2DisplayName, signal2promise, gmapPlaceName2DisplayName } from "../utils/transform.js";
9
- import { inChina, inTaiwan, inHongkong } from "./useMapInChina.js";
8
+ import { amapPlaceName2DisplayName, signal2promise, toLocalWgs84Force, gmapPlaceName2DisplayName } from "../utils/transform.js";
9
+ import { inHongkong, inChina, inTaiwan } from "./useMapInChina.js";
10
10
  import { useMapSupplier } from "./useMapSupplier.js";
11
11
  import { useUpdate } from "./useUdate.js";
12
12
  import { useMapGCJ02 } from "./useMapGCJ02.js";
13
13
  import { apiGaodeRegeo } from "../api/gaodeRegeo.js";
14
+ import { apiGoogleRegeo } from "../api/apiGoogleRegeo.js";
14
15
  const useAmapPlace = (props) => {
15
16
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
16
17
  const defaultPoint = [...props.pointRef.value];
17
18
  const pointRef = ref(defaultPoint);
18
19
  const { readyPromise, language, hkGovernRegeoProxyUrl, gaodeRegeoProxyUrl } = useMapSupplier();
19
- const { toCoordinateType } = useMapGCJ02();
20
20
  const place = reactive({
21
21
  lng: pointRef.value[0],
22
22
  lat: pointRef.value[1],
@@ -36,43 +36,20 @@ const useAmapPlace = (props) => {
36
36
  };
37
37
  const getPlaceByRegeo = ([lng, lat], opt) => {
38
38
  const signal = AbortSignalAny([opt == null ? void 0 : opt.signal, inputSignal]);
39
+ const { getPlaceByRegeo: getPlaceByGmapRegeo } = useGmapPlace(props);
39
40
  const regeoPromise = new Promise((resolve) => {
40
41
  const handleFailed = () => {
41
42
  const name = emptyPlaceName;
42
43
  const displayName = emptyPlaceName;
43
44
  resolve({ lng, lat, name, displayName, pointSource: PointSource.OTHERS });
44
45
  };
46
+ const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
47
+ if (isUseHKGovern) {
48
+ return getPlaceByGmapRegeo([lng, lat], opt).then((res) => resolve(res));
49
+ }
45
50
  readyPromise.then(() => {
46
51
  const pipeTw = createPipeTw(language === "zh-TW");
47
52
  const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
48
- const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
49
- const startTime = Date.now();
50
- let hkReturned = !isUseHKGovern;
51
- let amapReturned = false;
52
- if (isUseHKGovern) {
53
- const [finalLng, finalLat] = toLocalWgs84Force([lng, lat], toCoordinateType([lng, lat]));
54
- console.log("lng:", lng, finalLng, "lat:", lat, finalLat);
55
- apiHongKongGovernDriving({
56
- proxyUrl: hkGovernRegeoProxyUrl,
57
- lng: finalLng,
58
- lat: finalLat,
59
- language: language === "zh-TW" ? "zh" : language
60
- }).then(({ result, origin }) => {
61
- var _a, _b;
62
- const hkGovernRes = getHKGovernResult((_b = (_a = result == null ? void 0 : result.data) == null ? void 0 : _a.rawResponse) == null ? void 0 : _b.results, origin);
63
- if (!amapReturned && hkGovernRes) {
64
- const name = language === "en" ? hkGovernRes.ename : hkGovernRes.cname;
65
- hkReturned = true;
66
- resolve({
67
- lng,
68
- lat,
69
- name,
70
- displayName: name,
71
- pointSource: PointSource.HKGOV
72
- });
73
- }
74
- });
75
- }
76
53
  if (gaodeRegeoProxyUrl) {
77
54
  apiGaodeRegeo({
78
55
  proxyUrl: gaodeRegeoProxyUrl,
@@ -81,16 +58,6 @@ const useAmapPlace = (props) => {
81
58
  language: language === "en" ? "en" : "zh_cn"
82
59
  }).then(async (result) => {
83
60
  clearTimeout(timer);
84
- if (isUseHKGovern) {
85
- const diff = Date.now() - startTime;
86
- console.log("==time of AmapReGeo==", diff);
87
- const rest = HK_GOVERN_API_TIMEOUT - diff;
88
- if (rest >= 0)
89
- await sleep(rest);
90
- console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
91
- if (hkReturned)
92
- return;
93
- }
94
61
  const { formatted_address, addressComponent } = result.regeocode;
95
62
  const _formmatted_address = typeof formatted_address === "string" ? formatted_address : "";
96
63
  const name = _formmatted_address || emptyPlaceName;
@@ -98,7 +65,6 @@ const useAmapPlace = (props) => {
98
65
  isChinese,
99
66
  ...addressComponent
100
67
  });
101
- amapReturned = true;
102
68
  resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName), pointSource: PointSource.GAODE });
103
69
  }).catch(() => {
104
70
  handleFailed();
@@ -107,16 +73,6 @@ const useAmapPlace = (props) => {
107
73
  const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
108
74
  geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
109
75
  clearTimeout(timer);
110
- if (isUseHKGovern) {
111
- const diff = Date.now() - startTime;
112
- console.log("==time of AmapReGeo==", diff);
113
- const rest = HK_GOVERN_API_TIMEOUT - diff;
114
- if (rest >= 0)
115
- await sleep(rest);
116
- console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
117
- if (hkReturned)
118
- return;
119
- }
120
76
  switch (status) {
121
77
  case "complete": {
122
78
  const { formattedAddress, addressComponent } = result.regeocode;
@@ -125,7 +81,6 @@ const useAmapPlace = (props) => {
125
81
  isChinese,
126
82
  ...addressComponent
127
83
  });
128
- amapReturned = true;
129
84
  resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName), pointSource: PointSource.GAODE });
130
85
  return;
131
86
  }
@@ -159,7 +114,8 @@ const useGmapPlace = (props) => {
159
114
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
160
115
  const defaultPoint = [...props.pointRef.value];
161
116
  const pointRef = ref(defaultPoint);
162
- const { readyPromise, language } = useMapSupplier();
117
+ const { readyPromise, language, googleRegeoProxyUrl, hkGovernRegeoProxyUrl } = useMapSupplier();
118
+ const { toCoordinateType } = useMapGCJ02();
163
119
  const { idx: placeKey, update } = useUpdate();
164
120
  const place = reactive({
165
121
  lng: pointRef.value[0],
@@ -178,6 +134,7 @@ const useGmapPlace = (props) => {
178
134
  place.displayName = value.displayName;
179
135
  };
180
136
  const getPlaceByRegeo = ([lng, lat], opt) => {
137
+ const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
181
138
  const signal = AbortSignalAny([opt == null ? void 0 : opt.signal, inputSignal]);
182
139
  const regeoPromise = new Promise((resolve) => {
183
140
  const handleFailed = (err) => {
@@ -187,14 +144,84 @@ const useGmapPlace = (props) => {
187
144
  const displayName = emptyPlaceName;
188
145
  resolve({ lng, lat, name, displayName, pointSource: PointSource.OTHERS });
189
146
  };
190
- readyPromise.then(() => {
191
- const geocoder = new google.maps.Geocoder();
147
+ readyPromise.then(async () => {
148
+ var _a;
192
149
  const pipeTw = createPipeTw(language === "zh-TW");
193
- geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
194
- const name = results[0].formatted_address || emptyPlaceName;
195
- const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
196
- resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName), pointSource: PointSource.GOOGLE });
197
- }).catch(handleFailed);
150
+ let hkReturned = false;
151
+ let mapReturned = false;
152
+ if (isUseHKGovern) {
153
+ const [finalLng, finalLat] = toLocalWgs84Force([lng, lat], toCoordinateType([lng, lat]));
154
+ console.log("lng:", lng, finalLng, "lat:", lat, finalLat);
155
+ apiHongKongGovernDriving({
156
+ proxyUrl: hkGovernRegeoProxyUrl,
157
+ lng: finalLng,
158
+ lat: finalLat,
159
+ language: language === "zh-TW" ? "zh" : language
160
+ }).then(({ result, origin }) => {
161
+ var _a2, _b;
162
+ const hkGovernRes = getHKGovernResult((_b = (_a2 = result == null ? void 0 : result.data) == null ? void 0 : _a2.rawResponse) == null ? void 0 : _b.results, origin);
163
+ if (mapReturned || !hkGovernRes)
164
+ return;
165
+ const name = language === "en" ? hkGovernRes.ename : hkGovernRes.cname;
166
+ hkReturned = true;
167
+ const addressInfo = {
168
+ lng,
169
+ lat,
170
+ name,
171
+ displayName: name,
172
+ pointSource: PointSource.HKGOV
173
+ };
174
+ console.log("==港府接口返回结果==", JSON.stringify(addressInfo));
175
+ resolve(addressInfo);
176
+ });
177
+ await sleep(HK_GOVERN_API_TIMEOUT);
178
+ if ((_a = props.findAttachedPlaceDone) == null ? void 0 : _a.value)
179
+ return;
180
+ if (hkReturned)
181
+ return;
182
+ console.log("==1s后推荐点和港府均未返回,开始请求谷歌逆地理==");
183
+ }
184
+ if (googleRegeoProxyUrl) {
185
+ apiGoogleRegeo({
186
+ proxyUrl: googleRegeoProxyUrl,
187
+ lng,
188
+ lat,
189
+ language
190
+ }).then((results) => {
191
+ const name = results[0].formatted_address || emptyPlaceName;
192
+ const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
193
+ if (hkReturned)
194
+ return;
195
+ mapReturned = true;
196
+ const addressInfo = {
197
+ lng,
198
+ lat,
199
+ name: pipeTw(name),
200
+ displayName: pipeTw(displayName),
201
+ pointSource: PointSource.GOOGLE
202
+ };
203
+ console.log("==谷歌逆地理返回结果==", JSON.stringify(addressInfo));
204
+ resolve(addressInfo);
205
+ }).catch(handleFailed);
206
+ } else {
207
+ const geocoder = new google.maps.Geocoder();
208
+ geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
209
+ const name = results[0].formatted_address || emptyPlaceName;
210
+ const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
211
+ if (hkReturned)
212
+ return;
213
+ mapReturned = true;
214
+ const addressInfo = {
215
+ lng,
216
+ lat,
217
+ name: pipeTw(name),
218
+ displayName: pipeTw(displayName),
219
+ pointSource: PointSource.GOOGLE
220
+ };
221
+ console.log("==谷歌逆地理返回结果==", JSON.stringify(addressInfo));
222
+ resolve(addressInfo);
223
+ }).catch(handleFailed);
224
+ }
198
225
  }, handleFailed);
199
226
  const timer = setTimeout(() => {
200
227
  console.warn("谷歌逆地理请求超时!");
@@ -52,6 +52,7 @@ const useMapRecomendPlace = (props) => {
52
52
  onChangePlace
53
53
  } = props;
54
54
  const availableRef = ref(true);
55
+ const findAttachedPlaceDone = ref(false);
55
56
  const recommendTypeRef = ref(DEFAULT_RECOMMEND_TYPE);
56
57
  const placeCandidatesRef = ref([]);
57
58
  const zoneRef = ref();
@@ -60,7 +61,8 @@ const useMapRecomendPlace = (props) => {
60
61
  const { getPlaceByRegeo } = useMapPlace({
61
62
  emptyPlaceName,
62
63
  pointRef: ref([...defaultPoint]),
63
- signal: inputSignal
64
+ signal: inputSignal,
65
+ findAttachedPlaceDone
64
66
  });
65
67
  const recomendPlace = reactive({
66
68
  lng: defaultPoint[0],
@@ -104,22 +106,30 @@ const useMapRecomendPlace = (props) => {
104
106
  const [lng, lat] = point;
105
107
  const { type, zone, available, candidates } = prevState;
106
108
  if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
107
- const reGeoPlacePromiseIgnored = recoverablyIgnoreManualAbortReject(
108
- getPlaceByRegeo(point, opt)
109
- );
110
- const {
111
- place: closestPlace,
112
- candidates: candidates2,
113
- available: available2,
114
- type: type2,
115
- zone: zone2
116
- } = await findAttachedPlace({ lng, lat, name: "", displayName: "" }, opt);
117
- if (isPlacesInclude(candidates2, closestPlace)) {
118
- return { place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
119
- }
120
- const regeoPlace = await reGeoPlacePromiseIgnored.recover();
121
- console.log("==RegeoPlace==", regeoPlace);
122
- return { place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
109
+ return new Promise((resolve) => {
110
+ findAttachedPlaceDone.value = false;
111
+ const reGeoPlacePromiseIgnored = recoverablyIgnoreManualAbortReject(
112
+ getPlaceByRegeo(point, opt)
113
+ );
114
+ findAttachedPlace({ lng, lat, name: "", displayName: "" }, opt).then(async ({
115
+ place: closestPlace,
116
+ candidates: candidates2,
117
+ available: available2,
118
+ type: type2,
119
+ zone: zone2
120
+ }) => {
121
+ findAttachedPlaceDone.value = true;
122
+ const adsorbed = isPlacesInclude(candidates2, closestPlace);
123
+ console.log("==推荐点接口==", `是否吸附:${adsorbed}`, `地址:${JSON.stringify(closestPlace)}`);
124
+ if (adsorbed) {
125
+ resolve({ place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 });
126
+ } else {
127
+ const regeoPlace = await reGeoPlacePromiseIgnored.recover();
128
+ console.log("==RegeoPlace==", regeoPlace);
129
+ resolve({ place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 });
130
+ }
131
+ });
132
+ });
123
133
  }
124
134
  if (type === "Forbidden") {
125
135
  const regeoPlace = await getPlaceByRegeo(point, opt);
@@ -14,6 +14,7 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
14
14
  googleSnapRoadProxyUrl?: string;
15
15
  hkGovernRegeoProxyUrl?: string;
16
16
  gaodeRegeoProxyUrl?: string;
17
+ googleRegeoProxyUrl?: string;
17
18
  themeVariables?: MapThemeVariables;
18
19
  renderLoadFailedTitle?: (status: Status) => string | undefined;
19
20
  renderLoadFailedDescription?: (status: Status) => string | undefined;
@@ -232,7 +232,11 @@ async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
232
232
  const routeSteps = [];
233
233
  for (const leg of firstRoute.legs) {
234
234
  distance += (_a = leg.distanceMeters) != null ? _a : 0;
235
- duration += (_b = leg.durationSeconds) != null ? _b : 0;
235
+ if (isCrossBorder) {
236
+ duration += leg.duration ? parseInt(leg.duration) : 0;
237
+ } else {
238
+ duration += (_b = leg.durationSeconds) != null ? _b : 0;
239
+ }
236
240
  const staticRatio = leg.staticDurationSeconds ? ((_c = leg.durationSeconds) != null ? _c : 0) / leg.staticDurationSeconds : 1;
237
241
  for (const step of leg.steps) {
238
242
  const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.20.0-pointSource5";
3
+ const pkgVersion = "2.21.0-gmapCost";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
package/dist/v3/App.js CHANGED
@@ -18,6 +18,7 @@ const App = /* @__PURE__ */ defineComponent({
18
18
  "language": "en",
19
19
  "supplier": supplierRef.value,
20
20
  "gaodeRegeoProxyUrl": "/overseas/amap/regeo",
21
+ "googleRegeoProxyUrl": "/overseas/maps/regeo",
21
22
  "hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
22
23
  "googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
23
24
  "googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
@@ -0,0 +1,7 @@
1
+ export interface GoogleRegeoProps {
2
+ proxyUrl: string;
3
+ lng: number;
4
+ lat: number;
5
+ language: string;
6
+ }
7
+ export declare const apiGoogleRegeo: (props: GoogleRegeoProps) => Promise<any>;
@@ -0,0 +1,28 @@
1
+ import { isProxyServiceError } from "../utils/typeChecking.js";
2
+ import { guid } from "../utils/helper.js";
3
+ import { createUrlObject } from "../utils/url.js";
4
+ const apiGoogleRegeo = async (props) => {
5
+ const { proxyUrl, lng, lat, language } = props;
6
+ const url = createUrlObject(proxyUrl);
7
+ url.searchParams.set("lang", language);
8
+ url.searchParams.set("lng", lng.toString());
9
+ url.searchParams.set("lat", 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
+ apiGoogleRegeo
28
+ };
@@ -1,6 +1,7 @@
1
1
  import { googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
2
2
  import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
3
  import { createUrlObject } from "../utils/url.js";
4
+ import { guid } from "../utils/helper.js";
4
5
  const DEFAULT_GOOGLE_ROUTES_FIELDS = ["routes.polyline", "routes.legs"];
5
6
  const ALL_ROUTES_STATUS = [
6
7
  "OK",
@@ -109,6 +110,7 @@ async function apiGoogleRoutes(props) {
109
110
  }
110
111
  const url = createUrlObject(proxyUrl);
111
112
  url.searchParams.set("fields", DEFAULT_GOOGLE_ROUTES_FIELDS.join(","));
113
+ url.searchParams.set("reqSid", guid());
112
114
  const response = await fetch(url, {
113
115
  method: "POST",
114
116
  headers: { "Content-Type": "application/json" },
@@ -116,7 +118,8 @@ async function apiGoogleRoutes(props) {
116
118
  });
117
119
  if (response.ok) {
118
120
  const result = await response.json();
119
- assertGoogleRoutesResponse(result);
121
+ if (!result.isCrossBorder)
122
+ assertGoogleRoutesResponse(result);
120
123
  return result;
121
124
  }
122
125
  const error = await response.json();
@@ -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" | "gaodeRegeoProxyUrl">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl" | "gaodeRegeoProxyUrl" | "googleRegeoProxyUrl">;
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", "gaodeRegeoProxyUrl"]);
56
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl", "gaodeRegeoProxyUrl", "googleRegeoProxyUrl"]);
57
57
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
58
58
  slots,
59
59
  emit,
@@ -1,7 +1,7 @@
1
1
  import { reactive } from "vue-demi";
2
2
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
3
  import { googleServiceApiDrivingRoute, gaodeServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
4
- import { inTaiwan, inKorean } from "./useMapInChina.js";
4
+ import { inTaiwan } from "./useMapInChina.js";
5
5
  import { useMapSupplier } from "./useMapSupplier.js";
6
6
  const useADrivingRoute = (props) => {
7
7
  const { googleRoutesProxyUrl, gaodeDirectionDrivingProxyUrl } = useMapSupplier();
@@ -48,7 +48,7 @@ const useGDrivingRoute = (props) => {
48
48
  });
49
49
  const gmapDirectionsService = new google.maps.DirectionsService();
50
50
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
51
- return gaodeDirectionDrivingProxyUrl && inKorean(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
51
+ return gaodeDirectionDrivingProxyUrl && !inTaiwan(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
52
52
  };
53
53
  watchPostEffectForDeepOption(
54
54
  () => {
@@ -5,6 +5,7 @@ export interface UseMapPlaceProps {
5
5
  pointRef: Ref<Point>;
6
6
  emptyPlaceName: string;
7
7
  signal?: AbortSignal;
8
+ findAttachedPlaceDone?: Ref<boolean>;
8
9
  onChange?: (value: Place) => any;
9
10
  }
10
11
  export declare const useAmapPlace: (props: UseMapPlaceProps) => {
@@ -5,18 +5,18 @@ import { PointSource } from "../types/interface.js";
5
5
  import { createPipeTw } from "../utils/cn2tw.js";
6
6
  import { equalAssign, AbortSignalAny, sleep } from "../utils/helper.js";
7
7
  import { getHKGovernResult } from "../utils/hongkongGovernGeoCoder.js";
8
- import { toLocalWgs84Force, amapPlaceName2DisplayName, signal2promise, gmapPlaceName2DisplayName } from "../utils/transform.js";
9
- import { inChina, inTaiwan, inHongkong } from "./useMapInChina.js";
8
+ import { amapPlaceName2DisplayName, signal2promise, toLocalWgs84Force, gmapPlaceName2DisplayName } from "../utils/transform.js";
9
+ import { inHongkong, inChina, inTaiwan } from "./useMapInChina.js";
10
10
  import { useMapSupplier } from "./useMapSupplier.js";
11
11
  import { useUpdate } from "./useUdate.js";
12
12
  import { useMapGCJ02 } from "./useMapGCJ02.js";
13
13
  import { apiGaodeRegeo } from "../api/gaodeRegeo.js";
14
+ import { apiGoogleRegeo } from "../api/apiGoogleRegeo.js";
14
15
  const useAmapPlace = (props) => {
15
16
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
16
17
  const defaultPoint = [...props.pointRef.value];
17
18
  const pointRef = ref(defaultPoint);
18
19
  const { readyPromise, language, hkGovernRegeoProxyUrl, gaodeRegeoProxyUrl } = useMapSupplier();
19
- const { toCoordinateType } = useMapGCJ02();
20
20
  const place = reactive({
21
21
  lng: pointRef.value[0],
22
22
  lat: pointRef.value[1],
@@ -36,43 +36,20 @@ const useAmapPlace = (props) => {
36
36
  };
37
37
  const getPlaceByRegeo = ([lng, lat], opt) => {
38
38
  const signal = AbortSignalAny([opt == null ? void 0 : opt.signal, inputSignal]);
39
+ const { getPlaceByRegeo: getPlaceByGmapRegeo } = useGmapPlace(props);
39
40
  const regeoPromise = new Promise((resolve) => {
40
41
  const handleFailed = () => {
41
42
  const name = emptyPlaceName;
42
43
  const displayName = emptyPlaceName;
43
44
  resolve({ lng, lat, name, displayName, pointSource: PointSource.OTHERS });
44
45
  };
46
+ const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
47
+ if (isUseHKGovern) {
48
+ return getPlaceByGmapRegeo([lng, lat], opt).then((res) => resolve(res));
49
+ }
45
50
  readyPromise.then(() => {
46
51
  const pipeTw = createPipeTw(language === "zh-TW");
47
52
  const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
48
- const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
49
- const startTime = Date.now();
50
- let hkReturned = !isUseHKGovern;
51
- let amapReturned = false;
52
- if (isUseHKGovern) {
53
- const [finalLng, finalLat] = toLocalWgs84Force([lng, lat], toCoordinateType([lng, lat]));
54
- console.log("lng:", lng, finalLng, "lat:", lat, finalLat);
55
- apiHongKongGovernDriving({
56
- proxyUrl: hkGovernRegeoProxyUrl,
57
- lng: finalLng,
58
- lat: finalLat,
59
- language: language === "zh-TW" ? "zh" : language
60
- }).then(({ result, origin }) => {
61
- var _a, _b;
62
- const hkGovernRes = getHKGovernResult((_b = (_a = result == null ? void 0 : result.data) == null ? void 0 : _a.rawResponse) == null ? void 0 : _b.results, origin);
63
- if (!amapReturned && hkGovernRes) {
64
- const name = language === "en" ? hkGovernRes.ename : hkGovernRes.cname;
65
- hkReturned = true;
66
- resolve({
67
- lng,
68
- lat,
69
- name,
70
- displayName: name,
71
- pointSource: PointSource.HKGOV
72
- });
73
- }
74
- });
75
- }
76
53
  if (gaodeRegeoProxyUrl) {
77
54
  apiGaodeRegeo({
78
55
  proxyUrl: gaodeRegeoProxyUrl,
@@ -81,16 +58,6 @@ const useAmapPlace = (props) => {
81
58
  language: language === "en" ? "en" : "zh_cn"
82
59
  }).then(async (result) => {
83
60
  clearTimeout(timer);
84
- if (isUseHKGovern) {
85
- const diff = Date.now() - startTime;
86
- console.log("==time of AmapReGeo==", diff);
87
- const rest = HK_GOVERN_API_TIMEOUT - diff;
88
- if (rest >= 0)
89
- await sleep(rest);
90
- console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
91
- if (hkReturned)
92
- return;
93
- }
94
61
  const { formatted_address, addressComponent } = result.regeocode;
95
62
  const _formmatted_address = typeof formatted_address === "string" ? formatted_address : "";
96
63
  const name = _formmatted_address || emptyPlaceName;
@@ -98,7 +65,6 @@ const useAmapPlace = (props) => {
98
65
  isChinese,
99
66
  ...addressComponent
100
67
  });
101
- amapReturned = true;
102
68
  resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName), pointSource: PointSource.GAODE });
103
69
  }).catch(() => {
104
70
  handleFailed();
@@ -107,16 +73,6 @@ const useAmapPlace = (props) => {
107
73
  const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
108
74
  geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
109
75
  clearTimeout(timer);
110
- if (isUseHKGovern) {
111
- const diff = Date.now() - startTime;
112
- console.log("==time of AmapReGeo==", diff);
113
- const rest = HK_GOVERN_API_TIMEOUT - diff;
114
- if (rest >= 0)
115
- await sleep(rest);
116
- console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
117
- if (hkReturned)
118
- return;
119
- }
120
76
  switch (status) {
121
77
  case "complete": {
122
78
  const { formattedAddress, addressComponent } = result.regeocode;
@@ -125,7 +81,6 @@ const useAmapPlace = (props) => {
125
81
  isChinese,
126
82
  ...addressComponent
127
83
  });
128
- amapReturned = true;
129
84
  resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName), pointSource: PointSource.GAODE });
130
85
  return;
131
86
  }
@@ -159,7 +114,8 @@ const useGmapPlace = (props) => {
159
114
  const { signal: inputSignal, onChange, emptyPlaceName } = props;
160
115
  const defaultPoint = [...props.pointRef.value];
161
116
  const pointRef = ref(defaultPoint);
162
- const { readyPromise, language } = useMapSupplier();
117
+ const { readyPromise, language, googleRegeoProxyUrl, hkGovernRegeoProxyUrl } = useMapSupplier();
118
+ const { toCoordinateType } = useMapGCJ02();
163
119
  const { idx: placeKey, update } = useUpdate();
164
120
  const place = reactive({
165
121
  lng: pointRef.value[0],
@@ -178,6 +134,7 @@ const useGmapPlace = (props) => {
178
134
  place.displayName = value.displayName;
179
135
  };
180
136
  const getPlaceByRegeo = ([lng, lat], opt) => {
137
+ const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
181
138
  const signal = AbortSignalAny([opt == null ? void 0 : opt.signal, inputSignal]);
182
139
  const regeoPromise = new Promise((resolve) => {
183
140
  const handleFailed = (err) => {
@@ -187,14 +144,84 @@ const useGmapPlace = (props) => {
187
144
  const displayName = emptyPlaceName;
188
145
  resolve({ lng, lat, name, displayName, pointSource: PointSource.OTHERS });
189
146
  };
190
- readyPromise.then(() => {
191
- const geocoder = new google.maps.Geocoder();
147
+ readyPromise.then(async () => {
148
+ var _a;
192
149
  const pipeTw = createPipeTw(language === "zh-TW");
193
- geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
194
- const name = results[0].formatted_address || emptyPlaceName;
195
- const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
196
- resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName), pointSource: PointSource.GOOGLE });
197
- }).catch(handleFailed);
150
+ let hkReturned = false;
151
+ let mapReturned = false;
152
+ if (isUseHKGovern) {
153
+ const [finalLng, finalLat] = toLocalWgs84Force([lng, lat], toCoordinateType([lng, lat]));
154
+ console.log("lng:", lng, finalLng, "lat:", lat, finalLat);
155
+ apiHongKongGovernDriving({
156
+ proxyUrl: hkGovernRegeoProxyUrl,
157
+ lng: finalLng,
158
+ lat: finalLat,
159
+ language: language === "zh-TW" ? "zh" : language
160
+ }).then(({ result, origin }) => {
161
+ var _a2, _b;
162
+ const hkGovernRes = getHKGovernResult((_b = (_a2 = result == null ? void 0 : result.data) == null ? void 0 : _a2.rawResponse) == null ? void 0 : _b.results, origin);
163
+ if (mapReturned || !hkGovernRes)
164
+ return;
165
+ const name = language === "en" ? hkGovernRes.ename : hkGovernRes.cname;
166
+ hkReturned = true;
167
+ const addressInfo = {
168
+ lng,
169
+ lat,
170
+ name,
171
+ displayName: name,
172
+ pointSource: PointSource.HKGOV
173
+ };
174
+ console.log("==港府接口返回结果==", JSON.stringify(addressInfo));
175
+ resolve(addressInfo);
176
+ });
177
+ await sleep(HK_GOVERN_API_TIMEOUT);
178
+ if ((_a = props.findAttachedPlaceDone) == null ? void 0 : _a.value)
179
+ return;
180
+ if (hkReturned)
181
+ return;
182
+ console.log("==1s后推荐点和港府均未返回,开始请求谷歌逆地理==");
183
+ }
184
+ if (googleRegeoProxyUrl) {
185
+ apiGoogleRegeo({
186
+ proxyUrl: googleRegeoProxyUrl,
187
+ lng,
188
+ lat,
189
+ language
190
+ }).then((results) => {
191
+ const name = results[0].formatted_address || emptyPlaceName;
192
+ const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
193
+ if (hkReturned)
194
+ return;
195
+ mapReturned = true;
196
+ const addressInfo = {
197
+ lng,
198
+ lat,
199
+ name: pipeTw(name),
200
+ displayName: pipeTw(displayName),
201
+ pointSource: PointSource.GOOGLE
202
+ };
203
+ console.log("==谷歌逆地理返回结果==", JSON.stringify(addressInfo));
204
+ resolve(addressInfo);
205
+ }).catch(handleFailed);
206
+ } else {
207
+ const geocoder = new google.maps.Geocoder();
208
+ geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
209
+ const name = results[0].formatted_address || emptyPlaceName;
210
+ const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
211
+ if (hkReturned)
212
+ return;
213
+ mapReturned = true;
214
+ const addressInfo = {
215
+ lng,
216
+ lat,
217
+ name: pipeTw(name),
218
+ displayName: pipeTw(displayName),
219
+ pointSource: PointSource.GOOGLE
220
+ };
221
+ console.log("==谷歌逆地理返回结果==", JSON.stringify(addressInfo));
222
+ resolve(addressInfo);
223
+ }).catch(handleFailed);
224
+ }
198
225
  }, handleFailed);
199
226
  const timer = setTimeout(() => {
200
227
  console.warn("谷歌逆地理请求超时!");
@@ -52,6 +52,7 @@ const useMapRecomendPlace = (props) => {
52
52
  onChangePlace
53
53
  } = props;
54
54
  const availableRef = ref(true);
55
+ const findAttachedPlaceDone = ref(false);
55
56
  const recommendTypeRef = ref(DEFAULT_RECOMMEND_TYPE);
56
57
  const placeCandidatesRef = ref([]);
57
58
  const zoneRef = ref();
@@ -60,7 +61,8 @@ const useMapRecomendPlace = (props) => {
60
61
  const { getPlaceByRegeo } = useMapPlace({
61
62
  emptyPlaceName,
62
63
  pointRef: ref([...defaultPoint]),
63
- signal: inputSignal
64
+ signal: inputSignal,
65
+ findAttachedPlaceDone
64
66
  });
65
67
  const recomendPlace = reactive({
66
68
  lng: defaultPoint[0],
@@ -104,22 +106,30 @@ const useMapRecomendPlace = (props) => {
104
106
  const [lng, lat] = point;
105
107
  const { type, zone, available, candidates } = prevState;
106
108
  if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
107
- const reGeoPlacePromiseIgnored = recoverablyIgnoreManualAbortReject(
108
- getPlaceByRegeo(point, opt)
109
- );
110
- const {
111
- place: closestPlace,
112
- candidates: candidates2,
113
- available: available2,
114
- type: type2,
115
- zone: zone2
116
- } = await findAttachedPlace({ lng, lat, name: "", displayName: "" }, opt);
117
- if (isPlacesInclude(candidates2, closestPlace)) {
118
- return { place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
119
- }
120
- const regeoPlace = await reGeoPlacePromiseIgnored.recover();
121
- console.log("==RegeoPlace==", regeoPlace);
122
- return { place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
109
+ return new Promise((resolve) => {
110
+ findAttachedPlaceDone.value = false;
111
+ const reGeoPlacePromiseIgnored = recoverablyIgnoreManualAbortReject(
112
+ getPlaceByRegeo(point, opt)
113
+ );
114
+ findAttachedPlace({ lng, lat, name: "", displayName: "" }, opt).then(async ({
115
+ place: closestPlace,
116
+ candidates: candidates2,
117
+ available: available2,
118
+ type: type2,
119
+ zone: zone2
120
+ }) => {
121
+ findAttachedPlaceDone.value = true;
122
+ const adsorbed = isPlacesInclude(candidates2, closestPlace);
123
+ console.log("==推荐点接口==", `是否吸附:${adsorbed}`, `地址:${JSON.stringify(closestPlace)}`);
124
+ if (adsorbed) {
125
+ resolve({ place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 });
126
+ } else {
127
+ const regeoPlace = await reGeoPlacePromiseIgnored.recover();
128
+ console.log("==RegeoPlace==", regeoPlace);
129
+ resolve({ place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 });
130
+ }
131
+ });
132
+ });
123
133
  }
124
134
  if (type === "Forbidden") {
125
135
  const regeoPlace = await getPlaceByRegeo(point, opt);
@@ -14,6 +14,7 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
14
14
  googleSnapRoadProxyUrl?: string;
15
15
  hkGovernRegeoProxyUrl?: string;
16
16
  gaodeRegeoProxyUrl?: string;
17
+ googleRegeoProxyUrl?: string;
17
18
  themeVariables?: MapThemeVariables;
18
19
  renderLoadFailedTitle?: (status: Status) => string | undefined;
19
20
  renderLoadFailedDescription?: (status: Status) => string | undefined;
@@ -232,7 +232,11 @@ async function googleServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
232
232
  const routeSteps = [];
233
233
  for (const leg of firstRoute.legs) {
234
234
  distance += (_a = leg.distanceMeters) != null ? _a : 0;
235
- duration += (_b = leg.durationSeconds) != null ? _b : 0;
235
+ if (isCrossBorder) {
236
+ duration += leg.duration ? parseInt(leg.duration) : 0;
237
+ } else {
238
+ duration += (_b = leg.durationSeconds) != null ? _b : 0;
239
+ }
236
240
  const staticRatio = leg.staticDurationSeconds ? ((_c = leg.durationSeconds) != null ? _c : 0) / leg.staticDurationSeconds : 1;
237
241
  for (const step of leg.steps) {
238
242
  const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.20.0-pointSource5";
3
+ const pkgVersion = "2.21.0-gmapCost";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.20.0-pointSource5",
3
+ "version": "2.21.0-gmapCost",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",