@heycar/heycars-map 2.5.3 → 2.6.0
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/README.md +4 -0
- package/dist/v2/Demo/DemoBusinessRecomendPlace.js +1 -1
- package/dist/v2/api/contants.d.ts +3 -3
- package/dist/v2/api/contants.js +3 -3
- package/dist/v2/api/googleDirections.d.ts +26 -0
- package/dist/v2/api/googleDirections.js +139 -0
- package/dist/v2/api/googleSnapRoad.d.ts +0 -1
- package/dist/v2/api/googleSnapRoad.js +6 -14
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
- package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +4 -3
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +0 -1
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +1 -3
- package/dist/v2/chunks/{BusinessRecomendPlaceMap.824002ef.js → BusinessRecomendPlaceMap.7b67c30c.js} +3 -2
- package/dist/v2/components/Gmap/Gmap.js +8 -2
- package/dist/v2/components/MapProvider/MapProvider.d.ts +1 -1
- package/dist/v2/components/MapProvider/MapProvider.js +6 -2
- package/dist/v2/hooks/useDrivingRoute.js +5 -82
- package/dist/v2/hooks/useMapAngle.d.ts +4 -3
- package/dist/v2/hooks/useMapCoordinatify.js +1 -1
- package/dist/v2/hooks/useMapFitView.js +4 -2
- package/dist/v2/hooks/useMapGraspRoad.d.ts +5 -8
- package/dist/v2/hooks/useMapGraspRoad.js +9 -60
- package/dist/v2/hooks/useMapInChina.d.ts +1 -0
- package/dist/v2/hooks/useMapInChina.js +28 -2
- package/dist/v2/hooks/useMapPlace.js +3 -3
- package/dist/v2/hooks/useMapRecomendPlace.js +2 -1
- package/dist/v2/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v2/hooks/useResizeObserver.d.ts +1 -0
- package/dist/v2/hooks/useResizeObserver.js +3 -1
- package/dist/v2/hooks/useWalkingRoute.js +21 -60
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v2/index.js +1 -1
- package/dist/v2/types/interface.d.ts +5 -0
- package/dist/v2/utils/compatibleDrivingRoute.d.ts +5 -0
- package/dist/v2/utils/compatibleDrivingRoute.js +130 -0
- package/dist/v2/utils/compatibleGoogleTypes.d.ts +11 -0
- package/dist/v2/utils/compatibleGoogleTypes.js +38 -0
- package/dist/v2/utils/compatibleGraspRoad.d.ts +8 -0
- package/dist/v2/utils/compatibleGraspRoad.js +67 -0
- package/dist/v2/utils/compatibleWalkingRoute.d.ts +5 -0
- package/dist/v2/utils/compatibleWalkingRoute.js +81 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.d.ts +3 -1
- package/dist/v2/utils/transform.js +46 -5
- package/dist/v2/utils/typeChecking.d.ts +3 -1
- package/dist/v2/utils/typeChecking.js +5 -0
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
- package/dist/v3/api/contants.d.ts +3 -3
- package/dist/v3/api/contants.js +3 -3
- package/dist/v3/api/googleDirections.d.ts +26 -0
- package/dist/v3/api/googleDirections.js +139 -0
- package/dist/v3/api/googleSnapRoad.d.ts +0 -1
- package/dist/v3/api/googleSnapRoad.js +6 -14
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
- package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +4 -3
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +0 -1
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +1 -3
- package/dist/v3/chunks/{BusinessRecomendPlaceMap.d14dbe4e.js → BusinessRecomendPlaceMap.8ce05cf5.js} +3 -2
- package/dist/v3/components/Gmap/Gmap.js +8 -2
- package/dist/v3/components/MapProvider/MapProvider.d.ts +1 -1
- package/dist/v3/components/MapProvider/MapProvider.js +6 -2
- package/dist/v3/hooks/useDrivingRoute.js +5 -82
- package/dist/v3/hooks/useMapAngle.d.ts +4 -3
- package/dist/v3/hooks/useMapCoordinatify.js +1 -1
- package/dist/v3/hooks/useMapFitView.js +4 -2
- package/dist/v3/hooks/useMapGraspRoad.d.ts +5 -8
- package/dist/v3/hooks/useMapGraspRoad.js +9 -60
- package/dist/v3/hooks/useMapInChina.d.ts +1 -0
- package/dist/v3/hooks/useMapInChina.js +28 -2
- package/dist/v3/hooks/useMapPlace.js +3 -3
- package/dist/v3/hooks/useMapRecomendPlace.js +2 -1
- package/dist/v3/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v3/hooks/useResizeObserver.d.ts +1 -0
- package/dist/v3/hooks/useResizeObserver.js +3 -1
- package/dist/v3/hooks/useWalkingRoute.js +21 -60
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v3/index.js +1 -1
- package/dist/v3/types/interface.d.ts +5 -0
- package/dist/v3/utils/compatibleDrivingRoute.d.ts +5 -0
- package/dist/v3/utils/compatibleDrivingRoute.js +130 -0
- package/dist/v3/utils/compatibleGoogleTypes.d.ts +11 -0
- package/dist/v3/utils/compatibleGoogleTypes.js +38 -0
- package/dist/v3/utils/compatibleGraspRoad.d.ts +8 -0
- package/dist/v3/utils/compatibleGraspRoad.js +67 -0
- package/dist/v3/utils/compatibleWalkingRoute.d.ts +5 -0
- package/dist/v3/utils/compatibleWalkingRoute.js +81 -0
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.d.ts +3 -1
- package/dist/v3/utils/transform.js +46 -5
- package/dist/v3/utils/typeChecking.d.ts +3 -1
- package/dist/v3/utils/typeChecking.js +5 -0
- package/package.json +2 -1
|
@@ -1,45 +1,18 @@
|
|
|
1
1
|
import { ref } from "vue-demi";
|
|
2
|
-
import { apiGoogleSnapRoad } from "../api/googleSnapRoad.js";
|
|
3
2
|
import { watchEffectForDeepOption } from "../utils/compare.js";
|
|
4
|
-
import {
|
|
3
|
+
import { googleServiceApiGraspRoad, amapJsApiGraspRoad } from "../utils/compatibleGraspRoad.js";
|
|
4
|
+
import { lnglat2point } from "../utils/transform.js";
|
|
5
5
|
import { useMapAngle } from "./useMapAngle.js";
|
|
6
|
-
import {
|
|
6
|
+
import { inTaiwan } from "./useMapInChina.js";
|
|
7
7
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
8
|
-
const GRASP_ROAD_INPUT_MIN_AMOUNT = 2;
|
|
9
|
-
const GRASP_ROAD_INPUT_MAX_AMOUNT = 500;
|
|
10
8
|
const useAmapGraspRoad = (props) => {
|
|
11
|
-
const amapGraspRoad = new AMap.GraspRoad();
|
|
12
9
|
const pathRef = ref([]);
|
|
13
10
|
const angleRef = ref(0);
|
|
11
|
+
const { googleSnapRoadProxyUrl } = useMapSupplier();
|
|
14
12
|
const { apiMapComputeHeading } = useMapAngle();
|
|
13
|
+
const amapGraspRoad = new AMap.GraspRoad();
|
|
15
14
|
const apiMapToGraspRoadPath = (tracks) => {
|
|
16
|
-
return
|
|
17
|
-
var _a, _b, _c;
|
|
18
|
-
if (tracks.length < GRASP_ROAD_INPUT_MIN_AMOUNT) {
|
|
19
|
-
const path = tracks.map(lnglat2point);
|
|
20
|
-
const angle = (_b = (_a = tracks[tracks.length - 1]) == null ? void 0 : _a.angle) != null ? _b : 0;
|
|
21
|
-
return resolve({ path, angle });
|
|
22
|
-
}
|
|
23
|
-
if (!inChina(lnglat2point(tracks[tracks.length - 1]))) {
|
|
24
|
-
const path = tracks.map(lnglat2point);
|
|
25
|
-
const angle = (_c = apiMapComputeHeading(path[path.length - 2], path[path.length - 1])) != null ? _c : 0;
|
|
26
|
-
return resolve({ path, angle });
|
|
27
|
-
}
|
|
28
|
-
const amount = Math.min(GRASP_ROAD_INPUT_MAX_AMOUNT, tracks.length);
|
|
29
|
-
const graspRoadPoints = trackPoints2amapGraspRoadPoints(tracks.slice(-amount));
|
|
30
|
-
amapGraspRoad.driving(graspRoadPoints, (error, result) => {
|
|
31
|
-
var _a2, _b2;
|
|
32
|
-
if (error) {
|
|
33
|
-
console.error("高德地图路线纠偏失败!原因如下:\n", error);
|
|
34
|
-
const path2 = tracks.map(lnglat2point);
|
|
35
|
-
const angle2 = (_a2 = apiMapComputeHeading(path2[0], path2[1])) != null ? _a2 : 0;
|
|
36
|
-
return resolve({ path: path2, angle: angle2 });
|
|
37
|
-
}
|
|
38
|
-
const path = result.data.points.map(({ x, y }) => [x, y]);
|
|
39
|
-
const angle = (_b2 = apiMapComputeHeading(path[path.length - 2], path[path.length - 1])) != null ? _b2 : 0;
|
|
40
|
-
resolve({ path, angle });
|
|
41
|
-
});
|
|
42
|
-
});
|
|
15
|
+
return googleSnapRoadProxyUrl && inTaiwan(lnglat2point(tracks[tracks.length - 1])) ? googleServiceApiGraspRoad(tracks, apiMapComputeHeading, googleSnapRoadProxyUrl) : amapJsApiGraspRoad(tracks, amapGraspRoad, apiMapComputeHeading);
|
|
43
16
|
};
|
|
44
17
|
watchEffectForDeepOption(
|
|
45
18
|
() => props ? [...props.tracks] : void 0,
|
|
@@ -56,34 +29,10 @@ const useAmapGraspRoad = (props) => {
|
|
|
56
29
|
const useGmapGraspRoad = (props) => {
|
|
57
30
|
const pathRef = ref([]);
|
|
58
31
|
const angleRef = ref(0);
|
|
32
|
+
const { googleSnapRoadProxyUrl } = useMapSupplier();
|
|
59
33
|
const { apiMapComputeHeading } = useMapAngle();
|
|
60
|
-
const apiMapToGraspRoadPath =
|
|
61
|
-
|
|
62
|
-
let result;
|
|
63
|
-
if (tracks.length < GRASP_ROAD_INPUT_MIN_AMOUNT) {
|
|
64
|
-
const path2 = tracks.map(lnglat2point);
|
|
65
|
-
const angle2 = (_b = (_a = tracks[tracks.length - 1]) == null ? void 0 : _a.angle) != null ? _b : 0;
|
|
66
|
-
return { path: path2, angle: angle2 };
|
|
67
|
-
}
|
|
68
|
-
const amount = Math.min(GRASP_ROAD_INPUT_MAX_AMOUNT, tracks.length);
|
|
69
|
-
const snapRoadPath = tracks.slice(-amount).map(lnglat2point);
|
|
70
|
-
try {
|
|
71
|
-
result = await apiGoogleSnapRoad({ path: snapRoadPath });
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error("谷歌地图路线纠偏失败!原因如下:\n", error);
|
|
74
|
-
const path2 = tracks.map(lnglat2point);
|
|
75
|
-
const angle2 = (_c = apiMapComputeHeading(path2[0], path2[1])) != null ? _c : 0;
|
|
76
|
-
return { path: path2, angle: angle2 };
|
|
77
|
-
}
|
|
78
|
-
const { snappedPoints, warningMessage } = result;
|
|
79
|
-
if (warningMessage)
|
|
80
|
-
console.warn("apiGoogleSnapRoad warning: ", warningMessage);
|
|
81
|
-
const path = snappedPoints.map((item) => [
|
|
82
|
-
item.location.longitude,
|
|
83
|
-
item.location.latitude
|
|
84
|
-
]);
|
|
85
|
-
const angle = (_d = apiMapComputeHeading(path[path.length - 2], path[path.length - 1])) != null ? _d : 0;
|
|
86
|
-
return { path, angle };
|
|
34
|
+
const apiMapToGraspRoadPath = (tracks) => {
|
|
35
|
+
return googleServiceApiGraspRoad(tracks, apiMapComputeHeading, googleSnapRoadProxyUrl);
|
|
87
36
|
};
|
|
88
37
|
watchEffectForDeepOption(
|
|
89
38
|
() => props ? [...props.tracks] : void 0,
|
|
@@ -2,3 +2,4 @@ import { type Point } from "../types/interface";
|
|
|
2
2
|
export declare const inChina: (point: Point) => boolean;
|
|
3
3
|
export declare const inHongkong: (point: Point) => boolean;
|
|
4
4
|
export declare const inMacau: (point: Point) => boolean;
|
|
5
|
+
export declare const inTaiwan: (point: Point) => boolean;
|
|
@@ -2593,8 +2593,30 @@ const macauBounds = [
|
|
|
2593
2593
|
22.19885
|
|
2594
2594
|
]
|
|
2595
2595
|
];
|
|
2596
|
+
const taiwanBounds = [
|
|
2597
|
+
[
|
|
2598
|
+
119.252093,
|
|
2599
|
+
23.561995
|
|
2600
|
+
],
|
|
2601
|
+
[
|
|
2602
|
+
121.031616,
|
|
2603
|
+
25.517889
|
|
2604
|
+
],
|
|
2605
|
+
[
|
|
2606
|
+
122.394777,
|
|
2607
|
+
25.20866
|
|
2608
|
+
],
|
|
2609
|
+
[
|
|
2610
|
+
121.835824,
|
|
2611
|
+
21.645481
|
|
2612
|
+
],
|
|
2613
|
+
[
|
|
2614
|
+
120.358592,
|
|
2615
|
+
21.58185
|
|
2616
|
+
]
|
|
2617
|
+
];
|
|
2596
2618
|
const inChina = (point) => {
|
|
2597
|
-
return pointInPolygon(point, chinaBounds) >= 0;
|
|
2619
|
+
return pointInPolygon(point, chinaBounds) >= 0 && !inTaiwan(point);
|
|
2598
2620
|
};
|
|
2599
2621
|
const inHongkong = (point) => {
|
|
2600
2622
|
return pointInPolygon(point, hongkongBounds) >= 0;
|
|
@@ -2602,8 +2624,12 @@ const inHongkong = (point) => {
|
|
|
2602
2624
|
const inMacau = (point) => {
|
|
2603
2625
|
return pointInPolygon(point, macauBounds) >= 0;
|
|
2604
2626
|
};
|
|
2627
|
+
const inTaiwan = (point) => {
|
|
2628
|
+
return pointInPolygon(point, taiwanBounds) >= 0;
|
|
2629
|
+
};
|
|
2605
2630
|
export {
|
|
2606
2631
|
inChina,
|
|
2607
2632
|
inHongkong,
|
|
2608
|
-
inMacau
|
|
2633
|
+
inMacau,
|
|
2634
|
+
inTaiwan
|
|
2609
2635
|
};
|
|
@@ -3,7 +3,7 @@ import { REGEO_TIMEOUT } from "../api/contants.js";
|
|
|
3
3
|
import { createPipeTw } from "../utils/cn2tw.js";
|
|
4
4
|
import { equalAssign, AbortSignalAny } from "../utils/helper.js";
|
|
5
5
|
import { amapPlaceName2DisplayName, signal2promise, gmapPlaceName2DisplayName } from "../utils/transform.js";
|
|
6
|
-
import { inChina } from "./useMapInChina.js";
|
|
6
|
+
import { inChina, inTaiwan } from "./useMapInChina.js";
|
|
7
7
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
8
8
|
import { useUpdate } from "./useUdate.js";
|
|
9
9
|
const useAmapPlace = (props) => {
|
|
@@ -39,7 +39,7 @@ const useAmapPlace = (props) => {
|
|
|
39
39
|
readyPromise.then(() => {
|
|
40
40
|
const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
|
|
41
41
|
const pipeTw = createPipeTw(language === "zh-TW");
|
|
42
|
-
const
|
|
42
|
+
const isChinese = inChina([lng, lat]) || inTaiwan([lng, lat]);
|
|
43
43
|
geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
|
|
44
44
|
clearTimeout(timer);
|
|
45
45
|
switch (status) {
|
|
@@ -47,7 +47,7 @@ const useAmapPlace = (props) => {
|
|
|
47
47
|
const { formattedAddress, addressComponent } = result.regeocode;
|
|
48
48
|
const name = formattedAddress ? formattedAddress : emptyPlaceName;
|
|
49
49
|
const displayName = amapPlaceName2DisplayName(name, {
|
|
50
|
-
|
|
50
|
+
isChinese,
|
|
51
51
|
...addressComponent
|
|
52
52
|
});
|
|
53
53
|
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
@@ -7,6 +7,8 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
|
|
|
7
7
|
readyPromise: UseMapLoaderOutput["readyPromise"];
|
|
8
8
|
status: Status;
|
|
9
9
|
pingStatus: ConnectionStatus;
|
|
10
|
+
googleDirectionsProxyUrl?: string;
|
|
11
|
+
googleSnapRoadProxyUrl?: string;
|
|
10
12
|
renderLoadFailedTitle?: (status: Status) => string | undefined;
|
|
11
13
|
renderLoadFailedDescription?: (status: Status) => string | undefined;
|
|
12
14
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { watchPostEffect } from "vue-demi";
|
|
2
2
|
const useResizeObserver = (props) => {
|
|
3
|
-
const { elementRef, onChange } = props;
|
|
3
|
+
const { elementRef, shouldSkip, onChange } = props;
|
|
4
4
|
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
5
5
|
var _a, _b;
|
|
6
|
+
if (shouldSkip == null ? void 0 : shouldSkip())
|
|
7
|
+
return;
|
|
6
8
|
const { contentBoxSize, contentRect } = entry;
|
|
7
9
|
const width = (_a = contentBoxSize == null ? void 0 : contentBoxSize[0].inlineSize) != null ? _a : contentRect.width;
|
|
8
10
|
const height = (_b = contentBoxSize == null ? void 0 : contentBoxSize[0].blockSize) != null ? _b : contentRect.height;
|
|
@@ -1,44 +1,24 @@
|
|
|
1
1
|
import { shallowRef } from "vue-demi";
|
|
2
2
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
3
|
+
import { googleServiceApiWalkingRoute, amapJsApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
|
|
4
|
+
import { inTaiwan } from "./useMapInChina.js";
|
|
3
5
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
4
|
-
const isIgnoredAmapWalkingRouteError = (err) => err === "RETURN_TIMEOUT";
|
|
5
6
|
const useAWalkingRoute = (props) => {
|
|
7
|
+
const { googleDirectionsProxyUrl } = useMapSupplier();
|
|
6
8
|
const pathRef = shallowRef([]);
|
|
7
9
|
const amapWalking = new AMap.Walking({});
|
|
10
|
+
const apiMapWalkingRoute = (from, to) => {
|
|
11
|
+
return googleDirectionsProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleDirectionsProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
|
|
12
|
+
};
|
|
8
13
|
watchPostEffectForDeepOption(
|
|
9
14
|
() => {
|
|
10
15
|
const { from, to } = props;
|
|
11
16
|
return { from, to };
|
|
12
17
|
},
|
|
13
|
-
({ from, to }) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let path = [];
|
|
18
|
-
const walkingResult = result;
|
|
19
|
-
if (!walkingResult.routes) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const firstRoute = walkingResult.routes[0];
|
|
23
|
-
for (const step of firstRoute.steps) {
|
|
24
|
-
const stepPath = step.path.map(({ lng, lat }) => [lng, lat]);
|
|
25
|
-
path = path.concat(stepPath);
|
|
26
|
-
}
|
|
27
|
-
pathRef.value = path;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
case "no_data":
|
|
31
|
-
pathRef.value = [];
|
|
32
|
-
return;
|
|
33
|
-
default:
|
|
34
|
-
if (isIgnoredAmapWalkingRouteError(result)) {
|
|
35
|
-
console.warn(result);
|
|
36
|
-
pathRef.value = [];
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
throw result;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
18
|
+
async ({ from, to }) => {
|
|
19
|
+
if (!from || !to)
|
|
20
|
+
return;
|
|
21
|
+
pathRef.value = await apiMapWalkingRoute(from, to);
|
|
42
22
|
}
|
|
43
23
|
);
|
|
44
24
|
return pathRef;
|
|
@@ -46,37 +26,18 @@ const useAWalkingRoute = (props) => {
|
|
|
46
26
|
const useGWalkingRoute = (props) => {
|
|
47
27
|
const pathRef = shallowRef([]);
|
|
48
28
|
const gmapDirectionsService = new google.maps.DirectionsService();
|
|
29
|
+
const apiMapWalkingRoute = (from, to) => {
|
|
30
|
+
return gmapJsApiWalkingRoute(from, to, gmapDirectionsService);
|
|
31
|
+
};
|
|
49
32
|
watchPostEffectForDeepOption(
|
|
50
|
-
() =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(result, status) => {
|
|
59
|
-
switch (status) {
|
|
60
|
-
case google.maps.DirectionsStatus.OK: {
|
|
61
|
-
let path = [];
|
|
62
|
-
const firstRoute = result.routes[0];
|
|
63
|
-
const stepPath = firstRoute.overview_path.map((item) => [
|
|
64
|
-
item.lng(),
|
|
65
|
-
item.lat()
|
|
66
|
-
]);
|
|
67
|
-
path = path.concat(stepPath);
|
|
68
|
-
pathRef.value = path;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
case google.maps.DirectionsStatus.ZERO_RESULTS:
|
|
72
|
-
case google.maps.DirectionsStatus.NOT_FOUND:
|
|
73
|
-
pathRef.value = [];
|
|
74
|
-
return;
|
|
75
|
-
default:
|
|
76
|
-
throw new Error(status);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
);
|
|
33
|
+
() => {
|
|
34
|
+
const { from, to } = props;
|
|
35
|
+
return { from, to };
|
|
36
|
+
},
|
|
37
|
+
async ({ from, to }) => {
|
|
38
|
+
if (!from || !to)
|
|
39
|
+
return;
|
|
40
|
+
pathRef.value = await apiMapWalkingRoute(from, to);
|
|
80
41
|
}
|
|
81
42
|
);
|
|
82
43
|
return pathRef;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reactive, ref, readonly } from "vue-demi";
|
|
2
|
-
import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.
|
|
2
|
+
import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.7b67c30c.js";
|
|
3
3
|
import { CenterPlaceStatus } from "../types/interface.js";
|
|
4
4
|
import { proxyFunctionalProperty, assertAssingedBeforeUsed } from "../utils/helper.js";
|
|
5
5
|
const useBusinessRecomendPlaceMap = () => {
|
package/dist/v2/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isCoordinatePointEqual } from "./api/geometry.js";
|
|
|
3
3
|
import { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
|
|
4
4
|
import { AddressBox } from "./business-components/AddressBox/AddressBox.js";
|
|
5
5
|
import { BusinessQuotingMap } from "./business-components/BusinessQuotingMap/BusinessQuotingMap.js";
|
|
6
|
-
import { B } from "./chunks/BusinessRecomendPlaceMap.
|
|
6
|
+
import { B } from "./chunks/BusinessRecomendPlaceMap.7b67c30c.js";
|
|
7
7
|
import { BusinessReselectPlaceMap } from "./business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js";
|
|
8
8
|
import { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js";
|
|
9
9
|
import { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js";
|
|
@@ -48,6 +48,7 @@ export interface ValueOfOnChangeRecommendPlace {
|
|
|
48
48
|
inputPlace: Place;
|
|
49
49
|
zone?: Zone;
|
|
50
50
|
isSameZone: boolean;
|
|
51
|
+
noAnimation?: boolean;
|
|
51
52
|
}
|
|
52
53
|
export interface CoordinateValueOfOnChangeRecommendPlace extends Omit<ValueOfOnChangeRecommendPlace, "place" | "inputPlace" | "zone"> {
|
|
53
54
|
place: CoordinatePlace;
|
|
@@ -100,3 +101,7 @@ export type ConnectionStatus = "pending" | "connected" | "unconnected";
|
|
|
100
101
|
export interface BusinessGeolocationPositionError extends GeolocationPositionError {
|
|
101
102
|
isBusinessTimeout: boolean;
|
|
102
103
|
}
|
|
104
|
+
export type ProxyServiceError = {
|
|
105
|
+
code: number;
|
|
106
|
+
msg: string;
|
|
107
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import type { Point, Route } from "../types/interface";
|
|
3
|
+
export declare function amapJsApiDrivingRoute(from: Point, to: Point, amapDriving: AMap.Driving): Promise<Route>;
|
|
4
|
+
export declare function gmapJsApiDrivingRoute(from: Point, to: Point, gmapDirectionsService: google.maps.DirectionsService): Promise<Route>;
|
|
5
|
+
export declare function googleServiceApiDrivingRoute(from: Point, to: Point, proxyUrl: string): Promise<Route>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { apiGoogleDirections } from "../api/googleDirections.js";
|
|
2
|
+
function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
amapDriving.search(
|
|
5
|
+
AMap.LngLat.from(from),
|
|
6
|
+
AMap.LngLat.from(to),
|
|
7
|
+
{ waypoints: [] },
|
|
8
|
+
(status, result) => {
|
|
9
|
+
switch (status) {
|
|
10
|
+
case "complete": {
|
|
11
|
+
let path = [];
|
|
12
|
+
const drivingResult = result;
|
|
13
|
+
const routeSteps = [];
|
|
14
|
+
const firstRoute = drivingResult.routes[0];
|
|
15
|
+
if (!firstRoute)
|
|
16
|
+
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
17
|
+
for (const step of firstRoute.steps) {
|
|
18
|
+
const basicStep = step;
|
|
19
|
+
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
20
|
+
path = path.concat(stepPath);
|
|
21
|
+
routeSteps.push({
|
|
22
|
+
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
23
|
+
duration: basicStep.time,
|
|
24
|
+
distance: basicStep.distance
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return resolve({
|
|
28
|
+
path,
|
|
29
|
+
distance: firstRoute.distance,
|
|
30
|
+
duration: firstRoute.time,
|
|
31
|
+
tolls: firstRoute.tolls,
|
|
32
|
+
steps: routeSteps
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
case "no_data":
|
|
36
|
+
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
37
|
+
default:
|
|
38
|
+
return reject(result);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function gmapJsApiDrivingRoute(from, to, gmapDirectionsService) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
gmapDirectionsService.route(
|
|
47
|
+
{
|
|
48
|
+
origin: { lng: from[0], lat: from[1] },
|
|
49
|
+
destination: { lng: to[0], lat: to[1] },
|
|
50
|
+
travelMode: google.maps.TravelMode.DRIVING
|
|
51
|
+
},
|
|
52
|
+
(result, status) => {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
54
|
+
switch (status) {
|
|
55
|
+
case "OK": {
|
|
56
|
+
let path = [];
|
|
57
|
+
let distance = 0;
|
|
58
|
+
let duration = 0;
|
|
59
|
+
const routeSteps = [];
|
|
60
|
+
const firstRoute = result.routes[0];
|
|
61
|
+
if (!firstRoute)
|
|
62
|
+
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
63
|
+
for (const leg of firstRoute.legs) {
|
|
64
|
+
distance += (_b = (_a = leg.distance) == null ? void 0 : _a.value) != null ? _b : 0;
|
|
65
|
+
duration += (_d = (_c = leg.duration) == null ? void 0 : _c.value) != null ? _d : 0;
|
|
66
|
+
for (const step of leg.steps) {
|
|
67
|
+
const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
|
|
68
|
+
path = path.concat(stepPath);
|
|
69
|
+
routeSteps.push({
|
|
70
|
+
path: stepPath,
|
|
71
|
+
distance: (_f = (_e = step.distance) == null ? void 0 : _e.value) != null ? _f : 0,
|
|
72
|
+
duration: (_h = (_g = step.duration) == null ? void 0 : _g.value) != null ? _h : 0
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return resolve({ path, distance, duration, steps: routeSteps });
|
|
77
|
+
}
|
|
78
|
+
case "ZERO_RESULTS":
|
|
79
|
+
case "NOT_FOUND":
|
|
80
|
+
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
81
|
+
default:
|
|
82
|
+
return reject(new Error(status));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function googleServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
89
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
90
|
+
const { status, routes, error_message } = await apiGoogleDirections({
|
|
91
|
+
proxyUrl,
|
|
92
|
+
origin: from,
|
|
93
|
+
destination: to
|
|
94
|
+
});
|
|
95
|
+
switch (status) {
|
|
96
|
+
case "OK": {
|
|
97
|
+
let path = [];
|
|
98
|
+
let distance = 0;
|
|
99
|
+
let duration = 0;
|
|
100
|
+
const routeSteps = [];
|
|
101
|
+
const firstRoute = routes[0];
|
|
102
|
+
if (!firstRoute)
|
|
103
|
+
return { path: [], distance: 0, duration: 0, steps: [] };
|
|
104
|
+
for (const leg of firstRoute.legs) {
|
|
105
|
+
distance += (_b = (_a = leg.distance) == null ? void 0 : _a.value) != null ? _b : 0;
|
|
106
|
+
duration += (_d = (_c = leg.duration) == null ? void 0 : _c.value) != null ? _d : 0;
|
|
107
|
+
for (const step of leg.steps) {
|
|
108
|
+
const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
|
|
109
|
+
path = path.concat(stepPath);
|
|
110
|
+
routeSteps.push({
|
|
111
|
+
path: stepPath,
|
|
112
|
+
distance: (_f = (_e = step.distance) == null ? void 0 : _e.value) != null ? _f : 0,
|
|
113
|
+
duration: (_h = (_g = step.duration) == null ? void 0 : _g.value) != null ? _h : 0
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return { path, distance, duration, steps: routeSteps };
|
|
118
|
+
}
|
|
119
|
+
case "ZERO_RESULTS":
|
|
120
|
+
case "NOT_FOUND":
|
|
121
|
+
return { path: [], distance: 0, duration: 0, steps: [] };
|
|
122
|
+
default:
|
|
123
|
+
throw Error(error_message != null ? error_message : status);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
amapJsApiDrivingRoute,
|
|
128
|
+
gmapJsApiDrivingRoute,
|
|
129
|
+
googleServiceApiDrivingRoute
|
|
130
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
export declare class GoogleLatLng implements google.maps.LatLng {
|
|
3
|
+
private json;
|
|
4
|
+
constructor(value: google.maps.LatLngLiteral);
|
|
5
|
+
lng(): number;
|
|
6
|
+
lat(): number;
|
|
7
|
+
equals(other: google.maps.LatLng | null): boolean;
|
|
8
|
+
toJSON(): google.maps.LatLngLiteral;
|
|
9
|
+
toString(): string;
|
|
10
|
+
toUrlValue(precision?: number | undefined): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
class GoogleLatLng {
|
|
8
|
+
constructor(value) {
|
|
9
|
+
__publicField(this, "json");
|
|
10
|
+
this.json = value;
|
|
11
|
+
this.lng = this.lng.bind(this);
|
|
12
|
+
this.lat = this.lat.bind(this);
|
|
13
|
+
}
|
|
14
|
+
lng() {
|
|
15
|
+
return this.json.lng;
|
|
16
|
+
}
|
|
17
|
+
lat() {
|
|
18
|
+
return this.json.lat;
|
|
19
|
+
}
|
|
20
|
+
equals(other) {
|
|
21
|
+
const { lng, lat } = this.json;
|
|
22
|
+
return lng === (other == null ? void 0 : other.lng()) && lat === other.lat();
|
|
23
|
+
}
|
|
24
|
+
toJSON() {
|
|
25
|
+
return { ...this.json };
|
|
26
|
+
}
|
|
27
|
+
toString() {
|
|
28
|
+
const { lng, lat } = this.json;
|
|
29
|
+
return `(${lat}, ${lng})`;
|
|
30
|
+
}
|
|
31
|
+
toUrlValue(precision = 7) {
|
|
32
|
+
const { lng, lat } = this.json;
|
|
33
|
+
return `${lat.toPrecision(precision)},${lng.toPrecision(precision)}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
GoogleLatLng
|
|
38
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiMapComputeHeading } from "../hooks/useMapAngle";
|
|
2
|
+
import type { Point, TrackPoint } from "../types/interface";
|
|
3
|
+
export interface ApiGraspRoadOutput {
|
|
4
|
+
path: Point[];
|
|
5
|
+
angle: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function amapJsApiGraspRoad(tracks: TrackPoint[], amapGraspRoad: AMap.GraspRoad, apiMapComputeHeading: ApiMapComputeHeading): Promise<ApiGraspRoadOutput>;
|
|
8
|
+
export declare function googleServiceApiGraspRoad(tracks: TrackPoint[], apiMapComputeHeading: ApiMapComputeHeading, proxyUrl?: string): Promise<ApiGraspRoadOutput>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { apiGoogleSnapRoad } from "../api/googleSnapRoad.js";
|
|
2
|
+
import { inChina } from "../hooks/useMapInChina.js";
|
|
3
|
+
import { lnglat2point, trackPoints2amapGraspRoadPoints } from "./transform.js";
|
|
4
|
+
const GRASP_ROAD_INPUT_MIN_AMOUNT = 2;
|
|
5
|
+
const GRASP_ROAD_INPUT_MAX_AMOUNT = 500;
|
|
6
|
+
function amapJsApiGraspRoad(tracks, amapGraspRoad, apiMapComputeHeading) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
if (tracks.length < GRASP_ROAD_INPUT_MIN_AMOUNT) {
|
|
10
|
+
const path = tracks.map(lnglat2point);
|
|
11
|
+
const angle = (_b = (_a = tracks[tracks.length - 1]) == null ? void 0 : _a.angle) != null ? _b : 0;
|
|
12
|
+
return resolve({ path, angle });
|
|
13
|
+
}
|
|
14
|
+
const lastPoint = lnglat2point(tracks[tracks.length - 1]);
|
|
15
|
+
if (!inChina(lastPoint)) {
|
|
16
|
+
const path = tracks.map(lnglat2point);
|
|
17
|
+
const angle = (_c = apiMapComputeHeading(path[path.length - 2], path[path.length - 1])) != null ? _c : 0;
|
|
18
|
+
return resolve({ path, angle });
|
|
19
|
+
}
|
|
20
|
+
const amount = Math.min(GRASP_ROAD_INPUT_MAX_AMOUNT, tracks.length);
|
|
21
|
+
const graspRoadPoints = trackPoints2amapGraspRoadPoints(tracks.slice(-amount));
|
|
22
|
+
amapGraspRoad.driving(graspRoadPoints, (error, result) => {
|
|
23
|
+
var _a2, _b2;
|
|
24
|
+
if (error) {
|
|
25
|
+
console.error("高德地图路线纠偏失败!原因如下:\n", error);
|
|
26
|
+
const path2 = tracks.map(lnglat2point);
|
|
27
|
+
const angle2 = (_a2 = apiMapComputeHeading(path2[0], path2[1])) != null ? _a2 : 0;
|
|
28
|
+
return resolve({ path: path2, angle: angle2 });
|
|
29
|
+
}
|
|
30
|
+
const path = result.data.points.map(({ x, y }) => [x, y]);
|
|
31
|
+
const angle = (_b2 = apiMapComputeHeading(path[path.length - 2], path[path.length - 1])) != null ? _b2 : 0;
|
|
32
|
+
resolve({ path, angle });
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async function googleServiceApiGraspRoad(tracks, apiMapComputeHeading, proxyUrl) {
|
|
37
|
+
var _a, _b, _c, _d;
|
|
38
|
+
let result;
|
|
39
|
+
if (tracks.length < GRASP_ROAD_INPUT_MIN_AMOUNT) {
|
|
40
|
+
const path2 = tracks.map(lnglat2point);
|
|
41
|
+
const angle2 = (_b = (_a = tracks[tracks.length - 1]) == null ? void 0 : _a.angle) != null ? _b : 0;
|
|
42
|
+
return { path: path2, angle: angle2 };
|
|
43
|
+
}
|
|
44
|
+
const amount = Math.min(GRASP_ROAD_INPUT_MAX_AMOUNT, tracks.length);
|
|
45
|
+
const snapRoadPath = tracks.slice(-amount).map(lnglat2point);
|
|
46
|
+
try {
|
|
47
|
+
result = await apiGoogleSnapRoad({ path: snapRoadPath, proxyUrl });
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error("谷歌地图路线纠偏失败!原因如下:\n", error);
|
|
50
|
+
const path2 = tracks.map(lnglat2point);
|
|
51
|
+
const angle2 = (_c = apiMapComputeHeading(path2[0], path2[1])) != null ? _c : 0;
|
|
52
|
+
return { path: path2, angle: angle2 };
|
|
53
|
+
}
|
|
54
|
+
const { snappedPoints, warningMessage } = result;
|
|
55
|
+
if (warningMessage)
|
|
56
|
+
console.warn("apiGoogleSnapRoad warning: ", warningMessage);
|
|
57
|
+
const path = snappedPoints.map((item) => [
|
|
58
|
+
item.location.longitude,
|
|
59
|
+
item.location.latitude
|
|
60
|
+
]);
|
|
61
|
+
const angle = (_d = apiMapComputeHeading(path[path.length - 2], path[path.length - 1])) != null ? _d : 0;
|
|
62
|
+
return { path, angle };
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
amapJsApiGraspRoad,
|
|
66
|
+
googleServiceApiGraspRoad
|
|
67
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import type { Point } from "../types/interface";
|
|
3
|
+
export declare function amapJsApiWalkingRoute(from: Point, to: Point, amapWalking: AMap.Walking): Promise<Point[]>;
|
|
4
|
+
export declare function gmapJsApiWalkingRoute(from: Point, to: Point, gmapDirectionsService: google.maps.DirectionsService): Promise<Point[]>;
|
|
5
|
+
export declare function googleServiceApiWalkingRoute(from: Point, to: Point, proxyUrl: string): Promise<Point[]>;
|