@heycar/heycars-map 2.17.0-curve8 → 2.18.0-apiLocalization
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 +9 -7
- package/dist/v2/api/gaodeRegeo.d.ts +7 -0
- package/dist/v2/api/gaodeRegeo.js +28 -0
- package/dist/v2/api/hongkongGovernDriving.d.ts +7 -1
- package/dist/v2/components/MapProvider/MapProvider.d.ts +1 -1
- package/dist/v2/components/MapProvider/MapProvider.js +1 -1
- package/dist/v2/hooks/useDrivingRoute.js +3 -3
- package/dist/v2/hooks/useMapPlace.js +72 -31
- package/dist/v2/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v2/hooks/useWalkingRoute.js +3 -3
- package/dist/v2/utils/compatibleDrivingRoute.js +2 -1
- package/dist/v2/utils/compatibleWatchPosition.js +1 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.js +29 -8
- package/dist/v2/utils/typeChecking.js +1 -0
- package/dist/v3/App.js +9 -7
- package/dist/v3/api/gaodeRegeo.d.ts +7 -0
- package/dist/v3/api/gaodeRegeo.js +28 -0
- package/dist/v3/api/hongkongGovernDriving.d.ts +7 -1
- package/dist/v3/components/MapProvider/MapProvider.d.ts +2 -1
- package/dist/v3/components/MapProvider/MapProvider.js +1 -1
- package/dist/v3/hooks/useDrivingRoute.js +3 -3
- package/dist/v3/hooks/useMapPlace.js +72 -31
- package/dist/v3/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v3/hooks/useWalkingRoute.js +3 -3
- package/dist/v3/utils/compatibleDrivingRoute.js +2 -1
- package/dist/v3/utils/compatibleWatchPosition.js +1 -0
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.js +29 -8
- package/dist/v3/utils/typeChecking.js +1 -0
- package/package.json +1 -1
package/dist/v2/App.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { h } from "vue";
|
|
2
2
|
import { defineComponent, ref } from "vue-demi";
|
|
3
3
|
import { MapProvider } from "./components/MapProvider/MapProvider.js";
|
|
4
|
-
import {
|
|
5
|
-
const gmapApiKey =
|
|
6
|
-
const gmapId =
|
|
7
|
-
const amapApiKey =
|
|
8
|
-
const amapApiSecret =
|
|
4
|
+
import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace.js";
|
|
5
|
+
const gmapApiKey = {}.VITE_GMAP_API_KEY;
|
|
6
|
+
const gmapId = {}.VITE_GMAP_MAP_ID;
|
|
7
|
+
const amapApiKey = {}.VITE_AMAP_API_KEY;
|
|
8
|
+
const amapApiSecret = {}.VITE_AMAP_API_SECRET;
|
|
9
9
|
const App = defineComponent({
|
|
10
10
|
setup() {
|
|
11
11
|
const supplierRef = ref("amap");
|
|
@@ -18,6 +18,7 @@ const App = defineComponent({
|
|
|
18
18
|
"gmapKey": gmapApiKey,
|
|
19
19
|
"language": "en",
|
|
20
20
|
"supplier": supplierRef.value,
|
|
21
|
+
"gaodeRegeoProxyUrl": "/overseas/amap/regeo",
|
|
21
22
|
"hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
|
|
22
23
|
"googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
|
|
23
24
|
"googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
|
|
@@ -42,14 +43,15 @@ const App = defineComponent({
|
|
|
42
43
|
// ZONE_FORBIDDEN_BORDER_COLOR: "#F41717",
|
|
43
44
|
},
|
|
44
45
|
"renderLoadFailedTitle": () => supplierRef.value === "gmap" ? "未能成功访问谷歌地图" : "高德地图加载失败",
|
|
45
|
-
"renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0
|
|
46
|
+
"renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0,
|
|
47
|
+
"reportLog": () => console.log("reportLog function is called")
|
|
46
48
|
},
|
|
47
49
|
"on": {
|
|
48
50
|
"success": () => console.log(`${supplierRef.value} load success`),
|
|
49
51
|
"fail": () => console.log(`${supplierRef.value} load failed`),
|
|
50
52
|
"downloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`)
|
|
51
53
|
}
|
|
52
|
-
}, [h(
|
|
54
|
+
}, [h(DemoBusinessRecomendPlace)]);
|
|
53
55
|
}
|
|
54
56
|
});
|
|
55
57
|
export {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isProxyServiceError } from "../utils/typeChecking.js";
|
|
2
|
+
import { guid } from "../utils/helper.js";
|
|
3
|
+
const apiGaodeRegeo = async (props) => {
|
|
4
|
+
const { proxyUrl, lng, lat, language } = props;
|
|
5
|
+
const { protocol, host } = location;
|
|
6
|
+
const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
|
|
7
|
+
const url = new URL(proxyUrl, baseUrl);
|
|
8
|
+
url.searchParams.set("language", language);
|
|
9
|
+
url.searchParams.set("location", `${lng.toString()},${lat.toString()}`);
|
|
10
|
+
url.searchParams.set("reqSid", guid());
|
|
11
|
+
const response = await fetch(url);
|
|
12
|
+
if (response.ok) {
|
|
13
|
+
const result = await response.json();
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
const error = await response.json();
|
|
17
|
+
if (isProxyServiceError(error)) {
|
|
18
|
+
const { code, msg } = error;
|
|
19
|
+
throw new Error(`apiGaodeRegeo proxy failed code: ${code}, msg:
|
|
20
|
+
${msg}`);
|
|
21
|
+
}
|
|
22
|
+
throw new Error(
|
|
23
|
+
`apiGaodeRegeo failed with unrecognized server response: ${JSON.stringify(error)}`
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
apiGaodeRegeo
|
|
28
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface HongKongGovernDrivingProps {
|
|
2
|
+
proxyUrl: string;
|
|
3
|
+
lng: number;
|
|
4
|
+
lat: number;
|
|
5
|
+
language: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const apiHongKongGovernDriving: (props: HongKongGovernDrivingProps) => Promise<{
|
|
2
8
|
result: any;
|
|
3
9
|
origin: {
|
|
4
10
|
x: number;
|
|
@@ -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" | "hkGovernRegeoProxyUrl">;
|
|
8
|
+
export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl" | "gaodeRegeoProxyUrl">;
|
|
9
9
|
export declare const MapProvider: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "success" | "fail" | "downloadOptimizeEnd", MapProviderProps>;
|
|
10
10
|
export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
|
|
11
11
|
mapRef?: SetMap<AmapMap> | SetMap<google.maps.Map>;
|
|
@@ -50,7 +50,7 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
|
|
|
50
50
|
var _a;
|
|
51
51
|
return h("div", [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
52
52
|
};
|
|
53
|
-
}).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "hkGovernRegeoProxyUrl"]);
|
|
53
|
+
}).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl", "gaodeRegeoProxyUrl"]);
|
|
54
54
|
const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
55
55
|
slots,
|
|
56
56
|
emit,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { reactive } from "vue-demi";
|
|
2
2
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
3
|
-
import { googleServiceApiDrivingRoute,
|
|
3
|
+
import { googleServiceApiDrivingRoute, gaodeServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
|
|
4
4
|
import { inTaiwan, inKorean } from "./useMapInChina.js";
|
|
5
5
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
6
6
|
const useADrivingRoute = (props) => {
|
|
7
|
-
const { googleRoutesProxyUrl } = useMapSupplier();
|
|
7
|
+
const { googleRoutesProxyUrl, gaodeDirectionDrivingProxyUrl } = useMapSupplier();
|
|
8
8
|
const outputRoute = reactive({
|
|
9
9
|
path: [],
|
|
10
10
|
distance: 0,
|
|
@@ -15,7 +15,7 @@ const useADrivingRoute = (props) => {
|
|
|
15
15
|
});
|
|
16
16
|
const amapDriving = new AMap.Driving({ ferry: 1 });
|
|
17
17
|
const apiMapDrivingRoute = (from, to, waypoints = []) => {
|
|
18
|
-
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
|
|
18
|
+
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
|
|
19
19
|
};
|
|
20
20
|
watchPostEffectForDeepOption(
|
|
21
21
|
() => {
|
|
@@ -9,11 +9,12 @@ import { inChina, inTaiwan, inHongkong } from "./useMapInChina.js";
|
|
|
9
9
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
10
10
|
import { useUpdate } from "./useUdate.js";
|
|
11
11
|
import { useMapGCJ02 } from "./useMapGCJ02.js";
|
|
12
|
+
import { apiGaodeRegeo } from "../api/gaodeRegeo.js";
|
|
12
13
|
const useAmapPlace = (props) => {
|
|
13
14
|
const { signal: inputSignal, onChange, emptyPlaceName } = props;
|
|
14
15
|
const defaultPoint = [...props.pointRef.value];
|
|
15
16
|
const pointRef = ref(defaultPoint);
|
|
16
|
-
const { readyPromise, language, hkGovernRegeoProxyUrl } = useMapSupplier();
|
|
17
|
+
const { readyPromise, language, hkGovernRegeoProxyUrl, gaodeRegeoProxyUrl } = useMapSupplier();
|
|
17
18
|
const { toCoordinateType } = useMapGCJ02();
|
|
18
19
|
const place = reactive({
|
|
19
20
|
lng: pointRef.value[0],
|
|
@@ -41,7 +42,6 @@ const useAmapPlace = (props) => {
|
|
|
41
42
|
resolve({ lng, lat, name, displayName });
|
|
42
43
|
};
|
|
43
44
|
readyPromise.then(() => {
|
|
44
|
-
const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
|
|
45
45
|
const pipeTw = createPipeTw(language === "zh-TW");
|
|
46
46
|
const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
|
|
47
47
|
const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
|
|
@@ -75,36 +75,68 @@ const useAmapPlace = (props) => {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
isChinese,
|
|
96
|
-
...addressComponent
|
|
97
|
-
});
|
|
98
|
-
amapReturned = true;
|
|
99
|
-
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
100
|
-
return;
|
|
78
|
+
if (gaodeRegeoProxyUrl) {
|
|
79
|
+
apiGaodeRegeo({
|
|
80
|
+
proxyUrl: gaodeRegeoProxyUrl,
|
|
81
|
+
lng,
|
|
82
|
+
lat,
|
|
83
|
+
language: language === "en" ? "en" : "zh_cn"
|
|
84
|
+
}).then(async (result) => {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
if (isUseHKGovern) {
|
|
87
|
+
const diff = Date.now() - startTime;
|
|
88
|
+
console.log("==time of AmapReGeo==", diff);
|
|
89
|
+
const rest = HK_GOVERN_API_TIMEOUT - diff;
|
|
90
|
+
if (rest >= 0)
|
|
91
|
+
await sleep(rest);
|
|
92
|
+
console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
|
|
93
|
+
if (hkReturned)
|
|
94
|
+
return;
|
|
101
95
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
const { formatted_address, addressComponent } = result.regeocode;
|
|
97
|
+
const name = formatted_address || emptyPlaceName;
|
|
98
|
+
const displayName = amapPlaceName2DisplayName(name, {
|
|
99
|
+
isChinese,
|
|
100
|
+
...addressComponent
|
|
101
|
+
});
|
|
102
|
+
amapReturned = true;
|
|
103
|
+
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
104
|
+
}).catch(() => {
|
|
105
|
+
handleFailed();
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
|
|
109
|
+
geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
if (isUseHKGovern) {
|
|
112
|
+
const diff = Date.now() - startTime;
|
|
113
|
+
console.log("==time of AmapReGeo==", diff);
|
|
114
|
+
const rest = HK_GOVERN_API_TIMEOUT - diff;
|
|
115
|
+
if (rest >= 0)
|
|
116
|
+
await sleep(rest);
|
|
117
|
+
console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
|
|
118
|
+
if (hkReturned)
|
|
119
|
+
return;
|
|
105
120
|
}
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
switch (status) {
|
|
122
|
+
case "complete": {
|
|
123
|
+
const { formattedAddress, addressComponent } = result.regeocode;
|
|
124
|
+
const name = formattedAddress ? formattedAddress : emptyPlaceName;
|
|
125
|
+
const displayName = amapPlaceName2DisplayName(name, {
|
|
126
|
+
isChinese,
|
|
127
|
+
...addressComponent
|
|
128
|
+
});
|
|
129
|
+
amapReturned = true;
|
|
130
|
+
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
case "no_data":
|
|
134
|
+
case "error": {
|
|
135
|
+
handleFailed();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
108
140
|
}, handleFailed);
|
|
109
141
|
const timer = setTimeout(() => {
|
|
110
142
|
console.warn("高德逆地理请求超时!");
|
|
@@ -128,7 +160,7 @@ const useGmapPlace = (props) => {
|
|
|
128
160
|
const { signal: inputSignal, onChange, emptyPlaceName } = props;
|
|
129
161
|
const defaultPoint = [...props.pointRef.value];
|
|
130
162
|
const pointRef = ref(defaultPoint);
|
|
131
|
-
const { readyPromise, language } = useMapSupplier();
|
|
163
|
+
const { readyPromise, language, reportLog } = useMapSupplier();
|
|
132
164
|
const { idx: placeKey, update } = useUpdate();
|
|
133
165
|
const place = reactive({
|
|
134
166
|
lng: pointRef.value[0],
|
|
@@ -159,6 +191,15 @@ const useGmapPlace = (props) => {
|
|
|
159
191
|
readyPromise.then(() => {
|
|
160
192
|
const geocoder = new google.maps.Geocoder();
|
|
161
193
|
const pipeTw = createPipeTw(language === "zh-TW");
|
|
194
|
+
reportLog == null ? void 0 : reportLog({
|
|
195
|
+
operation: "google_regeo",
|
|
196
|
+
eventType: "ServiceLogic",
|
|
197
|
+
message: {
|
|
198
|
+
lng,
|
|
199
|
+
lat,
|
|
200
|
+
language
|
|
201
|
+
}
|
|
202
|
+
});
|
|
162
203
|
geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
|
|
163
204
|
const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
|
|
164
205
|
const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
|
|
@@ -13,9 +13,11 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
|
|
|
13
13
|
googleRoutesProxyUrl?: string;
|
|
14
14
|
googleSnapRoadProxyUrl?: string;
|
|
15
15
|
hkGovernRegeoProxyUrl?: string;
|
|
16
|
+
gaodeRegeoProxyUrl?: string;
|
|
16
17
|
themeVariables?: MapThemeVariables;
|
|
17
18
|
renderLoadFailedTitle?: (status: Status) => string | undefined;
|
|
18
19
|
renderLoadFailedDescription?: (status: Status) => string | undefined;
|
|
20
|
+
reportLog?: (data: any) => void;
|
|
19
21
|
}
|
|
20
22
|
export declare const useMapSupplier: () => MapSupplierPayolad;
|
|
21
23
|
export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { shallowRef } from "vue-demi";
|
|
2
2
|
import { MAX_DEVIATION_DISTANCE_WALKING } from "../api/contants.js";
|
|
3
3
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
4
|
-
import { googleServiceApiWalkingRoute,
|
|
4
|
+
import { googleServiceApiWalkingRoute, gaodeServiceApiWalkingRoute, amapJsApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
|
|
5
5
|
import { findClosestPointInLine } from "../utils/geometry.js";
|
|
6
6
|
import { distanceBetweenTwoPoints } from "../utils/geometryPolygon.js";
|
|
7
7
|
import { spaceLog } from "../utils/log.js";
|
|
@@ -44,12 +44,12 @@ const findBestContinuation = (args, cacheEntries) => {
|
|
|
44
44
|
const memoizeAmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
|
|
45
45
|
const memoizeGmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
|
|
46
46
|
const useAWalkingRoute = (props) => {
|
|
47
|
-
const { googleRoutesProxyUrl } = useMapSupplier();
|
|
47
|
+
const { googleRoutesProxyUrl, gaodeDirectionWalkingProxyUrl } = useMapSupplier();
|
|
48
48
|
const pathRef = shallowRef([]);
|
|
49
49
|
const amapWalking = new AMap.Walking({});
|
|
50
50
|
const apiMapWalkingRoute = memoizeAmapWalkingRoute((from, to) => {
|
|
51
51
|
spaceLog("apiMapWalkingRoute", `amap from = ${from} to = ${to}`);
|
|
52
|
-
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
|
|
52
|
+
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : gaodeDirectionWalkingProxyUrl ? gaodeServiceApiWalkingRoute(from, to, gaodeDirectionWalkingProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
|
|
53
53
|
});
|
|
54
54
|
watchPostEffectForDeepOption(
|
|
55
55
|
() => {
|
|
@@ -219,6 +219,7 @@ function androidWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
|
219
219
|
if (isHandled)
|
|
220
220
|
return;
|
|
221
221
|
isHandled = true;
|
|
222
|
+
console.log("==GeoLocation assert==", JSON.stringify(geoLocationPosition), typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function");
|
|
222
223
|
geoErrorMessage = void 0;
|
|
223
224
|
resolve(geoLocationPosition);
|
|
224
225
|
},
|
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.
|
|
3
|
+
const pkgVersion = "2.18.0-apiLocalization";
|
|
4
4
|
const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
|
|
5
5
|
const enableSessionLogKey = (key) => {
|
|
6
6
|
const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
|
|
@@ -119,10 +119,22 @@ const amapPlaceName2DisplayName = (name, options) => {
|
|
|
119
119
|
};
|
|
120
120
|
function amapPlaceName2DisplayNameInChinese(name, options) {
|
|
121
121
|
const { province, city, district, township, building, neighborhood } = options;
|
|
122
|
-
if (building)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
if (typeof building === "string") {
|
|
123
|
+
if (building)
|
|
124
|
+
return building;
|
|
125
|
+
} else {
|
|
126
|
+
const { name: name2 } = building;
|
|
127
|
+
if (typeof name2 === "string" && name2)
|
|
128
|
+
return name2;
|
|
129
|
+
}
|
|
130
|
+
if (typeof neighborhood === "string") {
|
|
131
|
+
if (neighborhood)
|
|
132
|
+
return neighborhood;
|
|
133
|
+
} else {
|
|
134
|
+
const { name: name2 } = neighborhood;
|
|
135
|
+
if (typeof name2 === "string" && name2)
|
|
136
|
+
return name2;
|
|
137
|
+
}
|
|
126
138
|
let result = name;
|
|
127
139
|
for (const item of [province, city, district]) {
|
|
128
140
|
const replacedName2 = result.replace(item, "");
|
|
@@ -138,10 +150,19 @@ function amapPlaceName2DisplayNameInChinese(name, options) {
|
|
|
138
150
|
const NOT_ONLY_NUMBERS_REGEX = /[^\d\s-]/;
|
|
139
151
|
function amapPlaceName2DisplayNameOutChinese(name, options) {
|
|
140
152
|
const { adcode, province, city, district, township, street, streetNumber } = options;
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
if (typeof streetNumber === "string") {
|
|
154
|
+
if (street === "Unnamed Road")
|
|
155
|
+
return name;
|
|
156
|
+
if (street || streetNumber)
|
|
157
|
+
return `${street} ${streetNumber}`;
|
|
158
|
+
} else {
|
|
159
|
+
const { number, street: streetNumberStreet } = streetNumber;
|
|
160
|
+
if (streetNumberStreet === "Unnamed Road")
|
|
161
|
+
return name;
|
|
162
|
+
const streetNumberItem = typeof number === "string" ? number : "";
|
|
163
|
+
if (streetNumberStreet || streetNumberItem)
|
|
164
|
+
return `${streetNumberStreet} ${streetNumberItem}`;
|
|
165
|
+
}
|
|
145
166
|
const idxs = [];
|
|
146
167
|
for (const token of [adcode, province, city, district, township]) {
|
|
147
168
|
if (!token)
|
|
@@ -150,6 +150,7 @@ function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
|
|
|
150
150
|
});
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
+
console.log("==injected geoPosition==", JSON.stringify(position));
|
|
153
154
|
onSuccess(position);
|
|
154
155
|
};
|
|
155
156
|
const asseertedOnError = (error) => onError(toGeolocationPositionError(error, prefix));
|
package/dist/v3/App.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createVNode } from "vue";
|
|
2
2
|
import { defineComponent, ref } from "vue-demi";
|
|
3
3
|
import { MapProvider } from "./components/MapProvider/MapProvider.js";
|
|
4
|
-
import {
|
|
5
|
-
const gmapApiKey =
|
|
6
|
-
const gmapId =
|
|
7
|
-
const amapApiKey =
|
|
8
|
-
const amapApiSecret =
|
|
4
|
+
import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace.js";
|
|
5
|
+
const gmapApiKey = {}.VITE_GMAP_API_KEY;
|
|
6
|
+
const gmapId = {}.VITE_GMAP_MAP_ID;
|
|
7
|
+
const amapApiKey = {}.VITE_AMAP_API_KEY;
|
|
8
|
+
const amapApiSecret = {}.VITE_AMAP_API_SECRET;
|
|
9
9
|
const App = /* @__PURE__ */ defineComponent({
|
|
10
10
|
setup() {
|
|
11
11
|
const supplierRef = ref("amap");
|
|
@@ -17,6 +17,7 @@ const App = /* @__PURE__ */ defineComponent({
|
|
|
17
17
|
"gmapKey": gmapApiKey,
|
|
18
18
|
"language": "en",
|
|
19
19
|
"supplier": supplierRef.value,
|
|
20
|
+
"gaodeRegeoProxyUrl": "/overseas/amap/regeo",
|
|
20
21
|
"hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
|
|
21
22
|
"googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
|
|
22
23
|
"googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
|
|
@@ -44,9 +45,10 @@ const App = /* @__PURE__ */ defineComponent({
|
|
|
44
45
|
"renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0,
|
|
45
46
|
"onSuccess": () => console.log(`${supplierRef.value} load success`),
|
|
46
47
|
"onFail": () => console.log(`${supplierRef.value} load failed`),
|
|
47
|
-
"onDownloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`)
|
|
48
|
+
"onDownloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`),
|
|
49
|
+
"reportLog": () => console.log("reportLog function is called")
|
|
48
50
|
}, {
|
|
49
|
-
default: () => [createVNode(
|
|
51
|
+
default: () => [createVNode(DemoBusinessRecomendPlace, null, null)]
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isProxyServiceError } from "../utils/typeChecking.js";
|
|
2
|
+
import { guid } from "../utils/helper.js";
|
|
3
|
+
const apiGaodeRegeo = async (props) => {
|
|
4
|
+
const { proxyUrl, lng, lat, language } = props;
|
|
5
|
+
const { protocol, host } = location;
|
|
6
|
+
const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
|
|
7
|
+
const url = new URL(proxyUrl, baseUrl);
|
|
8
|
+
url.searchParams.set("language", language);
|
|
9
|
+
url.searchParams.set("location", `${lng.toString()},${lat.toString()}`);
|
|
10
|
+
url.searchParams.set("reqSid", guid());
|
|
11
|
+
const response = await fetch(url);
|
|
12
|
+
if (response.ok) {
|
|
13
|
+
const result = await response.json();
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
const error = await response.json();
|
|
17
|
+
if (isProxyServiceError(error)) {
|
|
18
|
+
const { code, msg } = error;
|
|
19
|
+
throw new Error(`apiGaodeRegeo proxy failed code: ${code}, msg:
|
|
20
|
+
${msg}`);
|
|
21
|
+
}
|
|
22
|
+
throw new Error(
|
|
23
|
+
`apiGaodeRegeo failed with unrecognized server response: ${JSON.stringify(error)}`
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
apiGaodeRegeo
|
|
28
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface HongKongGovernDrivingProps {
|
|
2
|
+
proxyUrl: string;
|
|
3
|
+
lng: number;
|
|
4
|
+
lat: number;
|
|
5
|
+
language: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const apiHongKongGovernDriving: (props: HongKongGovernDrivingProps) => Promise<{
|
|
2
8
|
result: any;
|
|
3
9
|
origin: {
|
|
4
10
|
x: number;
|
|
@@ -5,10 +5,11 @@ 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" | "hkGovernRegeoProxyUrl">;
|
|
8
|
+
export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "gaodeDirectionDrivingProxyUrl" | "gaodeDirectionWalkingProxyUrl" | "googleDirectionsProxyUrl" | "googleRoutesProxyUrl" | "googleSnapRoadProxyUrl" | "themeVariables" | "renderLoadFailedTitle" | "renderLoadFailedDescription" | "reportLog" | "hkGovernRegeoProxyUrl" | "gaodeRegeoProxyUrl">;
|
|
9
9
|
export declare const MapProvider: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "success" | "fail" | "downloadOptimizeEnd", import("vue-demi").PublicProps, MapProviderProps, MapProviderProps, import("vue-demi").SlotsType<{
|
|
10
10
|
renderLoadFailedTitle?: ((status: Status) => string | undefined) | undefined;
|
|
11
11
|
renderLoadFailedDescription?: ((status: Status) => string | undefined) | undefined;
|
|
12
|
+
reportLog?: ((data: any) => void) | undefined;
|
|
12
13
|
} & {
|
|
13
14
|
default?: import("../../demi-polyfill").Slot | undefined;
|
|
14
15
|
}>>;
|
|
@@ -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", "hkGovernRegeoProxyUrl"]);
|
|
56
|
+
}).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "gaodeDirectionDrivingProxyUrl", "gaodeDirectionWalkingProxyUrl", "googleDirectionsProxyUrl", "googleRoutesProxyUrl", "googleSnapRoadProxyUrl", "themeVariables", "renderLoadFailedTitle", "renderLoadFailedDescription", "reportLog", "hkGovernRegeoProxyUrl", "gaodeRegeoProxyUrl"]);
|
|
57
57
|
const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
58
58
|
slots,
|
|
59
59
|
emit,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { reactive } from "vue-demi";
|
|
2
2
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
3
|
-
import { googleServiceApiDrivingRoute,
|
|
3
|
+
import { googleServiceApiDrivingRoute, gaodeServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
|
|
4
4
|
import { inTaiwan, inKorean } from "./useMapInChina.js";
|
|
5
5
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
6
6
|
const useADrivingRoute = (props) => {
|
|
7
|
-
const { googleRoutesProxyUrl } = useMapSupplier();
|
|
7
|
+
const { googleRoutesProxyUrl, gaodeDirectionDrivingProxyUrl } = useMapSupplier();
|
|
8
8
|
const outputRoute = reactive({
|
|
9
9
|
path: [],
|
|
10
10
|
distance: 0,
|
|
@@ -15,7 +15,7 @@ const useADrivingRoute = (props) => {
|
|
|
15
15
|
});
|
|
16
16
|
const amapDriving = new AMap.Driving({ ferry: 1 });
|
|
17
17
|
const apiMapDrivingRoute = (from, to, waypoints = []) => {
|
|
18
|
-
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
|
|
18
|
+
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
|
|
19
19
|
};
|
|
20
20
|
watchPostEffectForDeepOption(
|
|
21
21
|
() => {
|
|
@@ -9,11 +9,12 @@ import { inChina, inTaiwan, inHongkong } from "./useMapInChina.js";
|
|
|
9
9
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
10
10
|
import { useUpdate } from "./useUdate.js";
|
|
11
11
|
import { useMapGCJ02 } from "./useMapGCJ02.js";
|
|
12
|
+
import { apiGaodeRegeo } from "../api/gaodeRegeo.js";
|
|
12
13
|
const useAmapPlace = (props) => {
|
|
13
14
|
const { signal: inputSignal, onChange, emptyPlaceName } = props;
|
|
14
15
|
const defaultPoint = [...props.pointRef.value];
|
|
15
16
|
const pointRef = ref(defaultPoint);
|
|
16
|
-
const { readyPromise, language, hkGovernRegeoProxyUrl } = useMapSupplier();
|
|
17
|
+
const { readyPromise, language, hkGovernRegeoProxyUrl, gaodeRegeoProxyUrl } = useMapSupplier();
|
|
17
18
|
const { toCoordinateType } = useMapGCJ02();
|
|
18
19
|
const place = reactive({
|
|
19
20
|
lng: pointRef.value[0],
|
|
@@ -41,7 +42,6 @@ const useAmapPlace = (props) => {
|
|
|
41
42
|
resolve({ lng, lat, name, displayName });
|
|
42
43
|
};
|
|
43
44
|
readyPromise.then(() => {
|
|
44
|
-
const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
|
|
45
45
|
const pipeTw = createPipeTw(language === "zh-TW");
|
|
46
46
|
const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
|
|
47
47
|
const isUseHKGovern = inHongkong([lng, lat]) && hkGovernRegeoProxyUrl;
|
|
@@ -75,36 +75,68 @@ const useAmapPlace = (props) => {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
isChinese,
|
|
96
|
-
...addressComponent
|
|
97
|
-
});
|
|
98
|
-
amapReturned = true;
|
|
99
|
-
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
100
|
-
return;
|
|
78
|
+
if (gaodeRegeoProxyUrl) {
|
|
79
|
+
apiGaodeRegeo({
|
|
80
|
+
proxyUrl: gaodeRegeoProxyUrl,
|
|
81
|
+
lng,
|
|
82
|
+
lat,
|
|
83
|
+
language: language === "en" ? "en" : "zh_cn"
|
|
84
|
+
}).then(async (result) => {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
if (isUseHKGovern) {
|
|
87
|
+
const diff = Date.now() - startTime;
|
|
88
|
+
console.log("==time of AmapReGeo==", diff);
|
|
89
|
+
const rest = HK_GOVERN_API_TIMEOUT - diff;
|
|
90
|
+
if (rest >= 0)
|
|
91
|
+
await sleep(rest);
|
|
92
|
+
console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
|
|
93
|
+
if (hkReturned)
|
|
94
|
+
return;
|
|
101
95
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
const { formatted_address, addressComponent } = result.regeocode;
|
|
97
|
+
const name = formatted_address || emptyPlaceName;
|
|
98
|
+
const displayName = amapPlaceName2DisplayName(name, {
|
|
99
|
+
isChinese,
|
|
100
|
+
...addressComponent
|
|
101
|
+
});
|
|
102
|
+
amapReturned = true;
|
|
103
|
+
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
104
|
+
}).catch(() => {
|
|
105
|
+
handleFailed();
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
|
|
109
|
+
geocoder.getAddress(new AMap.LngLat(lng, lat), async (status, result) => {
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
if (isUseHKGovern) {
|
|
112
|
+
const diff = Date.now() - startTime;
|
|
113
|
+
console.log("==time of AmapReGeo==", diff);
|
|
114
|
+
const rest = HK_GOVERN_API_TIMEOUT - diff;
|
|
115
|
+
if (rest >= 0)
|
|
116
|
+
await sleep(rest);
|
|
117
|
+
console.log("==time of AmapReGeoWaitEnd==", Date.now() - startTime);
|
|
118
|
+
if (hkReturned)
|
|
119
|
+
return;
|
|
105
120
|
}
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
switch (status) {
|
|
122
|
+
case "complete": {
|
|
123
|
+
const { formattedAddress, addressComponent } = result.regeocode;
|
|
124
|
+
const name = formattedAddress ? formattedAddress : emptyPlaceName;
|
|
125
|
+
const displayName = amapPlaceName2DisplayName(name, {
|
|
126
|
+
isChinese,
|
|
127
|
+
...addressComponent
|
|
128
|
+
});
|
|
129
|
+
amapReturned = true;
|
|
130
|
+
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
case "no_data":
|
|
134
|
+
case "error": {
|
|
135
|
+
handleFailed();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
108
140
|
}, handleFailed);
|
|
109
141
|
const timer = setTimeout(() => {
|
|
110
142
|
console.warn("高德逆地理请求超时!");
|
|
@@ -128,7 +160,7 @@ const useGmapPlace = (props) => {
|
|
|
128
160
|
const { signal: inputSignal, onChange, emptyPlaceName } = props;
|
|
129
161
|
const defaultPoint = [...props.pointRef.value];
|
|
130
162
|
const pointRef = ref(defaultPoint);
|
|
131
|
-
const { readyPromise, language } = useMapSupplier();
|
|
163
|
+
const { readyPromise, language, reportLog } = useMapSupplier();
|
|
132
164
|
const { idx: placeKey, update } = useUpdate();
|
|
133
165
|
const place = reactive({
|
|
134
166
|
lng: pointRef.value[0],
|
|
@@ -159,6 +191,15 @@ const useGmapPlace = (props) => {
|
|
|
159
191
|
readyPromise.then(() => {
|
|
160
192
|
const geocoder = new google.maps.Geocoder();
|
|
161
193
|
const pipeTw = createPipeTw(language === "zh-TW");
|
|
194
|
+
reportLog == null ? void 0 : reportLog({
|
|
195
|
+
operation: "google_regeo",
|
|
196
|
+
eventType: "ServiceLogic",
|
|
197
|
+
message: {
|
|
198
|
+
lng,
|
|
199
|
+
lat,
|
|
200
|
+
language
|
|
201
|
+
}
|
|
202
|
+
});
|
|
162
203
|
geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
|
|
163
204
|
const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
|
|
164
205
|
const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
|
|
@@ -13,9 +13,11 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
|
|
|
13
13
|
googleRoutesProxyUrl?: string;
|
|
14
14
|
googleSnapRoadProxyUrl?: string;
|
|
15
15
|
hkGovernRegeoProxyUrl?: string;
|
|
16
|
+
gaodeRegeoProxyUrl?: string;
|
|
16
17
|
themeVariables?: MapThemeVariables;
|
|
17
18
|
renderLoadFailedTitle?: (status: Status) => string | undefined;
|
|
18
19
|
renderLoadFailedDescription?: (status: Status) => string | undefined;
|
|
20
|
+
reportLog?: (data: any) => void;
|
|
19
21
|
}
|
|
20
22
|
export declare const useMapSupplier: () => MapSupplierPayolad;
|
|
21
23
|
export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { shallowRef } from "vue-demi";
|
|
2
2
|
import { MAX_DEVIATION_DISTANCE_WALKING } from "../api/contants.js";
|
|
3
3
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
4
|
-
import { googleServiceApiWalkingRoute,
|
|
4
|
+
import { googleServiceApiWalkingRoute, gaodeServiceApiWalkingRoute, amapJsApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
|
|
5
5
|
import { findClosestPointInLine } from "../utils/geometry.js";
|
|
6
6
|
import { distanceBetweenTwoPoints } from "../utils/geometryPolygon.js";
|
|
7
7
|
import { spaceLog } from "../utils/log.js";
|
|
@@ -44,12 +44,12 @@ const findBestContinuation = (args, cacheEntries) => {
|
|
|
44
44
|
const memoizeAmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
|
|
45
45
|
const memoizeGmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
|
|
46
46
|
const useAWalkingRoute = (props) => {
|
|
47
|
-
const { googleRoutesProxyUrl } = useMapSupplier();
|
|
47
|
+
const { googleRoutesProxyUrl, gaodeDirectionWalkingProxyUrl } = useMapSupplier();
|
|
48
48
|
const pathRef = shallowRef([]);
|
|
49
49
|
const amapWalking = new AMap.Walking({});
|
|
50
50
|
const apiMapWalkingRoute = memoizeAmapWalkingRoute((from, to) => {
|
|
51
51
|
spaceLog("apiMapWalkingRoute", `amap from = ${from} to = ${to}`);
|
|
52
|
-
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
|
|
52
|
+
return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : gaodeDirectionWalkingProxyUrl ? gaodeServiceApiWalkingRoute(from, to, gaodeDirectionWalkingProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
|
|
53
53
|
});
|
|
54
54
|
watchPostEffectForDeepOption(
|
|
55
55
|
() => {
|
|
@@ -219,6 +219,7 @@ function androidWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
|
219
219
|
if (isHandled)
|
|
220
220
|
return;
|
|
221
221
|
isHandled = true;
|
|
222
|
+
console.log("==GeoLocation assert==", JSON.stringify(geoLocationPosition), typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function");
|
|
222
223
|
geoErrorMessage = void 0;
|
|
223
224
|
resolve(geoLocationPosition);
|
|
224
225
|
},
|
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.
|
|
3
|
+
const pkgVersion = "2.18.0-apiLocalization";
|
|
4
4
|
const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
|
|
5
5
|
const enableSessionLogKey = (key) => {
|
|
6
6
|
const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
|
|
@@ -119,10 +119,22 @@ const amapPlaceName2DisplayName = (name, options) => {
|
|
|
119
119
|
};
|
|
120
120
|
function amapPlaceName2DisplayNameInChinese(name, options) {
|
|
121
121
|
const { province, city, district, township, building, neighborhood } = options;
|
|
122
|
-
if (building)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
if (typeof building === "string") {
|
|
123
|
+
if (building)
|
|
124
|
+
return building;
|
|
125
|
+
} else {
|
|
126
|
+
const { name: name2 } = building;
|
|
127
|
+
if (typeof name2 === "string" && name2)
|
|
128
|
+
return name2;
|
|
129
|
+
}
|
|
130
|
+
if (typeof neighborhood === "string") {
|
|
131
|
+
if (neighborhood)
|
|
132
|
+
return neighborhood;
|
|
133
|
+
} else {
|
|
134
|
+
const { name: name2 } = neighborhood;
|
|
135
|
+
if (typeof name2 === "string" && name2)
|
|
136
|
+
return name2;
|
|
137
|
+
}
|
|
126
138
|
let result = name;
|
|
127
139
|
for (const item of [province, city, district]) {
|
|
128
140
|
const replacedName2 = result.replace(item, "");
|
|
@@ -138,10 +150,19 @@ function amapPlaceName2DisplayNameInChinese(name, options) {
|
|
|
138
150
|
const NOT_ONLY_NUMBERS_REGEX = /[^\d\s-]/;
|
|
139
151
|
function amapPlaceName2DisplayNameOutChinese(name, options) {
|
|
140
152
|
const { adcode, province, city, district, township, street, streetNumber } = options;
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
if (typeof streetNumber === "string") {
|
|
154
|
+
if (street === "Unnamed Road")
|
|
155
|
+
return name;
|
|
156
|
+
if (street || streetNumber)
|
|
157
|
+
return `${street} ${streetNumber}`;
|
|
158
|
+
} else {
|
|
159
|
+
const { number, street: streetNumberStreet } = streetNumber;
|
|
160
|
+
if (streetNumberStreet === "Unnamed Road")
|
|
161
|
+
return name;
|
|
162
|
+
const streetNumberItem = typeof number === "string" ? number : "";
|
|
163
|
+
if (streetNumberStreet || streetNumberItem)
|
|
164
|
+
return `${streetNumberStreet} ${streetNumberItem}`;
|
|
165
|
+
}
|
|
145
166
|
const idxs = [];
|
|
146
167
|
for (const token of [adcode, province, city, district, township]) {
|
|
147
168
|
if (!token)
|
|
@@ -150,6 +150,7 @@ function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
|
|
|
150
150
|
});
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
+
console.log("==injected geoPosition==", JSON.stringify(position));
|
|
153
154
|
onSuccess(position);
|
|
154
155
|
};
|
|
155
156
|
const asseertedOnError = (error) => onError(toGeolocationPositionError(error, prefix));
|