@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
|
@@ -11,6 +11,7 @@ import { detectWebGL, WEBGL_STATUS, detectBrowserPlatform, OS_PLATFORM, BRWOSER_
|
|
|
11
11
|
import { language2vectorMapForeign, vec2lnglat } from "../../utils/transform.js";
|
|
12
12
|
import { Amap } from "../Amap/Amap.js";
|
|
13
13
|
import { Gmap } from "../Gmap/Gmap.js";
|
|
14
|
+
import { t as throttle } from "../../chunks/throttle.8bdd8d3b.js";
|
|
14
15
|
const style_css_ts_vanilla = "";
|
|
15
16
|
const MapProvider_css_ts_vanilla = "";
|
|
16
17
|
var heycarGmapBackgroundDefaultLoadingImage = "_16q981k1";
|
|
@@ -18,6 +19,7 @@ var heycarMap = "_16q981k0";
|
|
|
18
19
|
function _isSlot(s) {
|
|
19
20
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
20
21
|
}
|
|
22
|
+
const MAP_RESIZE_MIN_INTERVAL = 500;
|
|
21
23
|
window.movingDraw = !new URLSearchParams(location.search).has("disableMovingDraw");
|
|
22
24
|
if (detectWebGL() === WEBGL_STATUS.ENABLED) {
|
|
23
25
|
window.forceWebGL = true;
|
|
@@ -51,7 +53,7 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
|
|
|
51
53
|
var _a;
|
|
52
54
|
return createVNode("div", null, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
53
55
|
};
|
|
54
|
-
}).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "renderLoadFailedTitle", "renderLoadFailedDescription"]);
|
|
56
|
+
}).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "googleDirectionsProxyUrl", "googleSnapRoadProxyUrl", "renderLoadFailedTitle", "renderLoadFailedDescription"]);
|
|
55
57
|
const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
56
58
|
slots,
|
|
57
59
|
emit,
|
|
@@ -76,7 +78,9 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
|
76
78
|
} = target.getCenter();
|
|
77
79
|
emit("dragEnd", [lng, lat]);
|
|
78
80
|
};
|
|
79
|
-
const handleResize = () => emit("resize")
|
|
81
|
+
const handleResize = throttle(() => emit("resize"), MAP_RESIZE_MIN_INTERVAL, {
|
|
82
|
+
trailing: true
|
|
83
|
+
});
|
|
80
84
|
loadTraditionalChineseConvertOnce(payload.language === "zh-TW");
|
|
81
85
|
return () => {
|
|
82
86
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { reactive } from "vue-demi";
|
|
2
2
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
3
|
+
import { googleServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
|
|
4
|
+
import { inTaiwan } from "./useMapInChina.js";
|
|
3
5
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
4
6
|
const useADrivingRoute = (props) => {
|
|
7
|
+
const { googleDirectionsProxyUrl } = useMapSupplier();
|
|
5
8
|
const outputRoute = reactive({
|
|
6
9
|
path: [],
|
|
7
10
|
distance: 0,
|
|
@@ -11,46 +14,7 @@ const useADrivingRoute = (props) => {
|
|
|
11
14
|
});
|
|
12
15
|
const amapDriving = new AMap.Driving({});
|
|
13
16
|
const apiMapDrivingRoute = (from, to) => {
|
|
14
|
-
return
|
|
15
|
-
amapDriving.search(
|
|
16
|
-
AMap.LngLat.from(from),
|
|
17
|
-
AMap.LngLat.from(to),
|
|
18
|
-
{ waypoints: [] },
|
|
19
|
-
(status, result) => {
|
|
20
|
-
switch (status) {
|
|
21
|
-
case "complete": {
|
|
22
|
-
let path = [];
|
|
23
|
-
const drivingResult = result;
|
|
24
|
-
const routeSteps = [];
|
|
25
|
-
const firstRoute = drivingResult.routes[0];
|
|
26
|
-
if (!firstRoute)
|
|
27
|
-
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
28
|
-
for (const step of firstRoute.steps) {
|
|
29
|
-
const basicStep = step;
|
|
30
|
-
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
31
|
-
path = path.concat(stepPath);
|
|
32
|
-
routeSteps.push({
|
|
33
|
-
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
34
|
-
duration: basicStep.time,
|
|
35
|
-
distance: basicStep.distance
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return resolve({
|
|
39
|
-
path,
|
|
40
|
-
distance: firstRoute.distance,
|
|
41
|
-
duration: firstRoute.time,
|
|
42
|
-
tolls: firstRoute.tolls,
|
|
43
|
-
steps: routeSteps
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
case "no_data":
|
|
47
|
-
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
48
|
-
default:
|
|
49
|
-
return reject(result);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
});
|
|
17
|
+
return googleDirectionsProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, googleDirectionsProxyUrl) : amapJsApiDrivingRoute(from, to, amapDriving);
|
|
54
18
|
};
|
|
55
19
|
watchPostEffectForDeepOption(
|
|
56
20
|
() => {
|
|
@@ -69,48 +33,7 @@ const useGDrivingRoute = (props) => {
|
|
|
69
33
|
const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [] });
|
|
70
34
|
const gmapDirectionsService = new google.maps.DirectionsService();
|
|
71
35
|
const apiMapDrivingRoute = (from, to) => {
|
|
72
|
-
return
|
|
73
|
-
gmapDirectionsService.route(
|
|
74
|
-
{
|
|
75
|
-
origin: { lng: from[0], lat: from[1] },
|
|
76
|
-
destination: { lng: to[0], lat: to[1] },
|
|
77
|
-
travelMode: google.maps.TravelMode.DRIVING
|
|
78
|
-
},
|
|
79
|
-
(result, status) => {
|
|
80
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
81
|
-
switch (status) {
|
|
82
|
-
case google.maps.DirectionsStatus.OK: {
|
|
83
|
-
let path = [];
|
|
84
|
-
let distance = 0;
|
|
85
|
-
let duration = 0;
|
|
86
|
-
const routeSteps = [];
|
|
87
|
-
const firstRoute = result.routes[0];
|
|
88
|
-
if (!firstRoute)
|
|
89
|
-
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
90
|
-
for (const leg of firstRoute.legs) {
|
|
91
|
-
distance += (_b = (_a = leg.distance) == null ? void 0 : _a.value) != null ? _b : 0;
|
|
92
|
-
duration += (_d = (_c = leg.duration) == null ? void 0 : _c.value) != null ? _d : 0;
|
|
93
|
-
for (const step of leg.steps) {
|
|
94
|
-
const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
|
|
95
|
-
path = path.concat(stepPath);
|
|
96
|
-
routeSteps.push({
|
|
97
|
-
path: stepPath,
|
|
98
|
-
distance: (_f = (_e = step.distance) == null ? void 0 : _e.value) != null ? _f : 0,
|
|
99
|
-
duration: (_h = (_g = step.duration) == null ? void 0 : _g.value) != null ? _h : 0
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return resolve({ path, distance, duration, steps: routeSteps });
|
|
104
|
-
}
|
|
105
|
-
case google.maps.DirectionsStatus.ZERO_RESULTS:
|
|
106
|
-
case google.maps.DirectionsStatus.NOT_FOUND:
|
|
107
|
-
return resolve({ path: [], distance: 0, duration: 0, steps: [] });
|
|
108
|
-
default:
|
|
109
|
-
return reject(new Error(status));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
});
|
|
36
|
+
return gmapJsApiDrivingRoute(from, to, gmapDirectionsService);
|
|
114
37
|
};
|
|
115
38
|
watchPostEffectForDeepOption(
|
|
116
39
|
() => {
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
2
|
import type { AmapMap, Point } from "../types/interface";
|
|
3
|
+
export type ApiMapComputeHeading = (from?: Point, to?: Point) => number | undefined;
|
|
3
4
|
export type UseMapAngleProps<M = AmapMap | google.maps.Map> = {
|
|
4
5
|
path: Point[];
|
|
5
6
|
map?: M;
|
|
6
7
|
};
|
|
7
8
|
export declare const useAmapAngle: (props?: UseMapAngleProps<AmapMap>) => {
|
|
8
9
|
angleRef: import("vue-demi").ComputedRef<number | undefined>;
|
|
9
|
-
apiMapComputeHeading:
|
|
10
|
+
apiMapComputeHeading: ApiMapComputeHeading;
|
|
10
11
|
};
|
|
11
12
|
export declare const useGmapAngle: (props?: UseMapAngleProps<google.maps.Map>) => {
|
|
12
13
|
angleRef: import("vue-demi").ComputedRef<number | undefined>;
|
|
13
|
-
apiMapComputeHeading:
|
|
14
|
+
apiMapComputeHeading: ApiMapComputeHeading;
|
|
14
15
|
};
|
|
15
16
|
export declare const useMapAngle: (props?: UseMapAngleProps) => {
|
|
16
17
|
angleRef: import("vue-demi").ComputedRef<number | undefined>;
|
|
17
|
-
apiMapComputeHeading:
|
|
18
|
+
apiMapComputeHeading: ApiMapComputeHeading;
|
|
18
19
|
};
|
|
@@ -13,7 +13,7 @@ function useMapCoordinatify() {
|
|
|
13
13
|
return [lng, lat];
|
|
14
14
|
if (type === "wgs84") {
|
|
15
15
|
if (!inChina([lng, lat]))
|
|
16
|
-
throw new Error(
|
|
16
|
+
throw new Error(`国外(或台湾)经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
|
|
17
17
|
return toLocalWgs84([lng, lat]);
|
|
18
18
|
}
|
|
19
19
|
return toLocalGcj02([lng, lat]);
|
|
@@ -5,6 +5,8 @@ import { useMapSupplier } from "./useMapSupplier.js";
|
|
|
5
5
|
import { d as debounce } from "../chunks/debounce.5afe7867.js";
|
|
6
6
|
const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 20;
|
|
7
7
|
const GOOGLE_MAP_FIT_BOUND_SINGLE_POINT_ZOOM = 17.5;
|
|
8
|
+
const GOOGLE_MAP_FIT_BOUND_MIN_WIDTH = 10;
|
|
9
|
+
const GOOGLE_MAP_FIT_BOUND_MIN_HEIGHT = 10;
|
|
8
10
|
const useAmapFitView = (props) => {
|
|
9
11
|
const { mapRef, autoFitTimeout } = props;
|
|
10
12
|
const overlayGroup = /* @__PURE__ */ new Set();
|
|
@@ -80,8 +82,8 @@ function gmapFitBoundNoAnimate(map, bound, padding) {
|
|
|
80
82
|
return;
|
|
81
83
|
const { top = 0, right = 0, bottom = 0, left = 0 } = padding;
|
|
82
84
|
const { offsetWidth, offsetHeight } = map.getDiv();
|
|
83
|
-
const w = offsetWidth - left - right;
|
|
84
|
-
const h = offsetHeight - top - bottom;
|
|
85
|
+
const w = Math.max(offsetWidth - left - right, GOOGLE_MAP_FIT_BOUND_MIN_WIDTH);
|
|
86
|
+
const h = Math.max(offsetHeight - top - bottom, GOOGLE_MAP_FIT_BOUND_MIN_HEIGHT);
|
|
85
87
|
const northEast = bound.getNorthEast();
|
|
86
88
|
const southWest = bound.getSouthWest();
|
|
87
89
|
const { x: x0, y: y0 } = projection.fromLatLngToPoint(northEast);
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
path: Point[];
|
|
4
|
-
angle: number;
|
|
5
|
-
}
|
|
1
|
+
import type { TrackPoint } from "../types/interface";
|
|
2
|
+
import { type ApiGraspRoadOutput } from "../utils/compatibleGraspRoad";
|
|
6
3
|
interface UseMapGraspRoadProps {
|
|
7
4
|
tracks: TrackPoint[];
|
|
8
5
|
}
|
|
9
6
|
export declare const useAmapGraspRoad: (props?: UseMapGraspRoadProps) => {
|
|
10
7
|
pathRef: import("vue-demi").Ref<[number, number][]>;
|
|
11
8
|
angleRef: import("vue-demi").Ref<number>;
|
|
12
|
-
apiMapToGraspRoadPath: (tracks: TrackPoint[]) => Promise<
|
|
9
|
+
apiMapToGraspRoadPath: (tracks: TrackPoint[]) => Promise<ApiGraspRoadOutput>;
|
|
13
10
|
};
|
|
14
11
|
export declare const useGmapGraspRoad: (props?: UseMapGraspRoadProps) => {
|
|
15
12
|
pathRef: import("vue-demi").Ref<[number, number][]>;
|
|
16
13
|
angleRef: import("vue-demi").Ref<number>;
|
|
17
|
-
apiMapToGraspRoadPath: (tracks: TrackPoint[]) => Promise<
|
|
14
|
+
apiMapToGraspRoadPath: (tracks: TrackPoint[]) => Promise<ApiGraspRoadOutput>;
|
|
18
15
|
};
|
|
19
16
|
export declare const useMapGraspRoad: (props?: UseMapGraspRoadProps) => {
|
|
20
17
|
pathRef: import("vue-demi").Ref<[number, number][]>;
|
|
21
18
|
angleRef: import("vue-demi").Ref<number>;
|
|
22
|
-
apiMapToGraspRoadPath: (tracks: TrackPoint[]) => Promise<
|
|
19
|
+
apiMapToGraspRoadPath: (tracks: TrackPoint[]) => Promise<ApiGraspRoadOutput>;
|
|
23
20
|
};
|
|
24
21
|
export {};
|
|
@@ -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.8ce05cf5.js";
|
|
3
3
|
import { CenterPlaceStatus } from "../types/interface.js";
|
|
4
4
|
import { proxyFunctionalProperty, assertAssingedBeforeUsed } from "../utils/helper.js";
|
|
5
5
|
const useBusinessRecomendPlaceMap = () => {
|
package/dist/v3/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.8ce05cf5.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>;
|