@heycar/heycars-map 2.0.0-switchMap1 → 2.0.0-switchMap3

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.
Files changed (96) hide show
  1. package/README.md +43 -29
  2. package/dist/v2/App.js +5 -3
  3. package/dist/v2/Demo/DemoBusinessQuoting.js +3 -2
  4. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +1 -1
  5. package/dist/v2/api/cdn.d.ts +1 -0
  6. package/dist/v2/api/cdn.js +2 -0
  7. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  8. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -2
  9. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  10. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  11. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +2 -2
  12. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +18 -11
  13. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  14. package/dist/v2/chunks/{BusinessRecomendPlaceMap.5be4fdcf.js → BusinessRecomendPlaceMap.f589ebf7.js} +17 -10
  15. package/dist/v2/chunks/{Loading.fc6e75d0.js → Loading.da68a2a6.js} +31 -1
  16. package/dist/v2/chunks/throttle.8bdd8d3b.js +20 -0
  17. package/dist/v2/components/Loading/Loading.css.d.ts +5 -0
  18. package/dist/v2/components/Loading/Loading.d.ts +6 -0
  19. package/dist/v2/components/Loading/Loading.js +3 -1
  20. package/dist/v2/components/Loading/index.js +2 -1
  21. package/dist/v2/components/MapProvider/MapProvider.d.ts +2 -2
  22. package/dist/v2/components/MapProvider/MapProvider.js +16 -9
  23. package/dist/v2/css/Loading-0e058b68.css +51 -0
  24. package/dist/v2/hooks/useDeviceOrientation.js +1 -17
  25. package/dist/v2/hooks/useMapGCJ02.js +1 -3
  26. package/dist/v2/hooks/useMapGraspRoad.js +1 -2
  27. package/dist/v2/hooks/useMapInChina.d.ts +3 -15
  28. package/dist/v2/hooks/useMapInChina.js +11 -16
  29. package/dist/v2/hooks/useMapLoader.d.ts +10 -6
  30. package/dist/v2/hooks/useMapLoader.js +88 -59
  31. package/dist/v2/hooks/useMapPlace.d.ts +1 -0
  32. package/dist/v2/hooks/useMapPlace.js +10 -9
  33. package/dist/v2/hooks/useMapRecomendPlace.d.ts +1 -0
  34. package/dist/v2/hooks/useMapRecomendPlace.js +72 -64
  35. package/dist/v2/hooks/useMapSupplier.d.ts +6 -0
  36. package/dist/v2/hooks/useMapSupplier.js +17 -0
  37. package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +2 -0
  38. package/dist/v2/hooks-business/useBusinessQuotingMap.js +7 -2
  39. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  40. package/dist/v2/index.js +1 -1
  41. package/dist/v2/utils/ManualAbortError.d.ts +3 -0
  42. package/dist/v2/utils/ManualAbortError.js +14 -0
  43. package/dist/v2/utils/helper.d.ts +1 -0
  44. package/dist/v2/utils/helper.js +17 -0
  45. package/dist/v2/utils/log.js +1 -1
  46. package/dist/v2/utils/patchGoogleMapLoader.d.ts +2 -0
  47. package/dist/v2/utils/patchGoogleMapLoader.js +64 -0
  48. package/dist/v3/App.js +5 -3
  49. package/dist/v3/Demo/DemoBusinessQuoting.js +4 -3
  50. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
  51. package/dist/v3/api/cdn.d.ts +1 -0
  52. package/dist/v3/api/cdn.js +2 -0
  53. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  54. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -2
  55. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  56. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  57. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +2 -2
  58. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +18 -11
  59. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  60. package/dist/v3/chunks/{BusinessRecomendPlaceMap.39888296.js → BusinessRecomendPlaceMap.86e9c287.js} +17 -10
  61. package/dist/v3/chunks/{Loading.a8e2f26a.js → Loading.98d687c0.js} +27 -1
  62. package/dist/v3/chunks/throttle.8bdd8d3b.js +20 -0
  63. package/dist/v3/components/Loading/Loading.css.d.ts +5 -0
  64. package/dist/v3/components/Loading/Loading.d.ts +8 -0
  65. package/dist/v3/components/Loading/Loading.js +3 -1
  66. package/dist/v3/components/Loading/index.js +2 -1
  67. package/dist/v3/components/MapProvider/MapProvider.d.ts +6 -3
  68. package/dist/v3/components/MapProvider/MapProvider.js +14 -9
  69. package/dist/v3/css/Loading-0e058b68.css +51 -0
  70. package/dist/v3/hooks/useDeviceOrientation.js +1 -17
  71. package/dist/v3/hooks/useMapGCJ02.js +1 -3
  72. package/dist/v3/hooks/useMapGraspRoad.js +1 -2
  73. package/dist/v3/hooks/useMapInChina.d.ts +3 -15
  74. package/dist/v3/hooks/useMapInChina.js +11 -16
  75. package/dist/v3/hooks/useMapLoader.d.ts +10 -6
  76. package/dist/v3/hooks/useMapLoader.js +88 -59
  77. package/dist/v3/hooks/useMapPlace.d.ts +1 -0
  78. package/dist/v3/hooks/useMapPlace.js +10 -9
  79. package/dist/v3/hooks/useMapRecomendPlace.d.ts +1 -0
  80. package/dist/v3/hooks/useMapRecomendPlace.js +72 -64
  81. package/dist/v3/hooks/useMapSupplier.d.ts +6 -0
  82. package/dist/v3/hooks/useMapSupplier.js +17 -0
  83. package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +2 -0
  84. package/dist/v3/hooks-business/useBusinessQuotingMap.js +7 -2
  85. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  86. package/dist/v3/index.js +1 -1
  87. package/dist/v3/utils/ManualAbortError.d.ts +3 -0
  88. package/dist/v3/utils/ManualAbortError.js +14 -0
  89. package/dist/v3/utils/helper.d.ts +1 -0
  90. package/dist/v3/utils/helper.js +17 -0
  91. package/dist/v3/utils/log.js +1 -1
  92. package/dist/v3/utils/patchGoogleMapLoader.d.ts +2 -0
  93. package/dist/v3/utils/patchGoogleMapLoader.js +64 -0
  94. package/package.json +2 -2
  95. package/dist/v2/css/Loading-523061b9.css +0 -9
  96. package/dist/v3/css/Loading-523061b9.css +0 -9
