@heycar/heycars-map 1.0.0-coordinate7 → 2.0.0-switchMap10
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 +45 -52
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/v2/App.js +8 -4
- package/dist/v2/Demo/DemoBusinessQuoting.js +6 -12
- package/dist/v2/Demo/DemoBusinessRecomendPlace.js +3 -8
- package/dist/v2/Demo/DemoBusinessReselectPlace.js +2 -7
- package/dist/v2/Demo/DemoBusinessTaxiEnd.d.ts +1 -3
- package/dist/v2/Demo/DemoBusinessTaxiEnd.js +2 -18
- package/dist/v2/Demo/DemoBusinessTaxiService.d.ts +1 -2392
- package/dist/v2/Demo/DemoBusinessTaxiService.js +6 -19
- package/dist/v2/api/cdn.d.ts +1 -0
- package/dist/v2/api/cdn.js +2 -0
- package/dist/v2/api/googleSnapRoad.js +7 -2
- package/dist/v2/api/pingConnection.d.ts +9 -0
- package/dist/v2/api/pingConnection.js +111 -0
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +5 -5
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +46 -12
- package/dist/v2/business-components/BusinessQuotingMap/index.js +3 -2
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -3
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +7 -4
- package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +4 -3
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +3 -2
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +60 -24
- package/dist/v2/business-components/BusinessReselectPlaceMap/index.js +3 -2
- package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +2 -3
- package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
- package/dist/v2/business-components/BusinessTaxiEndMap/index.js +3 -2
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +5 -5
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +52 -21
- package/dist/v2/business-components/BusinessTaxiServiceMap/index.js +3 -2
- package/dist/v2/chunks/{BusinessRecomendPlaceMap.87ea3b2f.js → BusinessRecomendPlaceMap.b4d45108.js} +65 -30
- package/dist/v2/chunks/{Loading.fc6e75d0.js → Loading.492acbc2.js} +30 -2
- package/dist/v2/components/AmapMarker/AmapMarker.js +2 -1
- package/dist/v2/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
- package/dist/v2/components/Loading/Loading.css.d.ts +5 -0
- package/dist/v2/components/Loading/Loading.d.ts +6 -0
- package/dist/v2/components/Loading/Loading.js +4 -2
- package/dist/v2/components/Loading/index.js +3 -2
- package/dist/v2/components/MapProvider/MapProvider.d.ts +2 -2
- package/dist/v2/components/MapProvider/MapProvider.js +24 -13
- package/dist/v2/css/Loading-49e58ced.css +46 -0
- package/dist/v2/demi-polyfill/demi-polyfill.d.ts +1 -0
- package/dist/v2/hooks/useDrivingRoute.js +4 -0
- package/dist/v2/hooks/useMapGCJ02.js +4 -37
- package/dist/v2/hooks/useMapGeometry.d.ts +1 -3
- package/dist/v2/hooks/useMapGeometry.js +4 -4
- package/dist/v2/hooks/useMapGraspRoad.js +1 -2
- package/dist/v2/hooks/useMapInChina.d.ts +3 -15
- package/dist/v2/hooks/useMapInChina.js +11 -16
- package/dist/v2/hooks/useMapLoader.d.ts +18 -10
- package/dist/v2/hooks/useMapLoader.js +159 -82
- package/dist/v2/hooks/useMapPlace.d.ts +1 -0
- package/dist/v2/hooks/useMapPlace.js +52 -44
- package/dist/v2/hooks/useMapRecomendPlace.d.ts +1 -0
- package/dist/v2/hooks/useMapRecomendPlace.js +75 -67
- package/dist/v2/hooks/useMapSupplier.d.ts +8 -0
- package/dist/v2/hooks/useMapSupplier.js +17 -0
- package/dist/v2/hooks/usePingConnection.d.ts +10 -0
- package/dist/v2/hooks/usePingConnection.js +26 -0
- package/dist/v2/hooks-business/useBusinessAlarm.d.ts +3 -0
- package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
- package/dist/v2/hooks-business/useBusinessQuotingMap.js +10 -10
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
- package/dist/v2/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
- package/dist/v2/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
- package/dist/v2/hooks-business/useBusinessTaxiServiceMap.js +5 -10
- package/dist/v2/index.js +1 -1
- package/dist/v2/types/global.d.ts +3 -0
- package/dist/v2/types/interface.d.ts +1 -1
- package/dist/v2/utils/ManualAbortError.d.ts +3 -0
- package/dist/v2/utils/ManualAbortError.js +14 -0
- package/dist/v2/utils/compare.d.ts +4 -0
- package/dist/v2/utils/compare.js +6 -0
- package/dist/v2/utils/helper.d.ts +6 -0
- package/dist/v2/utils/helper.js +43 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/patchGoogleMapLoader.d.ts +2 -0
- package/dist/v2/utils/patchGoogleMapLoader.js +64 -0
- package/dist/v3/App.js +8 -4
- package/dist/v3/Demo/DemoBusinessQuoting.js +7 -13
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +3 -8
- package/dist/v3/Demo/DemoBusinessReselectPlace.js +2 -7
- package/dist/v3/Demo/DemoBusinessTaxiEnd.d.ts +1 -3
- package/dist/v3/Demo/DemoBusinessTaxiEnd.js +3 -17
- package/dist/v3/Demo/DemoBusinessTaxiService.d.ts +1 -2392
- package/dist/v3/Demo/DemoBusinessTaxiService.js +6 -17
- package/dist/v3/api/cdn.d.ts +1 -0
- package/dist/v3/api/cdn.js +2 -0
- package/dist/v3/api/googleSnapRoad.js +7 -2
- package/dist/v3/api/pingConnection.d.ts +9 -0
- package/dist/v3/api/pingConnection.js +111 -0
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +16 -7
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +46 -12
- package/dist/v3/business-components/BusinessQuotingMap/index.js +3 -2
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +10 -3
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +7 -4
- package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +4 -3
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +10 -2
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +60 -24
- package/dist/v3/business-components/BusinessReselectPlaceMap/index.js +3 -2
- package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
- package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
- package/dist/v3/business-components/BusinessTaxiEndMap/index.js +3 -2
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +19 -7
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +52 -21
- package/dist/v3/business-components/BusinessTaxiServiceMap/index.js +3 -2
- package/dist/v3/chunks/{BusinessRecomendPlaceMap.57b15c64.js → BusinessRecomendPlaceMap.6ba5dbb1.js} +65 -30
- package/dist/v3/chunks/{Loading.a8e2f26a.js → Loading.21d8e759.js} +26 -2
- package/dist/v3/components/AmapMarker/AmapMarker.js +2 -1
- package/dist/v3/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
- package/dist/v3/components/Loading/Loading.css.d.ts +5 -0
- package/dist/v3/components/Loading/Loading.d.ts +8 -0
- package/dist/v3/components/Loading/Loading.js +4 -2
- package/dist/v3/components/Loading/index.js +3 -2
- package/dist/v3/components/MapProvider/MapProvider.d.ts +6 -3
- package/dist/v3/components/MapProvider/MapProvider.js +22 -13
- package/dist/v3/css/Loading-49e58ced.css +46 -0
- package/dist/v3/demi-polyfill/demi-polyfill.d.ts +1 -0
- package/dist/v3/hooks/useDrivingRoute.js +4 -0
- package/dist/v3/hooks/useMapGCJ02.js +4 -37
- package/dist/v3/hooks/useMapGeometry.d.ts +1 -3
- package/dist/v3/hooks/useMapGeometry.js +4 -4
- package/dist/v3/hooks/useMapGraspRoad.js +1 -2
- package/dist/v3/hooks/useMapInChina.d.ts +3 -15
- package/dist/v3/hooks/useMapInChina.js +11 -16
- package/dist/v3/hooks/useMapLoader.d.ts +18 -10
- package/dist/v3/hooks/useMapLoader.js +159 -82
- package/dist/v3/hooks/useMapPlace.d.ts +1 -0
- package/dist/v3/hooks/useMapPlace.js +52 -44
- package/dist/v3/hooks/useMapRecomendPlace.d.ts +1 -0
- package/dist/v3/hooks/useMapRecomendPlace.js +75 -67
- package/dist/v3/hooks/useMapSupplier.d.ts +8 -0
- package/dist/v3/hooks/useMapSupplier.js +17 -0
- package/dist/v3/hooks/usePingConnection.d.ts +10 -0
- package/dist/v3/hooks/usePingConnection.js +26 -0
- package/dist/v3/hooks-business/useBusinessAlarm.d.ts +3 -0
- package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
- package/dist/v3/hooks-business/useBusinessQuotingMap.js +10 -10
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
- package/dist/v3/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
- package/dist/v3/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
- package/dist/v3/hooks-business/useBusinessTaxiServiceMap.js +5 -10
- package/dist/v3/index.js +1 -1
- package/dist/v3/types/global.d.ts +3 -0
- package/dist/v3/types/interface.d.ts +1 -1
- package/dist/v3/utils/ManualAbortError.d.ts +3 -0
- package/dist/v3/utils/ManualAbortError.js +14 -0
- package/dist/v3/utils/compare.d.ts +4 -0
- package/dist/v3/utils/compare.js +6 -0
- package/dist/v3/utils/helper.d.ts +6 -0
- package/dist/v3/utils/helper.js +43 -0
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/patchGoogleMapLoader.d.ts +2 -0
- package/dist/v3/utils/patchGoogleMapLoader.js +64 -0
- package/package.json +2 -2
- package/dist/v2/Demo/Demo.d.ts +0 -3
- package/dist/v2/Demo/Demo.js +0 -1634
- package/dist/v2/api/googleConnection.d.ts +0 -5
- package/dist/v2/api/googleConnection.js +0 -51
- package/dist/v2/components/AmapLoader/AmapLoader.d.ts +0 -5
- package/dist/v2/components/AmapLoader/AmapLoader.js +0 -21
- package/dist/v2/components/AmapLoader/index.d.ts +0 -1
- package/dist/v2/components/AmapLoader/index.js +0 -4
- package/dist/v2/components/GmapLoader/GmapLoader.d.ts +0 -5
- package/dist/v2/components/GmapLoader/GmapLoader.js +0 -21
- package/dist/v2/components/GmapLoader/index.d.ts +0 -1
- package/dist/v2/components/GmapLoader/index.js +0 -4
- package/dist/v2/css/Loading-523061b9.css +0 -9
- package/dist/v2/hooks/useGoogleConnection.d.ts +0 -7
- package/dist/v2/hooks/useGoogleConnection.js +0 -15
- package/dist/v2/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
- package/dist/v2/hooks-business/useBusinessTaxiEndMap.js +0 -7
- package/dist/v3/Demo/Demo.d.ts +0 -9
- package/dist/v3/Demo/Demo.js +0 -1612
- package/dist/v3/api/googleConnection.d.ts +0 -5
- package/dist/v3/api/googleConnection.js +0 -51
- package/dist/v3/components/AmapLoader/AmapLoader.d.ts +0 -10
- package/dist/v3/components/AmapLoader/AmapLoader.js +0 -21
- package/dist/v3/components/AmapLoader/index.d.ts +0 -1
- package/dist/v3/components/AmapLoader/index.js +0 -4
- package/dist/v3/components/GmapLoader/GmapLoader.d.ts +0 -10
- package/dist/v3/components/GmapLoader/GmapLoader.js +0 -21
- package/dist/v3/components/GmapLoader/index.d.ts +0 -1
- package/dist/v3/components/GmapLoader/index.js +0 -4
- package/dist/v3/css/Loading-523061b9.css +0 -9
- package/dist/v3/hooks/useGoogleConnection.d.ts +0 -7
- package/dist/v3/hooks/useGoogleConnection.js +0 -15
- package/dist/v3/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
- package/dist/v3/hooks-business/useBusinessTaxiEndMap.js +0 -7
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ref, reactive } from "vue-demi";
|
|
2
2
|
import { GET_RECOMMEND_PLACE_TIMEOUT } from "../api/contants.js";
|
|
3
|
-
import {
|
|
3
|
+
import { logNoneManualAbortError } from "../utils/ManualAbortError.js";
|
|
4
|
+
import { equalAssign, createAbortable, isPlacesInclude } from "../utils/helper.js";
|
|
4
5
|
import { isZoneEqual, place2point, isPlaceEqual, businessCandidatesToAdsorptionPlace } from "../utils/transform.js";
|
|
5
|
-
import { useMapGeometry } from "./useMapGeometry.js";
|
|
6
|
+
import { useMapGeometry, apiLocalIsPointInRing } from "./useMapGeometry.js";
|
|
6
7
|
import { useMapPlace } from "./useMapPlace.js";
|
|
7
8
|
function mergeGetRecommendPlaceAndGetAvailable(getRecomendPlace, getAvailable, timeout) {
|
|
8
9
|
return function mergedGetRecommendPlace(place, context) {
|
|
@@ -11,9 +12,9 @@ function mergeGetRecommendPlaceAndGetAvailable(getRecomendPlace, getAvailable, t
|
|
|
11
12
|
getAvailable == null ? void 0 : getAvailable(place).then((value) => {
|
|
12
13
|
if (!value)
|
|
13
14
|
resolve({ available: false });
|
|
14
|
-
}).catch(
|
|
15
|
+
}).catch(logNoneManualAbortError);
|
|
15
16
|
getRecomendPlace(place, context).then((result) => resolve(result != null ? result : { available })).catch((error) => {
|
|
16
|
-
|
|
17
|
+
logNoneManualAbortError(error);
|
|
17
18
|
resolve({ available });
|
|
18
19
|
});
|
|
19
20
|
setTimeout(() => resolve({ available }), timeout);
|
|
@@ -42,6 +43,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
42
43
|
context,
|
|
43
44
|
emptyPlaceName,
|
|
44
45
|
queryingPlaceName,
|
|
46
|
+
signal,
|
|
45
47
|
onChange,
|
|
46
48
|
onQueryingPlace,
|
|
47
49
|
onChangePlace
|
|
@@ -50,10 +52,12 @@ const useMapRecomendPlace = (props) => {
|
|
|
50
52
|
const forceRef = ref(false);
|
|
51
53
|
const placeCandidatesRef = ref([]);
|
|
52
54
|
const zoneRef = ref();
|
|
53
|
-
const
|
|
55
|
+
const abortable = createAbortable(signal);
|
|
56
|
+
const { apiMapDistance } = useMapGeometry();
|
|
54
57
|
const { getPlaceByRegeo } = useMapPlace({
|
|
55
58
|
emptyPlaceName,
|
|
56
|
-
pointRef: ref([...defaultPoint])
|
|
59
|
+
pointRef: ref([...defaultPoint]),
|
|
60
|
+
signal
|
|
57
61
|
});
|
|
58
62
|
const recomendPlace = reactive({
|
|
59
63
|
lng: defaultPoint[0],
|
|
@@ -63,11 +67,11 @@ const useMapRecomendPlace = (props) => {
|
|
|
63
67
|
});
|
|
64
68
|
const isQueryingRef = ref(false);
|
|
65
69
|
const getRecomendPlaceNoFail = mergeGetRecommendPlaceAndGetAvailable(
|
|
66
|
-
getRecomendPlace,
|
|
67
|
-
getAvailable,
|
|
70
|
+
abortable(getRecomendPlace),
|
|
71
|
+
abortable(getAvailable),
|
|
68
72
|
GET_RECOMMEND_PLACE_TIMEOUT
|
|
69
73
|
);
|
|
70
|
-
const findAttachedPlace = async (place) => {
|
|
74
|
+
const findAttachedPlace = abortable(async (place) => {
|
|
71
75
|
const {
|
|
72
76
|
places: placeCandidates,
|
|
73
77
|
zone,
|
|
@@ -90,41 +94,43 @@ const useMapRecomendPlace = (props) => {
|
|
|
90
94
|
const limit = getLimit(context);
|
|
91
95
|
const resultPlace = zone || shortestDistance <= limit ? shortestPlace : place;
|
|
92
96
|
return { place: { ...resultPlace }, zone, candidates: placeCandidates, available, force };
|
|
93
|
-
};
|
|
94
|
-
const getRecommendPlaceZoneState =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
});
|
|
98
|
+
const getRecommendPlaceZoneState = abortable(
|
|
99
|
+
async (point, prevState) => {
|
|
100
|
+
const [lng, lat] = point;
|
|
101
|
+
const zone = zoneRef.value;
|
|
102
|
+
if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
|
|
103
|
+
const reGeoPlacePromise = getPlaceByRegeo(point);
|
|
104
|
+
const {
|
|
105
|
+
place: closestPlace,
|
|
106
|
+
candidates,
|
|
107
|
+
available,
|
|
108
|
+
force,
|
|
109
|
+
zone: zone2
|
|
110
|
+
} = await findAttachedPlace({ lng, lat, name: "", displayName: "" });
|
|
111
|
+
if (isPlacesInclude(candidates, closestPlace)) {
|
|
112
|
+
return { place: { ...closestPlace }, zone: zone2, available, candidates, force };
|
|
113
|
+
}
|
|
114
|
+
const regeoPlace = await reGeoPlacePromise;
|
|
115
|
+
return { place: { ...regeoPlace }, zone: zone2, available, candidates, force };
|
|
108
116
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
117
|
+
const { shortestPlace: resultPlace } = findNearestPlace(
|
|
118
|
+
{ lng, lat, name: "", displayName: "" },
|
|
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
|
+
};
|
|
111
129
|
}
|
|
112
|
-
|
|
113
|
-
{ lng, lat, name: "", displayName: "" },
|
|
114
|
-
prevState.candidates,
|
|
115
|
-
apiMapDistance
|
|
116
|
-
);
|
|
117
|
-
return {
|
|
118
|
-
place: { ...resultPlace },
|
|
119
|
-
zone,
|
|
120
|
-
available: prevState.available,
|
|
121
|
-
force: prevState.force,
|
|
122
|
-
candidates: prevState.candidates
|
|
123
|
-
};
|
|
124
|
-
};
|
|
130
|
+
);
|
|
125
131
|
const updateIntermediateQueryingState = (point) => {
|
|
126
132
|
const zone = zoneRef.value;
|
|
127
|
-
if (zone &&
|
|
133
|
+
if (zone && apiLocalIsPointInRing(point, zone.path))
|
|
128
134
|
return;
|
|
129
135
|
const [lng, lat] = point;
|
|
130
136
|
const intermediateQueryingPlace = {
|
|
@@ -141,7 +147,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
141
147
|
equalAssign(recomendPlace, { ...intermediateQueryingPlace });
|
|
142
148
|
onQueryingPlace == null ? void 0 : onQueryingPlace({ ...intermediateQueryingPlace });
|
|
143
149
|
};
|
|
144
|
-
const updatePlace = async (point) => {
|
|
150
|
+
const updatePlace = abortable(async (point) => {
|
|
145
151
|
updateIntermediateQueryingState(point);
|
|
146
152
|
const {
|
|
147
153
|
place: resultPlace,
|
|
@@ -166,29 +172,31 @@ const useMapRecomendPlace = (props) => {
|
|
|
166
172
|
onChangePlace == null ? void 0 : onChangePlace({ ...resultPlace });
|
|
167
173
|
const inputPlace = { name: "", displayName: "", lng: point[0], lat: point[1] };
|
|
168
174
|
onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace, isInZone: !!zone, isSameZone });
|
|
169
|
-
};
|
|
170
|
-
const updatePlaceCandidates =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
175
|
+
});
|
|
176
|
+
const updatePlaceCandidates = abortable(
|
|
177
|
+
async (place) => {
|
|
178
|
+
updateIntermediateQueryingState(place2point(place));
|
|
179
|
+
const {
|
|
180
|
+
places: placeCandidates,
|
|
181
|
+
zone,
|
|
182
|
+
available = false,
|
|
183
|
+
force = false
|
|
184
|
+
} = await getRecomendPlaceNoFail({ ...place }, context);
|
|
185
|
+
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
186
|
+
isQueryingRef.value = false;
|
|
187
|
+
availableRef.value = !!available;
|
|
188
|
+
forceRef.value = !!force;
|
|
189
|
+
zoneRef.value = zone;
|
|
190
|
+
placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
|
|
191
|
+
return {
|
|
192
|
+
inputPlace: { ...place },
|
|
193
|
+
isInZone: !!zone,
|
|
194
|
+
place: { ...place },
|
|
195
|
+
isSameZone
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
const updateRecommendPlace = abortable(async (place) => {
|
|
192
200
|
updateIntermediateQueryingState(place2point(place));
|
|
193
201
|
const {
|
|
194
202
|
place: resultPlace,
|
|
@@ -211,8 +219,8 @@ const useMapRecomendPlace = (props) => {
|
|
|
211
219
|
isInZone: !!zone,
|
|
212
220
|
isSameZone
|
|
213
221
|
});
|
|
214
|
-
};
|
|
215
|
-
const updateRecommendPlaceOnlyInZone = async (place) => {
|
|
222
|
+
});
|
|
223
|
+
const updateRecommendPlaceOnlyInZone = abortable(async (place) => {
|
|
216
224
|
var _a;
|
|
217
225
|
updateIntermediateQueryingState(place2point(place));
|
|
218
226
|
const {
|
|
@@ -237,7 +245,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
237
245
|
isInZone: !!zone,
|
|
238
246
|
isSameZone
|
|
239
247
|
});
|
|
240
|
-
};
|
|
248
|
+
});
|
|
241
249
|
const setPlaceCandidatesAndZone = ({ zone, places: placeCandidates }) => {
|
|
242
250
|
availableRef.value = true;
|
|
243
251
|
forceRef.value = !!zone;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import type { AnyFn } from "@vueuse/core";
|
|
2
|
+
import type { ConnectionStatus } from "../types/interface";
|
|
1
3
|
import type { Status, UseMapLoaderOutput, UseMapLoaderProps } from "./useMapLoader";
|
|
2
4
|
export interface MapSupplierPayolad extends UseMapLoaderProps {
|
|
3
5
|
gmapRasterId: string;
|
|
4
6
|
gmapId: string;
|
|
5
7
|
readyPromise: UseMapLoaderOutput["readyPromise"];
|
|
6
8
|
status: Status;
|
|
9
|
+
pingStatus: ConnectionStatus;
|
|
10
|
+
renderLoadFailedTitle?: (status: Status) => string | undefined;
|
|
11
|
+
renderLoadFailedDescription?: (status: Status) => string | undefined;
|
|
7
12
|
}
|
|
8
13
|
export declare const useMapSupplier: () => MapSupplierPayolad;
|
|
9
14
|
export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
|
|
15
|
+
export declare const useMapAssertSupplier: () => {
|
|
16
|
+
assertSupplier: <T extends AnyFn>(fn: T) => T;
|
|
17
|
+
};
|
|
@@ -7,7 +7,24 @@ const useMapSupplier = () => {
|
|
|
7
7
|
return payload;
|
|
8
8
|
};
|
|
9
9
|
const provideMapSupplier = (payload) => provide(context, payload);
|
|
10
|
+
const useMapAssertSupplier = () => {
|
|
11
|
+
const payload = useMapSupplier();
|
|
12
|
+
const instanceSupplier = payload.supplier;
|
|
13
|
+
function assertSupplier(fn) {
|
|
14
|
+
return function fnWithAssertSupplier(...args) {
|
|
15
|
+
console.log("instanceSupplier, payload.supplier = ", instanceSupplier, payload.supplier);
|
|
16
|
+
if (instanceSupplier === payload.supplier)
|
|
17
|
+
return fn(...args);
|
|
18
|
+
throw Error(
|
|
19
|
+
`MyError: expect instance supplier ${payload.supplier}, actual is ${instanceSupplier}
|
|
20
|
+
You probably call the api (exposed by useBusinessXXX) before the Element <BusinessXXX /> rendering!`
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return { assertSupplier };
|
|
25
|
+
};
|
|
10
26
|
export {
|
|
11
27
|
provideMapSupplier,
|
|
28
|
+
useMapAssertSupplier,
|
|
12
29
|
useMapSupplier
|
|
13
30
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PingConnectionOnChangeHandler } from "../api/pingConnection";
|
|
2
|
+
export interface UsePingConnectionProps {
|
|
3
|
+
onChange?: PingConnectionOnChangeHandler;
|
|
4
|
+
}
|
|
5
|
+
export declare const usePingAmapConnection: (props?: UsePingConnectionProps) => {
|
|
6
|
+
connectionStatus: Readonly<import("vue-demi").Ref<import("..").ConnectionStatus>>;
|
|
7
|
+
};
|
|
8
|
+
export declare const usePingGmapConnection: (props?: UsePingConnectionProps) => {
|
|
9
|
+
connectionStatus: Readonly<import("vue-demi").Ref<import("..").ConnectionStatus>>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ref, onUnmounted, readonly } from "vue-demi";
|
|
2
|
+
import { apiGetPingAmapStatus, apiSubscribePingAmapChange, apiGetPingGmapStatus, apiSubscribePingGmapChange } from "../api/pingConnection.js";
|
|
3
|
+
const usePingAmapConnection = (props) => {
|
|
4
|
+
const statusRef = ref(apiGetPingAmapStatus());
|
|
5
|
+
const unsubscribe = apiSubscribePingAmapChange((status) => {
|
|
6
|
+
var _a;
|
|
7
|
+
statusRef.value = status;
|
|
8
|
+
(_a = props == null ? void 0 : props.onChange) == null ? void 0 : _a.call(props, status);
|
|
9
|
+
});
|
|
10
|
+
onUnmounted(unsubscribe);
|
|
11
|
+
return { connectionStatus: readonly(statusRef) };
|
|
12
|
+
};
|
|
13
|
+
const usePingGmapConnection = (props) => {
|
|
14
|
+
const statusRef = ref(apiGetPingGmapStatus());
|
|
15
|
+
const unsubscribe = apiSubscribePingGmapChange((status) => {
|
|
16
|
+
var _a;
|
|
17
|
+
statusRef.value = status;
|
|
18
|
+
(_a = props == null ? void 0 : props.onChange) == null ? void 0 : _a.call(props, status);
|
|
19
|
+
});
|
|
20
|
+
onUnmounted(unsubscribe);
|
|
21
|
+
return { connectionStatus: readonly(statusRef) };
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
usePingAmapConnection,
|
|
25
|
+
usePingGmapConnection
|
|
26
|
+
};
|