@heycar/heycars-map 2.2.0-fitZone4 → 2.3.0-drag2
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/Demo/DemoBusinessRecomendPlace.js +1 -1
- package/dist/v2/api/pingConnection.js +2 -1
- 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 +10 -8
- package/dist/v2/chunks/{BusinessRecomendPlaceMap.3567a399.js → BusinessRecomendPlaceMap.81a4b640.js} +9 -7
- package/dist/v2/hooks/useMapDrag.d.ts +1 -0
- package/dist/v2/hooks/useMapDrag.js +4 -2
- package/dist/v2/hooks/useMapLoader.js +2 -1
- package/dist/v2/hooks/useMapPlace.d.ts +4 -3
- package/dist/v2/hooks/useMapPlace.js +14 -12
- package/dist/v2/hooks/useMapRecomendPlace.d.ts +5 -3
- package/dist/v2/hooks/useMapRecomendPlace.js +95 -86
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v2/index.js +1 -1
- package/dist/v2/utils/helper.d.ts +11 -0
- package/dist/v2/utils/helper.js +35 -2
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.d.ts +1 -0
- package/dist/v2/utils/transform.js +6 -0
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
- package/dist/v3/api/pingConnection.js +2 -1
- 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 +10 -8
- package/dist/v3/chunks/{BusinessRecomendPlaceMap.112787c5.js → BusinessRecomendPlaceMap.7133beea.js} +9 -7
- package/dist/v3/hooks/useMapDrag.d.ts +1 -0
- package/dist/v3/hooks/useMapDrag.js +4 -2
- package/dist/v3/hooks/useMapLoader.js +2 -1
- package/dist/v3/hooks/useMapPlace.d.ts +4 -3
- package/dist/v3/hooks/useMapPlace.js +14 -12
- package/dist/v3/hooks/useMapRecomendPlace.d.ts +5 -3
- package/dist/v3/hooks/useMapRecomendPlace.js +95 -86
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v3/index.js +1 -1
- package/dist/v3/utils/helper.d.ts +11 -0
- package/dist/v3/utils/helper.js +35 -2
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.d.ts +1 -0
- package/dist/v3/utils/transform.js +6 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h } from "vue";
|
|
2
|
-
import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.
|
|
2
|
+
import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.81a4b640.js";
|
|
3
3
|
import { useBusinessRecomendPlaceMap } from "../hooks-business/useBusinessRecomendPlaceMap.js";
|
|
4
4
|
import { defineSetup } from "../types/helper.js";
|
|
5
5
|
import { d as demo } from "../chunks/Demo.css.e921a2f6.js";
|
|
@@ -4,6 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
+
import { MANUAL_ABORT_MESSAGE } from "../utils/ManualAbortError.js";
|
|
7
8
|
import { sleep } from "../utils/helper.js";
|
|
8
9
|
const PING_AMAP_URL = "https://webapi.amap.com/maps";
|
|
9
10
|
const PING_AMAP_TIMEOUT = 5e3;
|
|
@@ -58,7 +59,7 @@ class PingConnection {
|
|
|
58
59
|
}
|
|
59
60
|
check(url, timeout, fetchOption) {
|
|
60
61
|
const controller = new AbortController();
|
|
61
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
62
|
+
const timer = setTimeout(() => controller.abort(MANUAL_ABORT_MESSAGE), timeout);
|
|
62
63
|
return fetch(toUncachableUrl(url, timeout.toString()), {
|
|
63
64
|
signal: controller.signal,
|
|
64
65
|
...fetchOption
|
|
@@ -27,7 +27,7 @@ import "../GreenZone/GreenZone.js";
|
|
|
27
27
|
import "../PassengerCircle/PassengerCircle.js";
|
|
28
28
|
import "../PickupPoints/PickupPoints.js";
|
|
29
29
|
import "./useCacheCenterPlace.js";
|
|
30
|
-
import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.
|
|
30
|
+
import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.81a4b640.js";
|
|
31
31
|
export {
|
|
32
32
|
B as BusinessRecomendPlaceMap,
|
|
33
33
|
f as BusinessRecomendPlaceMapInner,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.
|
|
1
|
+
import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.81a4b640.js";
|
|
2
2
|
export {
|
|
3
3
|
B as BusinessRecomendPlaceMap,
|
|
4
4
|
f as BusinessRecomendPlaceMapInner,
|
|
@@ -18,10 +18,10 @@ import { throwNoneManualAbortError, MANUAL_ABORT_MESSAGE } from "../../utils/Man
|
|
|
18
18
|
import { watchPostEffectOnce, generateCreateElementV2PropsOn } from "../../utils/compare.js";
|
|
19
19
|
import { equalAssign, isPlacesInclude } from "../../utils/helper.js";
|
|
20
20
|
import { detectBrowserPlatform } from "../../utils/platform.js";
|
|
21
|
-
import { place2point, isPlaceEqual,
|
|
21
|
+
import { place2point, isPlaceEqual, isZoneEqual, geoPositionError2businessTimeout, pipeDefer } from "../../utils/transform.js";
|
|
22
22
|
import { toCoordinatePlaceType, toCoordinatePointType, toCoordinateRecommendZonePlacesType } from "../../utils/typeChecking.js";
|
|
23
23
|
import { AbsoluteAddressBox } from "../AbsoluteAddressBox/AbsoluteAddressBox.js";
|
|
24
|
-
import { E as EMPTY_PLACE, m as memoize, R as RECOMMEND_PLACE_DRAG_LIMIT, a as RECOMMEND_PLACE_LARGE_LIMIT, b as RECOMMEND_PLACE_ZONE_ICON_MIN, c as RECOMMEND_PLACE_ICON_ZOOM_MIN, d as RECOMMEND_PLACE_ZONE_TEXT_MIN, e as RECOMMEND_PLACE_TEXT_ZOOM_MIN, D as DEFAULT_ZOOM, Z as ZONE_FITVIEW_PANDING } from "../../chunks/BusinessRecomendPlaceMap.
|
|
24
|
+
import { E as EMPTY_PLACE, m as memoize, R as RECOMMEND_PLACE_DRAG_LIMIT, a as RECOMMEND_PLACE_LARGE_LIMIT, b as RECOMMEND_PLACE_ZONE_ICON_MIN, c as RECOMMEND_PLACE_ICON_ZOOM_MIN, d as RECOMMEND_PLACE_ZONE_TEXT_MIN, e as RECOMMEND_PLACE_TEXT_ZOOM_MIN, D as DEFAULT_ZOOM, Z as ZONE_FITVIEW_PANDING } from "../../chunks/BusinessRecomendPlaceMap.81a4b640.js";
|
|
25
25
|
import { DeviceOrientation } from "../DeviceOrientation/DeviceOrientation.js";
|
|
26
26
|
import { GreenZone } from "../GreenZone/GreenZone.js";
|
|
27
27
|
import { PassengerCircle } from "../PassengerCircle/PassengerCircle.js";
|
|
@@ -35,8 +35,8 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
35
35
|
emptyTitle,
|
|
36
36
|
queryingTitle,
|
|
37
37
|
geoErrorOnceNotificationKey = `BusinessRecomendPlaceMap_${Date.now()}`,
|
|
38
|
-
getAvailable,
|
|
39
|
-
getRecomendPlace,
|
|
38
|
+
getAvailable: inputGetAvailable,
|
|
39
|
+
getRecomendPlace: inputGetRecomendPlace,
|
|
40
40
|
mapContext,
|
|
41
41
|
disableLocator,
|
|
42
42
|
defaultPlace: inputDefaultPlace = {
|
|
@@ -53,8 +53,8 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
53
53
|
coordinatifyValueOfOnChangeRecommendPlace,
|
|
54
54
|
coordinatifyGeoPosition
|
|
55
55
|
} = useMapCoordinatify();
|
|
56
|
-
const
|
|
57
|
-
const
|
|
56
|
+
const getAvailable = inputGetAvailable && ((p) => inputGetAvailable(coordinatifyPlace(p)));
|
|
57
|
+
const getRecomendPlace = (p, context) => inputGetRecomendPlace(coordinatifyPlace(p), context).then((r) => r && unCoordinatifyRecommendZonePlaces(toCoordinateRecommendZonePlacesType(r)));
|
|
58
58
|
const {
|
|
59
59
|
apiMapDistance
|
|
60
60
|
} = useMapGeometry();
|
|
@@ -178,6 +178,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
178
178
|
isDragging
|
|
179
179
|
} = useMapDrag({
|
|
180
180
|
mapRef,
|
|
181
|
+
onDragStart: () => abortUpdatePlace(),
|
|
181
182
|
onChange: (point) => {
|
|
182
183
|
centerSource.source = "drag";
|
|
183
184
|
updatePlace(point);
|
|
@@ -185,6 +186,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
185
186
|
});
|
|
186
187
|
const {
|
|
187
188
|
updatePlace,
|
|
189
|
+
abortUpdatePlace,
|
|
188
190
|
updateRecommendPlaceOnlyInZone,
|
|
189
191
|
setPlaceCandidatesAndZone,
|
|
190
192
|
placeCandidates,
|
|
@@ -197,8 +199,8 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
197
199
|
queryingPlaceName: queryingTitle,
|
|
198
200
|
context: centerSource,
|
|
199
201
|
signal: abortController.signal,
|
|
200
|
-
getAvailable
|
|
201
|
-
getRecomendPlace
|
|
202
|
+
getAvailable,
|
|
203
|
+
getRecomendPlace,
|
|
202
204
|
getLimit: (context) => {
|
|
203
205
|
const source = context == null ? void 0 : context.source;
|
|
204
206
|
switch (source) {
|
package/dist/v2/chunks/{BusinessRecomendPlaceMap.3567a399.js → BusinessRecomendPlaceMap.81a4b640.js}
RENAMED
|
@@ -19,7 +19,7 @@ import { throwNoneManualAbortError, MANUAL_ABORT_MESSAGE } from "../utils/Manual
|
|
|
19
19
|
import { watchPostEffectOnce, generateCreateElementV2PropsOn } from "../utils/compare.js";
|
|
20
20
|
import { equalAssign, isPlacesInclude } from "../utils/helper.js";
|
|
21
21
|
import { detectBrowserPlatform } from "../utils/platform.js";
|
|
22
|
-
import { place2point, isPlaceEqual,
|
|
22
|
+
import { place2point, isPlaceEqual, isZoneEqual, geoPositionError2businessTimeout, pipeDefer } from "../utils/transform.js";
|
|
23
23
|
import { toCoordinatePointType, toCoordinateRecommendZonePlacesType, toCoordinatePlaceType } from "../utils/typeChecking.js";
|
|
24
24
|
import { AbsoluteAddressBox } from "../business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
|
|
25
25
|
import { DeviceOrientation } from "../business-components/DeviceOrientation/DeviceOrientation.js";
|
|
@@ -284,8 +284,8 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
|
|
|
284
284
|
emptyTitle,
|
|
285
285
|
queryingTitle,
|
|
286
286
|
geoErrorOnceNotificationKey = `BusinessRecomendPlaceMap_${Date.now()}`,
|
|
287
|
-
getAvailable,
|
|
288
|
-
getRecomendPlace,
|
|
287
|
+
getAvailable: inputGetAvailable,
|
|
288
|
+
getRecomendPlace: inputGetRecomendPlace,
|
|
289
289
|
mapContext
|
|
290
290
|
} = props;
|
|
291
291
|
const abortController = new AbortController();
|
|
@@ -298,8 +298,8 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
|
|
|
298
298
|
coordinatifyValueOfOnChangeRecommendPlace,
|
|
299
299
|
coordinatifyGeoPosition
|
|
300
300
|
} = useMapCoordinatify();
|
|
301
|
-
const
|
|
302
|
-
const
|
|
301
|
+
const getAvailable = inputGetAvailable && ((p) => inputGetAvailable(coordinatifyPlace(p)));
|
|
302
|
+
const getRecomendPlace = (p, context) => inputGetRecomendPlace(coordinatifyPlace(p), context).then((r) => r && unCoordinatifyRecommendZonePlaces(toCoordinateRecommendZonePlacesType(r)));
|
|
303
303
|
const {
|
|
304
304
|
apiMapDistance
|
|
305
305
|
} = useMapGeometry();
|
|
@@ -451,6 +451,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
|
|
|
451
451
|
isDragging
|
|
452
452
|
} = useMapDrag({
|
|
453
453
|
mapRef,
|
|
454
|
+
onDragStart: () => abortUpdatePlace(),
|
|
454
455
|
onChange: (point) => {
|
|
455
456
|
centerSource.source = "drag";
|
|
456
457
|
updatePlace(point);
|
|
@@ -459,6 +460,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
|
|
|
459
460
|
});
|
|
460
461
|
const {
|
|
461
462
|
updatePlace,
|
|
463
|
+
abortUpdatePlace,
|
|
462
464
|
updateRecommendPlaceOnlyInZone,
|
|
463
465
|
setPlaceCandidatesAndZone,
|
|
464
466
|
placeCandidates,
|
|
@@ -471,8 +473,8 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
|
|
|
471
473
|
queryingPlaceName: queryingTitle,
|
|
472
474
|
context: centerSource,
|
|
473
475
|
signal: abortController.signal,
|
|
474
|
-
getAvailable
|
|
475
|
-
getRecomendPlace
|
|
476
|
+
getAvailable,
|
|
477
|
+
getRecomendPlace,
|
|
476
478
|
getLimit: (context) => {
|
|
477
479
|
const source = context == null ? void 0 : context.source;
|
|
478
480
|
switch (source) {
|
|
@@ -6,6 +6,7 @@ export declare const DRAGEND_DETECTING_ANIMATION_DELAY = 50;
|
|
|
6
6
|
export interface UseMapDragProps<M = AmapMap | google.maps.Map> {
|
|
7
7
|
mapRef: ShallowRef<M | undefined>;
|
|
8
8
|
onChange?: (value: Point) => any;
|
|
9
|
+
onDragStart?: () => void;
|
|
9
10
|
}
|
|
10
11
|
export declare const useAmapDrag: (props: UseMapDragProps<AmapMap>) => {
|
|
11
12
|
centerRef: import("vue-demi").Ref<[number, number]>;
|
|
@@ -7,7 +7,7 @@ const ON_CHANGE_CENTER_INTERVAL = 200;
|
|
|
7
7
|
const DRAGEND_DETECTING_ANIMATION_DELAY = 50;
|
|
8
8
|
const GMAP_DRAG_END_DELAY_TO_TOUCH_END = 20;
|
|
9
9
|
const useAmapDrag = (props) => {
|
|
10
|
-
const { mapRef, onChange } = props;
|
|
10
|
+
const { mapRef, onChange, onDragStart } = props;
|
|
11
11
|
const centerRef = ref([0, 0]);
|
|
12
12
|
const isDragging = ref(false);
|
|
13
13
|
const isDragEndWaitingMovingEndRef = ref(false);
|
|
@@ -17,6 +17,7 @@ const useAmapDrag = (props) => {
|
|
|
17
17
|
const emitDragStart = () => {
|
|
18
18
|
pipeAsync(() => {
|
|
19
19
|
isDragging.value = true;
|
|
20
|
+
onDragStart == null ? void 0 : onDragStart();
|
|
20
21
|
})();
|
|
21
22
|
};
|
|
22
23
|
const handleZoomStart = () => {
|
|
@@ -76,12 +77,13 @@ const useAmapDrag = (props) => {
|
|
|
76
77
|
return { centerRef, isDragging };
|
|
77
78
|
};
|
|
78
79
|
const useGmapDrag = (props) => {
|
|
79
|
-
const { mapRef, onChange } = props;
|
|
80
|
+
const { mapRef, onChange, onDragStart } = props;
|
|
80
81
|
const centerRef = ref([0, 0]);
|
|
81
82
|
const isDragging = ref(false);
|
|
82
83
|
const emitDragStart = () => {
|
|
83
84
|
pipeAsync(() => {
|
|
84
85
|
isDragging.value = true;
|
|
86
|
+
onDragStart == null ? void 0 : onDragStart();
|
|
85
87
|
})();
|
|
86
88
|
};
|
|
87
89
|
const emitDragEnd = async () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { shallowRef, computed } from "vue-demi";
|
|
2
2
|
import { apiPingAmap, apiPingGmap } from "../api/pingConnection.js";
|
|
3
|
+
import { MANUAL_ABORT_MESSAGE } from "../utils/ManualAbortError.js";
|
|
3
4
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
4
5
|
import { createOneConcurrent, sleep, createRunOnce } from "../utils/helper.js";
|
|
5
6
|
import { patchGoogleMapLoader } from "../utils/patchGoogleMapLoader.js";
|
|
@@ -718,7 +719,7 @@ const useGmapLoader = (props) => {
|
|
|
718
719
|
const reloadPromise = reload(options, controller.signal);
|
|
719
720
|
pingStatusRef.value = await apiPingGmap();
|
|
720
721
|
if (pingStatusRef.value === "unconnected") {
|
|
721
|
-
controller.abort();
|
|
722
|
+
controller.abort(MANUAL_ABORT_MESSAGE);
|
|
722
723
|
continue;
|
|
723
724
|
}
|
|
724
725
|
await reloadPromise;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Ref } from "vue-demi";
|
|
2
2
|
import type { Place, Point } from "../types/interface";
|
|
3
|
+
import { type AbortSignalOption } from "../utils/helper";
|
|
3
4
|
export interface UseMapPlaceProps {
|
|
4
5
|
pointRef: Ref<Point>;
|
|
5
6
|
emptyPlaceName: string;
|
|
@@ -15,7 +16,7 @@ export declare const useAmapPlace: (props: UseMapPlaceProps) => {
|
|
|
15
16
|
};
|
|
16
17
|
updatePlace: (value: Point) => void;
|
|
17
18
|
setPlace: (value: Place) => void;
|
|
18
|
-
getPlaceByRegeo: ([lng, lat]: Point) => Promise<Place>;
|
|
19
|
+
getPlaceByRegeo: ([lng, lat]: Point, opt?: AbortSignalOption) => Promise<Place>;
|
|
19
20
|
};
|
|
20
21
|
export declare const useGmapPlace: (props: UseMapPlaceProps) => {
|
|
21
22
|
place: {
|
|
@@ -26,7 +27,7 @@ export declare const useGmapPlace: (props: UseMapPlaceProps) => {
|
|
|
26
27
|
};
|
|
27
28
|
updatePlace: (value: Point) => void;
|
|
28
29
|
setPlace: (value: Place) => void;
|
|
29
|
-
getPlaceByRegeo: ([lng, lat]: Point) => Promise<Place>;
|
|
30
|
+
getPlaceByRegeo: ([lng, lat]: Point, opt?: AbortSignalOption) => Promise<Place>;
|
|
30
31
|
};
|
|
31
32
|
export declare const useMapPlace: (props: UseMapPlaceProps) => {
|
|
32
33
|
place: {
|
|
@@ -37,5 +38,5 @@ export declare const useMapPlace: (props: UseMapPlaceProps) => {
|
|
|
37
38
|
};
|
|
38
39
|
updatePlace: (value: Point) => void;
|
|
39
40
|
setPlace: (value: Place) => void;
|
|
40
|
-
getPlaceByRegeo: ([lng, lat]: Point) => Promise<Place>;
|
|
41
|
+
getPlaceByRegeo: ([lng, lat]: Point, opt?: AbortSignalOption) => Promise<Place>;
|
|
41
42
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ref, reactive, watch } from "vue-demi";
|
|
2
2
|
import { REGEO_TIMEOUT } from "../api/contants.js";
|
|
3
3
|
import { createPipeTw } from "../utils/cn2tw.js";
|
|
4
|
-
import { equalAssign,
|
|
5
|
-
import { amapPlaceName2DisplayName, gmapPlaceName2DisplayName } from "../utils/transform.js";
|
|
4
|
+
import { equalAssign, AbortSignalAny } from "../utils/helper.js";
|
|
5
|
+
import { amapPlaceName2DisplayName, signal2promise, gmapPlaceName2DisplayName } from "../utils/transform.js";
|
|
6
6
|
import { inChina } from "./useMapInChina.js";
|
|
7
7
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
8
8
|
import { useUpdate } from "./useUdate.js";
|
|
9
9
|
const useAmapPlace = (props) => {
|
|
10
|
-
const { signal, onChange, emptyPlaceName } = props;
|
|
10
|
+
const { signal: inputSignal, onChange, emptyPlaceName } = props;
|
|
11
11
|
const defaultPoint = [...props.pointRef.value];
|
|
12
12
|
const pointRef = ref(defaultPoint);
|
|
13
13
|
const { readyPromise, language } = useMapSupplier();
|
|
@@ -17,7 +17,6 @@ const useAmapPlace = (props) => {
|
|
|
17
17
|
name: "",
|
|
18
18
|
displayName: ""
|
|
19
19
|
});
|
|
20
|
-
const abortable = createAbortable(signal);
|
|
21
20
|
const { idx: placeKey, update } = useUpdate();
|
|
22
21
|
const updatePlace = (value) => {
|
|
23
22
|
pointRef.value = value;
|
|
@@ -29,8 +28,9 @@ const useAmapPlace = (props) => {
|
|
|
29
28
|
place.name = value.name;
|
|
30
29
|
place.displayName = value.displayName;
|
|
31
30
|
};
|
|
32
|
-
const getPlaceByRegeo =
|
|
33
|
-
|
|
31
|
+
const getPlaceByRegeo = ([lng, lat], opt) => {
|
|
32
|
+
const signal = AbortSignalAny([opt == null ? void 0 : opt.signal, inputSignal]);
|
|
33
|
+
const regeoPromise = new Promise((resolve) => {
|
|
34
34
|
const handleFailed = () => {
|
|
35
35
|
const name = emptyPlaceName;
|
|
36
36
|
const displayName = emptyPlaceName;
|
|
@@ -64,7 +64,8 @@ const useAmapPlace = (props) => {
|
|
|
64
64
|
handleFailed();
|
|
65
65
|
}, REGEO_TIMEOUT);
|
|
66
66
|
});
|
|
67
|
-
|
|
67
|
+
return Promise.race([regeoPromise, signal2promise(signal)]);
|
|
68
|
+
};
|
|
68
69
|
watch(
|
|
69
70
|
() => [placeKey.value],
|
|
70
71
|
async () => {
|
|
@@ -77,7 +78,7 @@ const useAmapPlace = (props) => {
|
|
|
77
78
|
return { place, updatePlace, setPlace, getPlaceByRegeo };
|
|
78
79
|
};
|
|
79
80
|
const useGmapPlace = (props) => {
|
|
80
|
-
const { signal, onChange, emptyPlaceName } = props;
|
|
81
|
+
const { signal: inputSignal, onChange, emptyPlaceName } = props;
|
|
81
82
|
const defaultPoint = [...props.pointRef.value];
|
|
82
83
|
const pointRef = ref(defaultPoint);
|
|
83
84
|
const { readyPromise, language } = useMapSupplier();
|
|
@@ -88,7 +89,6 @@ const useGmapPlace = (props) => {
|
|
|
88
89
|
name: "",
|
|
89
90
|
displayName: ""
|
|
90
91
|
});
|
|
91
|
-
const abortable = createAbortable(signal);
|
|
92
92
|
const updatePlace = (value) => {
|
|
93
93
|
pointRef.value = value;
|
|
94
94
|
update();
|
|
@@ -99,8 +99,9 @@ const useGmapPlace = (props) => {
|
|
|
99
99
|
place.name = value.name;
|
|
100
100
|
place.displayName = value.displayName;
|
|
101
101
|
};
|
|
102
|
-
const getPlaceByRegeo =
|
|
103
|
-
|
|
102
|
+
const getPlaceByRegeo = ([lng, lat], opt) => {
|
|
103
|
+
const signal = AbortSignalAny([opt == null ? void 0 : opt.signal, inputSignal]);
|
|
104
|
+
const regeoPromise = new Promise((resolve) => {
|
|
104
105
|
const handleFailed = (err) => {
|
|
105
106
|
if (err)
|
|
106
107
|
console.error(err);
|
|
@@ -122,7 +123,8 @@ const useGmapPlace = (props) => {
|
|
|
122
123
|
handleFailed();
|
|
123
124
|
}, REGEO_TIMEOUT);
|
|
124
125
|
});
|
|
125
|
-
|
|
126
|
+
return Promise.race([regeoPromise, signal2promise(signal)]);
|
|
127
|
+
};
|
|
126
128
|
watch(
|
|
127
129
|
() => placeKey.value,
|
|
128
130
|
async () => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Place, Point, RecommendZonePlaces, ValueOfOnChangeRecommendPlace, Zone } from "../types/interface";
|
|
2
|
+
import { type AbortSignalOption } from "../utils/helper";
|
|
2
3
|
import { type UseMapPlaceProps } from "./useMapPlace";
|
|
3
4
|
export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
|
|
4
5
|
defaultPoint: Point;
|
|
@@ -30,9 +31,10 @@ export declare const useMapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C>
|
|
|
30
31
|
availableRef: import("vue-demi").Ref<boolean>;
|
|
31
32
|
forceRef: import("vue-demi").Ref<boolean>;
|
|
32
33
|
isQueryingRef: import("vue-demi").Ref<boolean>;
|
|
33
|
-
updateRecommendPlace: (place: Place) => Promise<void>;
|
|
34
|
-
updateRecommendPlaceOnlyInZone: (place: Place) => Promise<void>;
|
|
35
|
-
updatePlaceCandidates: (place: Place) => Promise<ValueOfOnChangeRecommendPlace>;
|
|
34
|
+
updateRecommendPlace: (place: Place, opt?: AbortSignalOption) => Promise<void>;
|
|
35
|
+
updateRecommendPlaceOnlyInZone: (place: Place, opt?: AbortSignalOption) => Promise<void>;
|
|
36
|
+
updatePlaceCandidates: (place: Place, opt?: AbortSignalOption) => Promise<ValueOfOnChangeRecommendPlace>;
|
|
36
37
|
updatePlace: (point: Point) => Promise<void>;
|
|
38
|
+
abortUpdatePlace: () => void;
|
|
37
39
|
setPlaceCandidatesAndZone: ({ zone, places: placeCandidates }: RecommendZonePlaces) => void;
|
|
38
40
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref, reactive } from "vue-demi";
|
|
2
2
|
import { GET_RECOMMEND_PLACE_TIMEOUT } from "../api/contants.js";
|
|
3
3
|
import { logNoneManualAbortError } from "../utils/ManualAbortError.js";
|
|
4
|
-
import {
|
|
4
|
+
import { createAbortableOneConcurrent, AbortSignalAny, equalAssign, isPlacesInclude, createAbortable } from "../utils/helper.js";
|
|
5
5
|
import { isZoneEqual, place2point, isPlaceEqual, businessCandidatesToAdsorptionPlace } from "../utils/transform.js";
|
|
6
6
|
import { useMapGeometry, apiLocalIsPointInRing } from "./useMapGeometry.js";
|
|
7
7
|
import { useMapPlace } from "./useMapPlace.js";
|
|
@@ -43,7 +43,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
43
43
|
context,
|
|
44
44
|
emptyPlaceName,
|
|
45
45
|
queryingPlaceName,
|
|
46
|
-
signal,
|
|
46
|
+
signal: inputSignal,
|
|
47
47
|
onChange,
|
|
48
48
|
onQueryingPlace,
|
|
49
49
|
onChangePlace
|
|
@@ -52,12 +52,12 @@ const useMapRecomendPlace = (props) => {
|
|
|
52
52
|
const forceRef = ref(false);
|
|
53
53
|
const placeCandidatesRef = ref([]);
|
|
54
54
|
const zoneRef = ref();
|
|
55
|
-
const abortable = createAbortable(
|
|
55
|
+
const abortable = createAbortable(inputSignal);
|
|
56
56
|
const { apiMapDistance } = useMapGeometry();
|
|
57
57
|
const { getPlaceByRegeo } = useMapPlace({
|
|
58
58
|
emptyPlaceName,
|
|
59
59
|
pointRef: ref([...defaultPoint]),
|
|
60
|
-
signal
|
|
60
|
+
signal: inputSignal
|
|
61
61
|
});
|
|
62
62
|
const recomendPlace = reactive({
|
|
63
63
|
lng: defaultPoint[0],
|
|
@@ -71,7 +71,8 @@ const useMapRecomendPlace = (props) => {
|
|
|
71
71
|
abortable(getAvailable),
|
|
72
72
|
GET_RECOMMEND_PLACE_TIMEOUT
|
|
73
73
|
);
|
|
74
|
-
const findAttachedPlace =
|
|
74
|
+
const findAttachedPlace = async (place, opt) => {
|
|
75
|
+
var _a;
|
|
75
76
|
const {
|
|
76
77
|
places: placeCandidates,
|
|
77
78
|
zone,
|
|
@@ -79,6 +80,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
79
80
|
force = false,
|
|
80
81
|
adsorption = false
|
|
81
82
|
} = await getRecomendPlaceNoFail({ ...place }, context);
|
|
83
|
+
(_a = opt == null ? void 0 : opt.signal) == null ? void 0 : _a.throwIfAborted();
|
|
82
84
|
if (!available || !placeCandidates) {
|
|
83
85
|
return { place: { ...place }, zone, candidates: [], available, force };
|
|
84
86
|
}
|
|
@@ -94,40 +96,38 @@ const useMapRecomendPlace = (props) => {
|
|
|
94
96
|
const limit = getLimit(context);
|
|
95
97
|
const resultPlace = zone || shortestDistance <= limit ? shortestPlace : place;
|
|
96
98
|
return { place: { ...resultPlace }, zone, candidates: placeCandidates, available, force };
|
|
97
|
-
}
|
|
98
|
-
const getRecommendPlaceZoneState =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return { place: { ...closestPlace }, zone: zone2, available, candidates, force };
|
|
113
|
-
}
|
|
114
|
-
const regeoPlace = await reGeoPlacePromise;
|
|
115
|
-
return { place: { ...regeoPlace }, zone: zone2, available, candidates, force };
|
|
99
|
+
};
|
|
100
|
+
const getRecommendPlaceZoneState = async (point, prevState, opt) => {
|
|
101
|
+
const [lng, lat] = point;
|
|
102
|
+
const zone = zoneRef.value;
|
|
103
|
+
if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
|
|
104
|
+
const reGeoPlacePromise = getPlaceByRegeo(point, opt);
|
|
105
|
+
const {
|
|
106
|
+
place: closestPlace,
|
|
107
|
+
candidates,
|
|
108
|
+
available,
|
|
109
|
+
force,
|
|
110
|
+
zone: zone2
|
|
111
|
+
} = await findAttachedPlace({ lng, lat, name: "", displayName: "" }, opt);
|
|
112
|
+
if (isPlacesInclude(candidates, closestPlace)) {
|
|
113
|
+
return { place: { ...closestPlace }, zone: zone2, available, candidates, force };
|
|
116
114
|
}
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
prevState.candidates,
|
|
120
|
-
apiMapDistance
|
|
121
|
-
);
|
|
122
|
-
return {
|
|
123
|
-
place: { ...resultPlace },
|
|
124
|
-
zone,
|
|
125
|
-
available: prevState.available,
|
|
126
|
-
force: prevState.force,
|
|
127
|
-
candidates: prevState.candidates
|
|
128
|
-
};
|
|
115
|
+
const regeoPlace = await reGeoPlacePromise;
|
|
116
|
+
return { place: { ...regeoPlace }, zone: zone2, available, candidates, force };
|
|
129
117
|
}
|
|
130
|
-
|
|
118
|
+
const { shortestPlace: resultPlace } = findNearestPlace(
|
|
119
|
+
{ lng, lat, name: "", displayName: "" },
|
|
120
|
+
prevState.candidates,
|
|
121
|
+
apiMapDistance
|
|
122
|
+
);
|
|
123
|
+
return {
|
|
124
|
+
place: { ...resultPlace },
|
|
125
|
+
zone,
|
|
126
|
+
available: prevState.available,
|
|
127
|
+
force: prevState.force,
|
|
128
|
+
candidates: prevState.candidates
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
131
|
const updateIntermediateQueryingState = (point) => {
|
|
132
132
|
const zone = zoneRef.value;
|
|
133
133
|
if (zone && apiLocalIsPointInRing(point, zone.path))
|
|
@@ -147,56 +147,64 @@ const useMapRecomendPlace = (props) => {
|
|
|
147
147
|
equalAssign(recomendPlace, { ...intermediateQueryingPlace });
|
|
148
148
|
onQueryingPlace == null ? void 0 : onQueryingPlace({ ...intermediateQueryingPlace });
|
|
149
149
|
};
|
|
150
|
-
const updatePlace
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
candidates,
|
|
155
|
-
zone,
|
|
156
|
-
available,
|
|
157
|
-
force
|
|
158
|
-
} = await getRecommendPlaceZoneState(point, {
|
|
159
|
-
place: recomendPlace,
|
|
160
|
-
available: availableRef.value,
|
|
161
|
-
force: forceRef.value,
|
|
162
|
-
candidates: placeCandidatesRef.value,
|
|
163
|
-
zone: zoneRef.value
|
|
164
|
-
});
|
|
165
|
-
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
166
|
-
isQueryingRef.value = false;
|
|
167
|
-
availableRef.value = available;
|
|
168
|
-
forceRef.value = force;
|
|
169
|
-
zoneRef.value = zone;
|
|
170
|
-
placeCandidatesRef.value = candidates;
|
|
171
|
-
equalAssign(recomendPlace, { ...resultPlace });
|
|
172
|
-
onChangePlace == null ? void 0 : onChangePlace({ ...resultPlace });
|
|
173
|
-
const inputPlace = { name: "", displayName: "", lng: point[0], lat: point[1] };
|
|
174
|
-
onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace, isInZone: !!zone, isSameZone });
|
|
175
|
-
});
|
|
176
|
-
const updatePlaceCandidates = abortable(
|
|
177
|
-
async (place) => {
|
|
178
|
-
updateIntermediateQueryingState(place2point(place));
|
|
150
|
+
const { fn: updatePlace, abort: abortUpdatePlace } = createAbortableOneConcurrent(
|
|
151
|
+
(concurrentSignal) => async (point) => {
|
|
152
|
+
const signal = AbortSignalAny([concurrentSignal, inputSignal]);
|
|
153
|
+
updateIntermediateQueryingState(point);
|
|
179
154
|
const {
|
|
180
|
-
|
|
155
|
+
place: resultPlace,
|
|
156
|
+
candidates,
|
|
181
157
|
zone,
|
|
182
|
-
available
|
|
183
|
-
force
|
|
184
|
-
} = await
|
|
158
|
+
available,
|
|
159
|
+
force
|
|
160
|
+
} = await getRecommendPlaceZoneState(
|
|
161
|
+
point,
|
|
162
|
+
{
|
|
163
|
+
place: recomendPlace,
|
|
164
|
+
available: availableRef.value,
|
|
165
|
+
force: forceRef.value,
|
|
166
|
+
candidates: placeCandidatesRef.value,
|
|
167
|
+
zone: zoneRef.value
|
|
168
|
+
},
|
|
169
|
+
{ signal }
|
|
170
|
+
);
|
|
185
171
|
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
186
172
|
isQueryingRef.value = false;
|
|
187
|
-
availableRef.value =
|
|
188
|
-
forceRef.value =
|
|
173
|
+
availableRef.value = available;
|
|
174
|
+
forceRef.value = force;
|
|
189
175
|
zoneRef.value = zone;
|
|
190
|
-
placeCandidatesRef.value =
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
176
|
+
placeCandidatesRef.value = candidates;
|
|
177
|
+
equalAssign(recomendPlace, { ...resultPlace });
|
|
178
|
+
onChangePlace == null ? void 0 : onChangePlace({ ...resultPlace });
|
|
179
|
+
const inputPlace = { name: "", displayName: "", lng: point[0], lat: point[1] };
|
|
180
|
+
onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace, isInZone: !!zone, isSameZone });
|
|
181
|
+
},
|
|
182
|
+
{ silent: true }
|
|
198
183
|
);
|
|
199
|
-
const
|
|
184
|
+
const updatePlaceCandidates = async (place, opt) => {
|
|
185
|
+
const signal = AbortSignalAny([opt == null ? void 0 : opt.signal, inputSignal]);
|
|
186
|
+
updateIntermediateQueryingState(place2point(place));
|
|
187
|
+
const {
|
|
188
|
+
places: placeCandidates,
|
|
189
|
+
zone,
|
|
190
|
+
available = false,
|
|
191
|
+
force = false
|
|
192
|
+
} = await getRecomendPlaceNoFail({ ...place }, context);
|
|
193
|
+
signal.throwIfAborted();
|
|
194
|
+
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
195
|
+
isQueryingRef.value = false;
|
|
196
|
+
availableRef.value = !!available;
|
|
197
|
+
forceRef.value = !!force;
|
|
198
|
+
zoneRef.value = zone;
|
|
199
|
+
placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
|
|
200
|
+
return {
|
|
201
|
+
inputPlace: { ...place },
|
|
202
|
+
isInZone: !!zone,
|
|
203
|
+
place: { ...place },
|
|
204
|
+
isSameZone
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
const updateRecommendPlace = async (place, opt) => {
|
|
200
208
|
updateIntermediateQueryingState(place2point(place));
|
|
201
209
|
const {
|
|
202
210
|
place: resultPlace,
|
|
@@ -204,7 +212,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
204
212
|
available,
|
|
205
213
|
force,
|
|
206
214
|
zone
|
|
207
|
-
} = await findAttachedPlace(place);
|
|
215
|
+
} = await findAttachedPlace(place, opt);
|
|
208
216
|
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
209
217
|
isQueryingRef.value = false;
|
|
210
218
|
availableRef.value = available;
|
|
@@ -219,8 +227,8 @@ const useMapRecomendPlace = (props) => {
|
|
|
219
227
|
isInZone: !!zone,
|
|
220
228
|
isSameZone
|
|
221
229
|
});
|
|
222
|
-
}
|
|
223
|
-
const updateRecommendPlaceOnlyInZone =
|
|
230
|
+
};
|
|
231
|
+
const updateRecommendPlaceOnlyInZone = async (place, opt) => {
|
|
224
232
|
var _a;
|
|
225
233
|
updateIntermediateQueryingState(place2point(place));
|
|
226
234
|
const {
|
|
@@ -229,7 +237,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
229
237
|
available,
|
|
230
238
|
force,
|
|
231
239
|
zone
|
|
232
|
-
} = await findAttachedPlace(place);
|
|
240
|
+
} = await findAttachedPlace(place, opt);
|
|
233
241
|
const resultPlace = zone ? foundPlace : (_a = candidates.find((p) => isPlaceEqual(p, place))) != null ? _a : place;
|
|
234
242
|
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
235
243
|
isQueryingRef.value = false;
|
|
@@ -245,7 +253,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
245
253
|
isInZone: !!zone,
|
|
246
254
|
isSameZone
|
|
247
255
|
});
|
|
248
|
-
}
|
|
256
|
+
};
|
|
249
257
|
const setPlaceCandidatesAndZone = ({ zone, places: placeCandidates }) => {
|
|
250
258
|
availableRef.value = true;
|
|
251
259
|
forceRef.value = !!zone;
|
|
@@ -263,6 +271,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
263
271
|
updateRecommendPlaceOnlyInZone,
|
|
264
272
|
updatePlaceCandidates,
|
|
265
273
|
updatePlace,
|
|
274
|
+
abortUpdatePlace,
|
|
266
275
|
setPlaceCandidatesAndZone
|
|
267
276
|
};
|
|
268
277
|
};
|
|
@@ -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.81a4b640.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
|
@@ -2,7 +2,7 @@ import "./utils/alipayPolyfill.js";
|
|
|
2
2
|
import { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
|
|
3
3
|
import { AddressBox } from "./business-components/AddressBox/AddressBox.js";
|
|
4
4
|
import { BusinessQuotingMap } from "./business-components/BusinessQuotingMap/BusinessQuotingMap.js";
|
|
5
|
-
import { B } from "./chunks/BusinessRecomendPlaceMap.
|
|
5
|
+
import { B } from "./chunks/BusinessRecomendPlaceMap.81a4b640.js";
|
|
6
6
|
import { BusinessReselectPlaceMap } from "./business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js";
|
|
7
7
|
import { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js";
|
|
8
8
|
import { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js";
|