@@ -1,6 +1,7 @@
1
1
  import { ref, reactive } from "vue-demi";
2
2
  import { GET_RECOMMEND_PLACE_TIMEOUT } from "../api/contants.js";
3
- import { equalAssign, isPlacesInclude } from "../utils/helper.js";
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
6
  import { useMapGeometry } from "./useMapGeometry.js";
6
7
  import { useMapPlace } from "./useMapPlace.js";
@@ -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((error) => console.error(error));
15
+ }).catch(logNoneManualAbortError);
15
16
  getRecomendPlace(place, context).then((result) => resolve(result != null ? result : { available })).catch((error) => {
16
- console.error(error);
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();
55
+ const abortable = createAbortable(signal);
53
56
  const { apiMapIsPointInRing, 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,38 +94,40 @@ 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 = async (point, prevState) => {
95
- const [lng, lat] = point;
96
- const zone = zoneRef.value;
97
- if (!zone || !apiMapIsPointInRing(point, zone.path)) {
98
- const reGeoPlacePromise = getPlaceByRegeo(point);
99
- const {
100
- place: closestPlace,
101
- candidates,
102
- available,
103
- force,
104
- zone: zone2
105
- } = await findAttachedPlace({ lng, lat, name: "", displayName: "" });
106
- if (isPlacesInclude(candidates, closestPlace)) {
107
- return { place: { ...closestPlace }, zone: zone2, available, candidates, force };
97
+ });
98
+ const getRecommendPlaceZoneState = abortable(
99
+ async (point, prevState) => {
100
+ const [lng, lat] = point;
101
+ const zone = zoneRef.value;
102
+ if (!zone || !apiMapIsPointInRing(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 regeoPlace = await reGeoPlacePromise;
110
- return { place: { ...regeoPlace }, zone: zone2, available, candidates, force };
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
- const { shortestPlace: resultPlace } = findNearestPlace(
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
133
  if (zone && apiMapIsPointInRing(point, zone.path))
@@ -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 = async (place) => {
171
- updateIntermediateQueryingState(place2point(place));
172
- const {
173
- places: placeCandidates,
174
- zone,
175
- available = false,
176
- force = false
177
- } = await getRecomendPlaceNoFail({ ...place }, context);
178
- const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
179
- isQueryingRef.value = false;
180
- availableRef.value = !!available;
181
- forceRef.value = !!force;
182
- zoneRef.value = zone;
183
- placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
184
- return {
185
- inputPlace: { ...place },
186
- isInZone: !!zone,
187
- place: { ...place },
188
- isSameZone
189
- };
190
- };
191
- const updateRecommendPlace = async (place) => {
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,15 @@
1
+ import type { AnyFn } from "@vueuse/core";
1
2
  import type { Status, UseMapLoaderOutput, UseMapLoaderProps } from "./useMapLoader";
2
3
  export interface MapSupplierPayolad extends UseMapLoaderProps {
3
4
  gmapRasterId: string;
4
5
  gmapId: string;
5
6
  readyPromise: UseMapLoaderOutput["readyPromise"];
6
7
  status: Status;
8
+ renderLoadFailedTitle?: (status: Status) => string | undefined;
9
+ renderLoadFailedDescription?: (status: Status) => string | undefined;
7
10
  }
8
11
  export declare const useMapSupplier: () => MapSupplierPayolad;
9
12
  export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
13
+ export declare const useMapAssertSupplier: () => {
14
+ assertSupplier: <T extends AnyFn>(fn: T) => T;
15
+ };
@@ -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
  };
@@ -1,7 +1,9 @@
1
+ import type { CoordinateType, Point } from "../types/interface";
1
2
  export type BusinessQuotingContext = {
2
3
  setFitView: () => void;
3
4
  };
4
5
  export declare const useBusinessQuotingMap: () => {
5
6
  setFitView: () => void;
6
7
  mapContext: BusinessQuotingContext;
8
+ toAmapCoordinateType: (point: Point) => CoordinateType;
7
9
  };
@@ -1,9 +1,14 @@
1
- import { proxyFunctionalProperty, assertAssingedBeforeUsed } from "../utils/helper.js";
1
+ import { inChina } from "../hooks/useMapInChina.js";
2
+ import { proxyFunctionalProperty, assertAssingedBeforeUsed, assertPoint } from "../utils/helper.js";
2
3
  const useBusinessQuotingMap = () => {
3
4
  const mapContext = {
4
5
  setFitView: assertAssingedBeforeUsed
5
6
  };
6
- return { mapContext, ...proxyFunctionalProperty(mapContext) };
7
+ const toAmapCoordinateType = (point) => {
8
+ assertPoint(point);
9
+ return inChina(point) ? "gcj02" : "wgs84";
10
+ };
11
+ return { mapContext, toAmapCoordinateType, ...proxyFunctionalProperty(mapContext) };
7
12
  };
8
13
  export {
9
14
  useBusinessQuotingMap
@@ -1,5 +1,5 @@
1
1
  import { reactive, ref, readonly } from "vue-demi";
2
- import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.5be4fdcf.js";
2
+ import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.f589ebf7.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.5be4fdcf.js";
5
+ import { B } from "./chunks/BusinessRecomendPlaceMap.f589ebf7.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";
@@ -0,0 +1,3 @@
1
+ export declare const MANUAL_ABORT_MESSAGE = "MANUAL_ABORT_MESSAGE";
2
+ export declare const throwNoneManualAbortError: (e: unknown) => void;
3
+ export declare const logNoneManualAbortError: (e: unknown) => void;
@@ -0,0 +1,14 @@
1
+ const MANUAL_ABORT_MESSAGE = "MANUAL_ABORT_MESSAGE";
2
+ const throwNoneManualAbortError = (e) => {
3
+ if (e !== MANUAL_ABORT_MESSAGE)
4
+ throw e;
5
+ };
6
+ const logNoneManualAbortError = (e) => {
7
+ if (e !== MANUAL_ABORT_MESSAGE)
8
+ console.error(e);
9
+ };
10
+ export {
11
+ MANUAL_ABORT_MESSAGE,
12
+ logNoneManualAbortError,
13
+ throwNoneManualAbortError
14
+ };
@@ -33,4 +33,5 @@ export declare const assertAssingedBeforeUsed: () => never;
33
33
  type PickFunctionalPropertyName<T, K extends keyof T = keyof T> = K extends any ? T[K] extends (...args: any) => any ? K : never : never;
34
34
  type PickFunctionalProperty<T> = Pick<T, PickFunctionalPropertyName<T>>;
35
35
  export declare const proxyFunctionalProperty: <T extends object>(target: T) => PickFunctionalProperty<T>;
36
+ export declare const createAbortable: (signal?: AbortSignal) => <F extends ((...args: any) => Promise<any>) | undefined>(fn: F) => F;
36
37
  export {};
@@ -147,12 +147,29 @@ const proxyFunctionalProperty = (target) => {
147
147
  }
148
148
  return result;
149
149
  };
150
+ const createAbortable = (signal) => {
151
+ return function abortable(fn) {
152
+ if (!fn || !signal)
153
+ return fn;
154
+ return function abrotableFn(...args) {
155
+ return new Promise((resolve, reject) => {
156
+ if (signal.aborted)
157
+ return reject(signal.reason);
158
+ signal.addEventListener("abort", () => reject(signal.reason));
159
+ fn(...args).then((result) => {
160
+ signal.aborted ? reject(signal.reason) : resolve(result);
161
+ }, reject);
162
+ });
163
+ };
164
+ };
165
+ };
150
166
  export {
151
167
  assertAngle,
152
168
  assertAssingedBeforeUsed,
153
169
  assertNotEmptyArray,
154
170
  assertPoint,
155
171
  assertZone,
172
+ createAbortable,
156
173
  createAsyncNoFailNonNullable,
157
174
  createReadOnce,
158
175
  createRunOnce,
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.0.0-switchMap1";
3
+ const pkgVersion = "2.0.0-switchMap3";
4
4
  const isEnableLog = (name) => {
5
5
  const searchParam = new URLSearchParams(location.search);
6
6
  return searchParam.has(`log-${name}`);
@@ -0,0 +1,2 @@
1
+ import { Loader } from "@googlemaps/js-api-loader";
2
+ export declare const patchGoogleMapLoader: (loader: Loader) => void;
@@ -0,0 +1,64 @@
1
+ const patchGoogleMapLoader = (loader) => {
2
+ loader.setScript = setScript;
3
+ };
4
+ function setScript() {
5
+ var _a, _b;
6
+ if (document.getElementById(this.id)) {
7
+ this.callback();
8
+ return;
9
+ }
10
+ const params = {
11
+ key: this.apiKey,
12
+ channel: this.channel,
13
+ client: this.client,
14
+ libraries: this.libraries.length && this.libraries,
15
+ v: this.version,
16
+ mapIds: this.mapIds,
17
+ language: this.language,
18
+ region: this.region,
19
+ authReferrerPolicy: this.authReferrerPolicy
20
+ };
21
+ Object.keys(params).forEach((key) => !params[key] && delete params[key]);
22
+ if (!((_b = (_a = window == null ? void 0 : window.google) == null ? void 0 : _a.maps) == null ? void 0 : _b.importLibrary)) {
23
+ ((g) => {
24
+ let h, a, k, p = "The Google Maps JavaScript API", c = "google", l = "importLibrary", q = "__ib__", m = document, b = window;
25
+ b = b[c] || (b[c] = {});
26
+ const d = b.maps || (b.maps = {}), r = /* @__PURE__ */ new Set(), e = new URLSearchParams(), u = () => (
27
+ // @ts-ignore
28
+ h || (h = new Promise(async (f, n) => {
29
+ var _a2;
30
+ await (a = m.createElement("script"));
31
+ a.id = this.id;
32
+ e.set("libraries", [...r] + "");
33
+ for (k in g)
34
+ e.set(
35
+ k.replace(/[A-Z]/g, (t) => "_" + t[0].toLowerCase()),
36
+ g[k]
37
+ );
38
+ e.set("callback", c + ".maps." + q);
39
+ e.set("t", Date.now().toString());
40
+ a.src = this.url + `?` + e;
41
+ d[q] = f;
42
+ a.onerror = () => h = n(Error(p + " could not load."));
43
+ a.nonce = this.nonce || ((_a2 = m.querySelector("script[nonce]")) == null ? void 0 : _a2.nonce) || "";
44
+ m.head.append(a);
45
+ }))
46
+ );
47
+ d[l] ? console.warn(p + " only loads once. Ignoring:", g) : d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n));
48
+ })(params);
49
+ }
50
+ const libraryPromises = this.libraries.map((library) => this.importLibrary(library));
51
+ if (!libraryPromises.length) {
52
+ libraryPromises.push(this.importLibrary("core"));
53
+ }
54
+ Promise.all(libraryPromises).then(
55
+ () => this.callback(),
56
+ (error) => {
57
+ const event = new ErrorEvent("error", { error });
58
+ this.loadErrorCallback(event);
59
+ }
60
+ );
61
+ }
62
+ export {
63
+ patchGoogleMapLoader
64
+ };
package/dist/v3/App.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createVNode } from "vue";
2
2
  import { defineComponent, ref } from "vue-demi";
3
- import { DemoBusinessTaxiService } from "./Demo/DemoBusinessTaxiService.js";
3
+ import { DemoBusinessQuoting } from "./Demo/DemoBusinessQuoting.js";
4
4
  import { MapProvider } from "./components/MapProvider/MapProvider.js";
5
5
  const gmapApiKey = "AIzaSyCRtkaNSWMOhOXDOUpJK4OVbm5RIstYj-I";
6
6
  const gmapId = "d0af0c05331af64a";
@@ -18,9 +18,11 @@ const App = /* @__PURE__ */ defineComponent({
18
18
  "gmapRasterId": gmapRasterId,
19
19
  "gmapKey": gmapApiKey,
20
20
  "language": "en",
21
- "supplier": supplierRef.value
21
+ "supplier": supplierRef.value,
22
+ "renderLoadFailedTitle": () => supplierRef.value === "gmap" ? "未能成功访问谷歌地图" : "高德地图加载失败",
23
+ "renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0
22
24
  }, {
23
- default: () => [createVNode(DemoBusinessTaxiService, null, null)]
25
+ default: () => [createVNode(DemoBusinessQuoting, null, null)]
24
26
  });
25
27
  }
26
28
  });
@@ -1,11 +1,12 @@
1
- import { createVNode } from "vue";
1
+ import { createVNode, createTextVNode } from "vue";
2
2
  import { BusinessQuotingMap } from "../business-components/BusinessQuotingMap/BusinessQuotingMap.js";
3
3
  import { useBusinessQuotingMap } from "../hooks-business/useBusinessQuotingMap.js";
4
4
  import { defineSetup } from "../types/helper.js";
5
5
  import { d as demo } from "../chunks/Demo.css.e921a2f6.js";
6
6
  const DemoBusinessQuoting = defineSetup("DemoBusinessQuoting", function() {
7
7
  const {
8
- mapContext
8
+ mapContext,
9
+ toAmapCoordinateType
9
10
  } = useBusinessQuotingMap();
10
11
  return () => createVNode("div", null, [createVNode(BusinessQuotingMap, {
11
12
  "class": demo,
@@ -32,7 +33,7 @@ const DemoBusinessQuoting = defineSetup("DemoBusinessQuoting", function() {
32
33
  "mapContext": mapContext,
33
34
  "onClickStartPoint": (place) => console.log("点击起点时触发 palce = ", place),
34
35
  "onClickEndPoint": (place) => console.log("点击终点时触发 palce = ", place)
35
- }, null)]);
36
+ }, null), createVNode("div", null, [createTextVNode("经度 103.841974, 纬度 1.311295 在高德地图上的坐标类型是:"), toAmapCoordinateType([103.841974, 1.311295])])]);
36
37
  });
37
38
  export {
38
39
  DemoBusinessQuoting
@@ -1,5 +1,5 @@
1
1
  import { createVNode } from "vue";
2
- import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.39888296.js";
2
+ import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.86e9c287.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";
@@ -5,3 +5,4 @@ export declare const ICON_END_POINT_EN_URL = "https://overseas-oss.heycars.cn/he
5
5
  export declare const ICON_END_POINT_ZH_TW_URL = "https://overseas-oss.heycars.cn/heycar-map/svg/end-point-zh-TW.svg";
6
6
  export declare const ICON_TAXI_CAR_URL = "https://overseas-oss.heycars.cn/heycar-map/svg/taxi-car.svg";
7
7
  export declare const ICON_DOT_LOADING_URL = "https://overseas-oss.heycars.cn/heycar-map/gif/dot-loading.gif";
8
+ export declare const ICON_LOAD_FAILED_URL = "https://overseas-oss.heycars.cn/heycar-map/svg/load-failed.svg";
@@ -5,12 +5,14 @@ const ICON_END_POINT_EN_URL = "https://overseas-oss.heycars.cn/heycar-map/svg/en
5
5
  const ICON_END_POINT_ZH_TW_URL = "https://overseas-oss.heycars.cn/heycar-map/svg/end-point-zh-TW.svg";
6
6
  const ICON_TAXI_CAR_URL = "https://overseas-oss.heycars.cn/heycar-map/svg/taxi-car.svg";
7
7
  const ICON_DOT_LOADING_URL = "https://overseas-oss.heycars.cn/heycar-map/gif/dot-loading.gif";
8
+ const ICON_LOAD_FAILED_URL = "https://overseas-oss.heycars.cn/heycar-map/svg/load-failed.svg";
8
9
  export {
9
10
  AMAP_DEFAULT_MARKER_ICON_URL,
10
11
  ICON_DOT_LOADING_URL,
11
12
  ICON_END_POINT_EN_URL,
12
13
  ICON_END_POINT_ZH_TW_URL,
13
14
  ICON_FULL_SCREEN_URL,
15
+ ICON_LOAD_FAILED_URL,
14
16
  ICON_START_POINT_EN_URL,
15
17
  ICON_TAXI_CAR_URL
16
18
  };
@@ -4,7 +4,7 @@ import { createElement } from "../../demi-polyfill/demi-polyfill.js";
4
4
  import { useHeycarMap } from "../../hooks/useHeycarMap.js";
5
5
  import { useMapCoordinatify } from "../../hooks/useMapCoordinatify.js";
6
6
  import { useMapFitView } from "../../hooks/useMapFitView.js";
7
- import { useMapSupplier } from "../../hooks/useMapSupplier.js";
7
+ import { useMapSupplier, useMapAssertSupplier } from "../../hooks/useMapSupplier.js";
8
8
  import { defineSetup, defineLagecySetup } from "../../types/helper.js";
9
9
  import { generateCreateElementV2PropsOn } from "../../utils/compare.js";
10
10
  import { place2point, pipeDefer } from "../../utils/transform.js";
@@ -25,6 +25,9 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
25
25
  const {
26
26
  language
27
27
  } = useMapSupplier();
28
+ const {
29
+ assertSupplier
30
+ } = useMapAssertSupplier();
28
31
  const {
29
32
  mapRef,
30
33
  setMap
@@ -40,7 +43,7 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
40
43
  mapRef,
41
44
  padding: BUSINESS_QUOTING_FITVIEW_PANDING
42
45
  });
43
- mapContext.setFitView = () => setFitView(false);
46
+ mapContext.setFitView = assertSupplier(() => setFitView(false));
44
47
  const fittableRegistryOverlay = createFittableRegisterOverlay({
45
48
  registerOverlay,
46
49
  immediate: true
@@ -45,7 +45,7 @@ export interface BusinessRecomendPlaceMapProps extends CoordinatifyProps<Omit<He
45
45
  onClickLocatorText?: AbsoluteAddressBoxProps["onClickText"];
46
46
  onClickLocatorPhoto?: AbsoluteAddressBoxProps["onClickPhoto"];
47
47
  }
48
- export declare const BusinessRecomendPlaceMapInner: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessRecomendPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessRecomendPlaceMapProps, Required<BusinessRecomendPlaceMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "geoError" | "changePlace" | "loadGeoLocation" | "loadDefaultGeoLocation" | "changeByDrag" | "changeGeoLocation" | "changeRecomandPlace" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessRecomendPlaceMapProps, BusinessRecomendPlaceMapProps, import("vue-demi").SlotsType<{
48
+ export declare const BusinessRecomendPlaceMapInner: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessRecomendPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessRecomendPlaceMapProps, Required<BusinessRecomendPlaceMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "changePlace" | "loadGeoLocation" | "loadDefaultGeoLocation" | "changeByDrag" | "changeGeoLocation" | "changeRecomandPlace" | "geoError" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessRecomendPlaceMapProps, BusinessRecomendPlaceMapProps, import("vue-demi").SlotsType<{
49
49
  renderPlacePhoto?: ((place: CoordinatePlace) => string | undefined) | undefined;
50
50
  renderPlaceTag?: PickupPointsProps["renderPlaceTag"];
51
51
  fallback?: (() => import("vue-demi").VNodeChild) | undefined;
@@ -54,7 +54,7 @@ export declare const BusinessRecomendPlaceMapInner: import("vue-demi").DefineCom
54
54
  } & {
55
55
  default?: import("../../demi-polyfill").Slot | undefined;
56
56
  }>>;
57
- export declare const BusinessRecomendPlaceMap: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessRecomendPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessRecomendPlaceMapProps, Required<BusinessRecomendPlaceMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "geoError" | "changePlace" | "loadGeoLocation" | "loadDefaultGeoLocation" | "changeByDrag" | "changeGeoLocation" | "changeRecomandPlace" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessRecomendPlaceMapProps, BusinessRecomendPlaceMapProps, import("vue-demi").SlotsType<{
57
+ export declare const BusinessRecomendPlaceMap: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessRecomendPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessRecomendPlaceMapProps, Required<BusinessRecomendPlaceMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "changePlace" | "loadGeoLocation" | "loadDefaultGeoLocation" | "changeByDrag" | "changeGeoLocation" | "changeRecomandPlace" | "geoError" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessRecomendPlaceMapProps, BusinessRecomendPlaceMapProps, import("vue-demi").SlotsType<{
58
58
  renderPlacePhoto?: ((place: CoordinatePlace) => string | undefined) | undefined;
59
59
  renderPlaceTag?: PickupPointsProps["renderPlaceTag"];
60
60
  fallback?: (() => import("vue-demi").VNodeChild) | undefined;
@@ -14,6 +14,7 @@ import "../../hooks/useMapSupplier.js";
14
14
  import "../../hooks/useMapZoom.js";
15
15
  import "../../types/helper.js";
16
16
  import "../../types/interface.js";
17
+ import "../../utils/ManualAbortError.js";
17
18
  import "../../utils/compare.js";
18
19
  import "../../utils/helper.js";
19
20
  import "../../utils/platform.js";
@@ -25,7 +26,7 @@ import "../GreenZone/GreenZone.js";
25
26
  import "../PassengerCircle/PassengerCircle.js";
26
27
  import "../PickupPoints/PickupPoints.js";
27
28
  import "./useCacheCenterPlace.js";
28
- import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.39888296.js";
29
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.86e9c287.js";
29
30
  export {
30
31
  B as BusinessRecomendPlaceMap,
31
32
  f as BusinessRecomendPlaceMapInner,
@@ -1,4 +1,4 @@
1
- import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.39888296.js";
1
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.86e9c287.js";
2
2
  export {
3
3
  B as BusinessRecomendPlaceMap,
4
4
  f as BusinessRecomendPlaceMapInner,
@@ -3,7 +3,7 @@ import { type BusinessRecomendPlaceMapProps } from "../BusinessRecomendPlaceMap"
3
3
  export interface BusinessReselectPlaceMapProps extends Pick<BusinessRecomendPlaceMapProps, "geoErrorOnceNotificationKey" | "loading" | "fallback" | "log" | "getAvailable" | "getRecomendPlace" | "unavailableTitle" | "emptyTitle" | "queryingTitle" | "recomendDescription" | "disableLocator" | "disableLocatorPhoto" | "mapContext" | "renderPlacePhoto" | "renderPlaceTag" | "onChangeGeoLocation" | "onChangePlace" | "onChangeRecomandPlace" | "onGeoError" | "onGeoErrorOnce" | "onClickLocatorText" | "onClickLocatorPhoto"> {
4
4
  defaultPlace?: CoordinatePlace;
5
5
  }
6
- export declare const BusinessReselectPlaceMapInner: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessReselectPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessReselectPlaceMapProps, Required<BusinessReselectPlaceMapProps>>, "geoError" | "changePlace" | "changeGeoLocation" | "changeRecomandPlace" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessReselectPlaceMapProps, BusinessReselectPlaceMapProps, import("vue-demi").SlotsType<{
6
+ export declare const BusinessReselectPlaceMapInner: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessReselectPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessReselectPlaceMapProps, Required<BusinessReselectPlaceMapProps>>, "changePlace" | "changeGeoLocation" | "changeRecomandPlace" | "geoError" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessReselectPlaceMapProps, BusinessReselectPlaceMapProps, import("vue-demi").SlotsType<{
7
7
  fallback?: (() => import("vue-demi").VNodeChild) | undefined;
8
8
  loading?: (() => import("vue-demi").VNodeChild) | undefined;
9
9
  renderPlaceTag?: ((place: Place) => string | undefined) | undefined;
@@ -11,7 +11,7 @@ export declare const BusinessReselectPlaceMapInner: import("vue-demi").DefineCom
11
11
  } & {
12
12
  default?: import("../../demi-polyfill").Slot | undefined;
13
13
  }>>;
14
- export declare const BusinessReselectPlaceMap: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessReselectPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessReselectPlaceMapProps, Required<BusinessReselectPlaceMapProps>>, "geoError" | "changePlace" | "changeGeoLocation" | "changeRecomandPlace" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessReselectPlaceMapProps, BusinessReselectPlaceMapProps, import("vue-demi").SlotsType<{
14
+ export declare const BusinessReselectPlaceMap: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessReselectPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessReselectPlaceMapProps, Required<BusinessReselectPlaceMapProps>>, "changePlace" | "changeGeoLocation" | "changeRecomandPlace" | "geoError" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessReselectPlaceMapProps, BusinessReselectPlaceMapProps, import("vue-demi").SlotsType<{
15
15
  fallback?: (() => import("vue-demi").VNodeChild) | undefined;
16
16
  loading?: (() => import("vue-demi").VNodeChild) | undefined;
17
17
  renderPlaceTag?: ((place: Place) => string | undefined) | undefined;