@heycar/heycars-map 2.4.5 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +25 -9
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/v2/App.js +2 -4
  5. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +11 -6
  6. package/dist/v2/Demo/DemoBusinessReselectPlace.js +10 -5
  7. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
  8. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  9. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  10. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +1 -1
  11. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +17 -10
  12. package/dist/v2/business-components/GreenZone/GreenZone.d.ts +1 -0
  13. package/dist/v2/business-components/GreenZone/GreenZone.js +7 -5
  14. package/dist/v2/chunks/{BusinessRecomendPlaceMap.81a4b640.js → BusinessRecomendPlaceMap.d8f5b904.js} +18 -9
  15. package/dist/v2/components/MapProvider/MapProvider.js +13 -14
  16. package/dist/v2/hooks/useMapCoordinatify.js +6 -4
  17. package/dist/v2/hooks/useMapGestureZoomCenter.js +0 -4
  18. package/dist/v2/hooks/useMapRecomendPlace.d.ts +3 -3
  19. package/dist/v2/hooks/useMapRecomendPlace.js +50 -40
  20. package/dist/v2/hooks/useMapSupplier.d.ts +1 -1
  21. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  22. package/dist/v2/index.js +1 -1
  23. package/dist/v2/types/gmap.d.ts +10 -0
  24. package/dist/v2/types/interface.d.ts +6 -3
  25. package/dist/v2/utils/log.js +1 -1
  26. package/dist/v2/utils/transform.js +1 -1
  27. package/dist/v2/utils/typeChecking.d.ts +5 -2
  28. package/dist/v2/utils/typeChecking.js +32 -4
  29. package/dist/v3/App.js +2 -4
  30. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +11 -6
  31. package/dist/v3/Demo/DemoBusinessReselectPlace.js +10 -5
  32. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
  33. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  34. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  35. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +1 -1
  36. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +17 -10
  37. package/dist/v3/business-components/GreenZone/GreenZone.d.ts +1 -0
  38. package/dist/v3/business-components/GreenZone/GreenZone.js +7 -5
  39. package/dist/v3/chunks/{BusinessRecomendPlaceMap.7133beea.js → BusinessRecomendPlaceMap.4c38b1fb.js} +18 -9
  40. package/dist/v3/components/MapProvider/MapProvider.js +13 -14
  41. package/dist/v3/hooks/useMapCoordinatify.js +6 -4
  42. package/dist/v3/hooks/useMapGestureZoomCenter.js +0 -4
  43. package/dist/v3/hooks/useMapRecomendPlace.d.ts +3 -3
  44. package/dist/v3/hooks/useMapRecomendPlace.js +50 -40
  45. package/dist/v3/hooks/useMapSupplier.d.ts +1 -1
  46. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  47. package/dist/v3/index.js +1 -1
  48. package/dist/v3/types/gmap.d.ts +10 -0
  49. package/dist/v3/types/interface.d.ts +6 -3
  50. package/dist/v3/utils/log.js +1 -1
  51. package/dist/v3/utils/transform.js +1 -1
  52. package/dist/v3/utils/typeChecking.d.ts +5 -2
  53. package/dist/v3/utils/typeChecking.js +32 -4
  54. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import type { Place, Point, RecommendZonePlaces, ValueOfOnChangeRecommendPlace, Zone } from "../types/interface";
1
+ import type { Place, Point, RecommendType, RecommendZonePlaces, ValueOfOnChangeRecommendPlace, Zone } from "../types/interface";
2
2
  import { type AbortSignalOption } from "../utils/helper";
3
3
  import { type UseMapPlaceProps } from "./useMapPlace";
4
4
  export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
@@ -29,12 +29,12 @@ export declare const useMapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C>
29
29
  displayName: string;
30
30
  }[]>;
31
31
  availableRef: import("vue-demi").Ref<boolean>;
32
- forceRef: import("vue-demi").Ref<boolean>;
32
+ recommendTypeRef: import("vue-demi").Ref<RecommendType>;
33
33
  isQueryingRef: import("vue-demi").Ref<boolean>;
34
34
  updateRecommendPlace: (place: Place, opt?: AbortSignalOption) => Promise<void>;
35
35
  updateRecommendPlaceOnlyInZone: (place: Place, opt?: AbortSignalOption) => Promise<void>;
36
36
  updatePlaceCandidates: (place: Place, opt?: AbortSignalOption) => Promise<ValueOfOnChangeRecommendPlace>;
37
37
  updatePlace: (point: Point) => Promise<void>;
38
38
  abortUpdatePlace: () => void;
39
- setPlaceCandidatesAndZone: ({ zone, places: placeCandidates }: RecommendZonePlaces) => void;
39
+ setPlaceCandidatesAndZone: ({ type, zone, places: placeCandidates, }: RecommendZonePlaces) => void;
40
40
  };
@@ -3,8 +3,10 @@ import { GET_RECOMMEND_PLACE_TIMEOUT } from "../api/contants.js";
3
3
  import { logNoneManualAbortError } from "../utils/ManualAbortError.js";
4
4
  import { createAbortableOneConcurrent, AbortSignalAny, equalAssign, isPlacesInclude, createAbortable } from "../utils/helper.js";
5
5
  import { isZoneEqual, place2point, isPlaceEqual, businessCandidatesToAdsorptionPlace } from "../utils/transform.js";
6
+ import { assertNoConflictTypeAndZone } from "../utils/typeChecking.js";
6
7
  import { useMapGeometry, apiLocalIsPointInRing } from "./useMapGeometry.js";
7
8
  import { useMapPlace } from "./useMapPlace.js";
9
+ const DEFAULT_RECOMMEND_TYPE = "Recommend";
8
10
  function mergeGetRecommendPlaceAndGetAvailable(getRecomendPlace, getAvailable, timeout) {
9
11
  return function mergedGetRecommendPlace(place, context) {
10
12
  const available = true;
@@ -49,7 +51,7 @@ const useMapRecomendPlace = (props) => {
49
51
  onChangePlace
50
52
  } = props;
51
53
  const availableRef = ref(true);
52
- const forceRef = ref(false);
54
+ const recommendTypeRef = ref(DEFAULT_RECOMMEND_TYPE);
53
55
  const placeCandidatesRef = ref([]);
54
56
  const zoneRef = ref();
55
57
  const abortable = createAbortable(inputSignal);
@@ -77,16 +79,16 @@ const useMapRecomendPlace = (props) => {
77
79
  places: placeCandidates,
78
80
  zone,
79
81
  available = false,
80
- force = false,
82
+ type = DEFAULT_RECOMMEND_TYPE,
81
83
  adsorption = false
82
84
  } = await getRecomendPlaceNoFail({ ...place }, context);
83
85
  (_a = opt == null ? void 0 : opt.signal) == null ? void 0 : _a.throwIfAborted();
84
- if (!available || !placeCandidates) {
85
- return { place: { ...place }, zone, candidates: [], available, force };
86
+ if (!available || !placeCandidates || placeCandidates.length === 0) {
87
+ return { place: { ...place }, zone, candidates: [], available, type };
86
88
  }
87
89
  if (!zone) {
88
90
  const resultPlace2 = adsorption ? businessCandidatesToAdsorptionPlace(placeCandidates) : place;
89
- return { place: { ...resultPlace2 }, zone, candidates: placeCandidates, available, force };
91
+ return { place: { ...resultPlace2 }, zone, candidates: placeCandidates, available, type };
90
92
  }
91
93
  const { shortestPlace, shortestDistance } = findNearestPlace(
92
94
  place,
@@ -95,42 +97,41 @@ const useMapRecomendPlace = (props) => {
95
97
  );
96
98
  const limit = getLimit(context);
97
99
  const resultPlace = zone || shortestDistance <= limit ? shortestPlace : place;
98
- return { place: { ...resultPlace }, zone, candidates: placeCandidates, available, force };
100
+ return { place: { ...resultPlace }, zone, candidates: placeCandidates, available, type };
99
101
  };
100
102
  const getRecommendPlaceZoneState = async (point, prevState, opt) => {
101
103
  const [lng, lat] = point;
102
- const zone = zoneRef.value;
104
+ const { type, zone, available, candidates } = prevState;
103
105
  if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
104
106
  const reGeoPlacePromise = getPlaceByRegeo(point, opt);
105
107
  const {
106
108
  place: closestPlace,
107
- candidates,
108
- available,
109
- force,
109
+ candidates: candidates2,
110
+ available: available2,
111
+ type: type2,
110
112
  zone: zone2
111
113
  } = await findAttachedPlace({ lng, lat, name: "", displayName: "" }, opt);
112
- if (isPlacesInclude(candidates, closestPlace)) {
113
- return { place: { ...closestPlace }, zone: zone2, available, candidates, force };
114
+ if (isPlacesInclude(candidates2, closestPlace)) {
115
+ return { place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
114
116
  }
115
117
  const regeoPlace = await reGeoPlacePromise;
116
- return { place: { ...regeoPlace }, zone: zone2, available, candidates, force };
118
+ return { place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
119
+ }
120
+ if (type === "Forbidden") {
121
+ const regeoPlace = await getPlaceByRegeo(point, opt);
122
+ return { place: { ...regeoPlace }, zone, available, candidates, type };
117
123
  }
118
124
  const { shortestPlace: resultPlace } = findNearestPlace(
119
125
  { lng, lat, name: "", displayName: "" },
120
- prevState.candidates,
126
+ candidates,
121
127
  apiMapDistance
122
128
  );
123
- return {
124
- place: { ...resultPlace },
125
- zone,
126
- available: prevState.available,
127
- force: prevState.force,
128
- candidates: prevState.candidates
129
- };
129
+ return { place: { ...resultPlace }, zone, type, available, candidates };
130
130
  };
131
131
  const updateIntermediateQueryingState = (point) => {
132
+ const type = recommendTypeRef.value;
132
133
  const zone = zoneRef.value;
133
- if (zone && apiLocalIsPointInRing(point, zone.path))
134
+ if (type === "Restricted" && zone && apiLocalIsPointInRing(point, zone.path))
134
135
  return;
135
136
  const [lng, lat] = point;
136
137
  const intermediateQueryingPlace = {
@@ -141,8 +142,10 @@ const useMapRecomendPlace = (props) => {
141
142
  };
142
143
  isQueryingRef.value = true;
143
144
  availableRef.value = true;
144
- if (zone)
145
+ if (type === "Restricted" || type === "Forbidden" && (!zone || !apiLocalIsPointInRing(point, zone.path))) {
145
146
  zoneRef.value = void 0;
147
+ recommendTypeRef.value = "Recommend";
148
+ }
146
149
  placeCandidatesRef.value = [];
147
150
  equalAssign(recomendPlace, { ...intermediateQueryingPlace });
148
151
  onQueryingPlace == null ? void 0 : onQueryingPlace({ ...intermediateQueryingPlace });
@@ -156,13 +159,13 @@ const useMapRecomendPlace = (props) => {
156
159
  candidates,
157
160
  zone,
158
161
  available,
159
- force
162
+ type
160
163
  } = await getRecommendPlaceZoneState(
161
164
  point,
162
165
  {
163
166
  place: recomendPlace,
164
167
  available: availableRef.value,
165
- force: forceRef.value,
168
+ type: recommendTypeRef.value,
166
169
  candidates: placeCandidatesRef.value,
167
170
  zone: zoneRef.value
168
171
  },
@@ -171,13 +174,13 @@ const useMapRecomendPlace = (props) => {
171
174
  const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
172
175
  isQueryingRef.value = false;
173
176
  availableRef.value = available;
174
- forceRef.value = force;
177
+ recommendTypeRef.value = type;
175
178
  zoneRef.value = zone;
176
179
  placeCandidatesRef.value = candidates;
177
180
  equalAssign(recomendPlace, { ...resultPlace });
178
181
  onChangePlace == null ? void 0 : onChangePlace({ ...resultPlace });
179
182
  const inputPlace = { name: "", displayName: "", lng: point[0], lat: point[1] };
180
- onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace, isInZone: !!zone, isSameZone });
183
+ onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace, type, zone, isSameZone });
181
184
  },
182
185
  { silent: true }
183
186
  );
@@ -188,19 +191,19 @@ const useMapRecomendPlace = (props) => {
188
191
  places: placeCandidates,
189
192
  zone,
190
193
  available = false,
191
- force = false
194
+ type = DEFAULT_RECOMMEND_TYPE
192
195
  } = await getRecomendPlaceNoFail({ ...place }, context);
193
196
  signal.throwIfAborted();
194
197
  const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
195
198
  isQueryingRef.value = false;
196
199
  availableRef.value = !!available;
197
- forceRef.value = !!force;
200
+ recommendTypeRef.value = type;
198
201
  zoneRef.value = zone;
199
202
  placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
200
203
  return {
201
204
  inputPlace: { ...place },
202
- isInZone: !!zone,
203
205
  place: { ...place },
206
+ type,
204
207
  isSameZone
205
208
  };
206
209
  };
@@ -210,13 +213,13 @@ const useMapRecomendPlace = (props) => {
210
213
  place: resultPlace,
211
214
  candidates,
212
215
  available,
213
- force,
216
+ type,
214
217
  zone
215
218
  } = await findAttachedPlace(place, opt);
216
219
  const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
217
220
  isQueryingRef.value = false;
218
221
  availableRef.value = available;
219
- forceRef.value = force;
222
+ recommendTypeRef.value = type;
220
223
  zoneRef.value = zone;
221
224
  placeCandidatesRef.value = candidates;
222
225
  equalAssign(recomendPlace, { ...resultPlace });
@@ -224,7 +227,8 @@ const useMapRecomendPlace = (props) => {
224
227
  onChange == null ? void 0 : onChange({
225
228
  place: { ...resultPlace },
226
229
  inputPlace: { ...place },
227
- isInZone: !!zone,
230
+ type,
231
+ zone,
228
232
  isSameZone
229
233
  });
230
234
  };
@@ -235,14 +239,14 @@ const useMapRecomendPlace = (props) => {
235
239
  place: foundPlace,
236
240
  candidates,
237
241
  available,
238
- force,
242
+ type,
239
243
  zone
240
244
  } = await findAttachedPlace(place, opt);
241
- const resultPlace = zone ? foundPlace : (_a = candidates.find((p) => isPlaceEqual(p, place))) != null ? _a : place;
245
+ const resultPlace = type === "Restricted" ? foundPlace : (_a = candidates.find((p) => isPlaceEqual(p, place))) != null ? _a : place;
242
246
  const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
243
247
  isQueryingRef.value = false;
244
248
  availableRef.value = available;
245
- forceRef.value = force;
249
+ recommendTypeRef.value = type;
246
250
  zoneRef.value = zone;
247
251
  placeCandidatesRef.value = candidates;
248
252
  equalAssign(recomendPlace, { ...resultPlace });
@@ -250,13 +254,19 @@ const useMapRecomendPlace = (props) => {
250
254
  onChange == null ? void 0 : onChange({
251
255
  place: { ...resultPlace },
252
256
  inputPlace: { ...place },
253
- isInZone: !!zone,
257
+ type,
258
+ zone,
254
259
  isSameZone
255
260
  });
256
261
  };
257
- const setPlaceCandidatesAndZone = ({ zone, places: placeCandidates }) => {
262
+ const setPlaceCandidatesAndZone = ({
263
+ type = DEFAULT_RECOMMEND_TYPE,
264
+ zone,
265
+ places: placeCandidates
266
+ }) => {
267
+ assertNoConflictTypeAndZone(type, zone);
258
268
  availableRef.value = true;
259
- forceRef.value = !!zone;
269
+ recommendTypeRef.value = type;
260
270
  zoneRef.value = zone ? zone : void 0;
261
271
  placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
262
272
  };
@@ -265,7 +275,7 @@ const useMapRecomendPlace = (props) => {
265
275
  recomendPlace,
266
276
  placeCandidates: placeCandidatesRef,
267
277
  availableRef,
268
- forceRef,
278
+ recommendTypeRef,
269
279
  isQueryingRef,
270
280
  updateRecommendPlace,
271
281
  updateRecommendPlaceOnlyInZone,
@@ -2,7 +2,7 @@ import type { AnyFn } from "@vueuse/core";
2
2
  import type { ConnectionStatus } from "../types/interface";
3
3
  import type { Status, UseMapLoaderOutput, UseMapLoaderProps } from "./useMapLoader";
4
4
  export interface MapSupplierPayolad extends UseMapLoaderProps {
5
- gmapRasterId: string;
5
+ gmapRasterId?: string;
6
6
  gmapId: string;
7
7
  readyPromise: UseMapLoaderOutput["readyPromise"];
8
8
  status: Status;
@@ -1,5 +1,5 @@
1
1
  import { reactive, ref, readonly } from "vue-demi";
2
- import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.81a4b640.js";
2
+ import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.d8f5b904.js";
3
3
  import { CenterPlaceStatus } from "../types/interface.js";
4
4
  import { proxyFunctionalProperty, assertAssingedBeforeUsed } from "../utils/helper.js";
5
5
  const useBusinessRecomendPlaceMap = () => {
package/dist/v2/index.js CHANGED
@@ -3,7 +3,7 @@ import { isCoordinatePointEqual } from "./api/geometry.js";
3
3
  import { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
4
4
  import { AddressBox } from "./business-components/AddressBox/AddressBox.js";
5
5
  import { BusinessQuotingMap } from "./business-components/BusinessQuotingMap/BusinessQuotingMap.js";
6
- import { B } from "./chunks/BusinessRecomendPlaceMap.81a4b640.js";
6
+ import { B } from "./chunks/BusinessRecomendPlaceMap.d8f5b904.js";
7
7
  import { BusinessReselectPlaceMap } from "./business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js";
8
8
  import { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js";
9
9
  import { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js";
@@ -1 +1,11 @@
1
+ /// <reference types="google.maps" />
2
+ declare global {
3
+ namespace google.maps {
4
+ interface MapOptions {
5
+ headingInteractionEnabled?: boolean;
6
+ tiltInteractionEnabled?: boolean;
7
+ renderingType?: RenderingType;
8
+ }
9
+ }
10
+ }
1
11
  export type GmapGeocoderAddressComponentType = "street_number" | "street_address" | "route" | "intersection" | "political" | "country" | "administrative_area_level_1" | "administrative_area_level_2" | "administrative_area_level_3" | "administrative_area_level_4" | "administrative_area_level_5" | "administrative_area_level_6" | "administrative_area_level_7" | "colloquial_area" | "locality" | "sublocality" | "neighborhood" | "premise" | "subpremise" | "plus_code" | "postal_code" | "natural_feature" | "airport" | "park" | "point_of_interest";
@@ -33,7 +33,7 @@ export interface CoordinateZone extends Omit<Zone, "path"> {
33
33
  }
34
34
  export interface RecommendZonePlaces {
35
35
  adsorption?: boolean;
36
- force?: boolean;
36
+ type?: RecommendType;
37
37
  available?: boolean;
38
38
  zone?: Zone;
39
39
  places?: Place[];
@@ -43,14 +43,16 @@ export interface CoordinateRecommendZonePlaces extends Omit<RecommendZonePlaces,
43
43
  places?: CoordinatePlace[];
44
44
  }
45
45
  export interface ValueOfOnChangeRecommendPlace {
46
+ type: RecommendType;
46
47
  place: Place;
47
48
  inputPlace: Place;
48
- isInZone: boolean;
49
+ zone?: Zone;
49
50
  isSameZone: boolean;
50
51
  }
51
- export interface CoordinateValueOfOnChangeRecommendPlace extends Omit<ValueOfOnChangeRecommendPlace, "place" | "inputPlace"> {
52
+ export interface CoordinateValueOfOnChangeRecommendPlace extends Omit<ValueOfOnChangeRecommendPlace, "place" | "inputPlace" | "zone"> {
52
53
  place: CoordinatePlace;
53
54
  inputPlace: CoordinatePlace;
55
+ zone?: CoordinateZone;
54
56
  }
55
57
  export interface GeoPosition {
56
58
  position: Point;
@@ -86,6 +88,7 @@ export interface TrackPoint {
86
88
  export interface CoordinateTrackPoint extends TrackPoint {
87
89
  type: CoordinateType;
88
90
  }
91
+ export type RecommendType = "Restricted" | "Forbidden" | "Recommend";
89
92
  export type DriverStatus = "dispatching" | "book-dispatching" | "dispatched" | "driverStartService" | "book-driverStartService" | "book-dispatched" | "driverArrived" | "inService" | "canceled" | "endService" | "completed" | "canceling" | "banlanceRefund" | "waitBanlanceRefund" | "rechargePayed" | "waitRechargePay" | "payed" | "waitpay" | "refund" | "confirmed" | "assign" | "orderReassigned";
90
93
  export declare enum CenterPlaceStatus {
91
94
  GEO_LOADING = "GEO_LOADING",
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.4.5";
3
+ const pkgVersion = "2.5.0";
4
4
  const isEnableLog = (name) => {
5
5
  const searchParam = new URLSearchParams(location.search);
6
6
  return searchParam.has(`log-${name}`);
@@ -74,7 +74,7 @@ const isGeoPositionEqual = (p1, p2) => {
74
74
  return p1.coords.longitude === p2.coords.longitude && p1.coords.latitude === p2.coords.latitude;
75
75
  };
76
76
  const isZoneEqual = (z1, z2) => {
77
- return z1.path.every((point, idx) => isPointEqual(point, z2 == null ? void 0 : z2.path[idx]));
77
+ return z1.name === (z2 == null ? void 0 : z2.name) && z1.path.every((point, idx) => isPointEqual(point, z2 == null ? void 0 : z2.path[idx]));
78
78
  };
79
79
  const amapPlaceName2DisplayName = (name, options) => {
80
80
  const { isChina } = options;
@@ -1,5 +1,7 @@
1
- import type { CoordinatePlace, CoordinatePoint, CoordinateRecommendZonePlaces, CoordinateTrackPoint, CoordinateType, CoordinateZone } from "../types/interface";
1
+ import type { CoordinatePlace, CoordinatePoint, CoordinateRecommendZonePlaces, CoordinateTrackPoint, CoordinateType, CoordinateZone, RecommendType } from "../types/interface";
2
2
  export declare function isCoordinateType(type: unknown): type is CoordinateType;
3
+ export declare function isRecommendType(type: unknown): type is RecommendType;
4
+ export declare function toRecommendType(type: unknown): RecommendType;
3
5
  interface MaybeCoordinatePlace {
4
6
  displayName?: string;
5
7
  name: string;
@@ -20,9 +22,10 @@ interface MaybeCoordinateZone {
20
22
  path: MaybeCoordinatePoint[];
21
23
  }
22
24
  export declare const toCoordinateZoneType: (value?: MaybeCoordinateZone) => CoordinateZone;
25
+ export declare const assertNoConflictTypeAndZone: (type: unknown, zone: unknown) => void;
23
26
  interface MaybeCoordinateRecomendZonePlaces {
24
27
  adsorption?: boolean;
25
- force?: boolean;
28
+ type?: string;
26
29
  available?: boolean;
27
30
  zone?: MaybeCoordinateZone;
28
31
  places?: MaybeCoordinatePlace[];
@@ -11,6 +11,16 @@ const createTypeError = (typeName, value, detail) => {
11
11
  function isCoordinateType(type) {
12
12
  return type === "wgs84" || type === "gcj02" || type === "bd09";
13
13
  }
14
+ function isRecommendType(type) {
15
+ return type === "Recommend" || type === "Restricted" || type === "Forbidden";
16
+ }
17
+ function toRecommendType(type) {
18
+ if (type === void 0)
19
+ return "Recommend";
20
+ if (isRecommendType(type))
21
+ return type;
22
+ throw createTypeError("RecommendType", type);
23
+ }
14
24
  const toCoordinatePlaceType = (value) => {
15
25
  var _a;
16
26
  try {
@@ -48,16 +58,31 @@ const toCoordinateZoneType = (value) => {
48
58
  const { name = "", path } = value;
49
59
  if (!Array.isArray(path))
50
60
  throw Error();
51
- return { name, path: path.map(toCoordinatePointType) };
61
+ return { ...value, name, path: path.map(toCoordinatePointType) };
52
62
  } catch (err) {
53
63
  throw createTypeError("CoordinateZone", value, err == null ? void 0 : err.message);
54
64
  }
55
65
  };
66
+ const assertNoConflictTypeAndZone = (type, zone) => {
67
+ if (!!zone && type !== "Restricted" && type !== "Forbidden") {
68
+ throw Error(
69
+ `MyTypeError: zone exist, so expected type: Restricted | Forbidden, but received: ${JSON.stringify(
70
+ type
71
+ )}`
72
+ );
73
+ }
74
+ if (!zone && (type === "Restricted" || type === "Forbidden")) {
75
+ throw Error(
76
+ `MyTypeError: zone not exist, so expected type: Recommend | undefined, but received: ${type}`
77
+ );
78
+ }
79
+ };
56
80
  const toCoordinateRecommendZonePlacesType = (value) => {
57
81
  try {
58
- const { force, available, zone, places, adsorption } = value;
82
+ const { type, available, zone, places, adsorption } = value;
83
+ assertNoConflictTypeAndZone(type, zone);
59
84
  return {
60
- force: !!force,
85
+ type: toRecommendType(type),
61
86
  available: !!available,
62
87
  zone: zone === void 0 ? void 0 : toCoordinateZoneType(zone),
63
88
  places: places === void 0 ? void 0 : places.map(toCoordinatePlaceType),
@@ -81,11 +106,14 @@ const toCoordinateTrackPoint = (value) => {
81
106
  return { lng, lat, type, angle, speed, timestamp };
82
107
  };
83
108
  export {
109
+ assertNoConflictTypeAndZone,
84
110
  isCoordinatePoint,
85
111
  isCoordinateType,
112
+ isRecommendType,
86
113
  toCoordinatePlaceType,
87
114
  toCoordinatePointType,
88
115
  toCoordinateRecommendZonePlacesType,
89
116
  toCoordinateTrackPoint,
90
- toCoordinateZoneType
117
+ toCoordinateZoneType,
118
+ toRecommendType
91
119
  };
package/dist/v3/App.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import { createVNode } from "vue";
2
2
  import { defineComponent, ref } from "vue-demi";
3
- import { DemoBusinessQuoting } from "./Demo/DemoBusinessQuoting.js";
3
+ import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace.js";
4
4
  import { MapProvider } from "./components/MapProvider/MapProvider.js";
5
5
  const gmapApiKey = "AIzaSyCCOe8MAeS3EYvSraKsBX6ztVyLxj69z94";
6
6
  const gmapId = "d0af0c05331af64a";
7
- const gmapRasterId = "e02db3cb62a7b46";
8
7
  const amapApiKey = "81ed1d2b5b77187683717a5f2f19591a";
9
8
  const amapApiSecret = "1dfe626553258a9f91d7c4552c0816d2";
10
9
  const App = /* @__PURE__ */ defineComponent({
@@ -15,7 +14,6 @@ const App = /* @__PURE__ */ defineComponent({
15
14
  "amapKey": amapApiKey,
16
15
  "amapSecret": amapApiSecret,
17
16
  "gmapId": gmapId,
18
- "gmapRasterId": gmapRasterId,
19
17
  "gmapKey": gmapApiKey,
20
18
  "language": "en",
21
19
  "supplier": supplierRef.value,
@@ -25,7 +23,7 @@ const App = /* @__PURE__ */ defineComponent({
25
23
  "onFail": () => console.log(`${supplierRef.value} load failed`),
26
24
  "onDownloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`)
27
25
  }, {
28
- default: () => [createVNode(DemoBusinessQuoting, null, null)]
26
+ default: () => [createVNode(DemoBusinessRecomendPlace, null, null)]
29
27
  });
30
28
  }
31
29
  });
@@ -1,5 +1,5 @@
1
1
  import { createVNode } from "vue";
2
- import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.7133beea.js";
2
+ import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.4c38b1fb.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";
@@ -12,7 +12,8 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
12
12
  await new Promise((r) => setTimeout(r, 3e3));
13
13
  return {
14
14
  available: true,
15
- zone: {
15
+ type: "Restricted",
16
+ zone: Object.assign({
16
17
  name: "",
17
18
  path: [{
18
19
  lng: lng - 1e-3,
@@ -27,7 +28,9 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
27
28
  lat: lat + 5e-4,
28
29
  type
29
30
  }]
30
- },
31
+ }, {
32
+ extra: "extra information 1"
33
+ }),
31
34
  places: [{
32
35
  lat: lat - 1e-5,
33
36
  lng: lng + 1e-4,
@@ -108,6 +111,7 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
108
111
  "class": demo,
109
112
  "geoLoadingTitle": "正在获取您当前的位置",
110
113
  "unavailableTitle": "当前区域暂未开通服务",
114
+ "forbiddenTitle": "当前区域不可叫车",
111
115
  "emptyTitle": "当前位置",
112
116
  "queryingTitle": "正在获取地址信息",
113
117
  "recomendDescription": "您将在此处上车",
@@ -115,7 +119,7 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
115
119
  "defaultCenterPlace": (place) => place != null ? place : {
116
120
  lng: 139.777777,
117
121
  lat: 35.777777,
118
- type: "gcj02",
122
+ type: "wgs84",
119
123
  name: "default place name",
120
124
  displayName: "default place displayName"
121
125
  },
@@ -134,10 +138,11 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
134
138
  "onChangeRecomandPlace": ({
135
139
  place,
136
140
  inputPlace,
137
- isInZone
141
+ type,
142
+ zone
138
143
  }) => {
139
144
  console.log("用户操作地图,计算推荐点后得出的最终位置时触发,此时可以向后端查询城市信息");
140
- console.log("计算推荐点之前的地址是: ", inputPlace, " 最终的地址是: ", place, " 是否在绿区内: ", isInZone);
145
+ console.log("计算推荐点之前的地址是: ", inputPlace, " 最终的地址是: ", place, " 推荐类型: ", type, "绿区(或红区):", zone);
141
146
  },
142
147
  "onClickLocatorText": () => console.log("用户点击了蓝色光标文字触发,此时可以执行用户点击起点输入框相同的逻辑"),
143
148
  "onClickLocatorPhoto": () => console.log("用户点击了蓝色光标图片触发,此时可以执行用户点击起点输入框相同的逻辑"),
@@ -12,7 +12,8 @@ const DemoBusinessReselectPlace = defineSetup("DemoBusinessReselectPlace", funct
12
12
  await new Promise((r) => setTimeout(r, 3e3));
13
13
  return {
14
14
  available: true,
15
- zone: {
15
+ type: "Restricted",
16
+ zone: Object.assign({
16
17
  name: "",
17
18
  path: [{
18
19
  lng: lng - 1e-3,
@@ -27,7 +28,9 @@ const DemoBusinessReselectPlace = defineSetup("DemoBusinessReselectPlace", funct
27
28
  lat: lat + 5e-4,
28
29
  type
29
30
  }]
30
- },
31
+ }, {
32
+ extra: "extra information 1"
33
+ }),
31
34
  places: [{
32
35
  lat: lat - 1e-5,
33
36
  lng: lng + 1e-4,
@@ -112,6 +115,7 @@ const DemoBusinessReselectPlace = defineSetup("DemoBusinessReselectPlace", funct
112
115
  return createVNode("div", null, [createVNode("div", null, [JSON.stringify(centerPlace)]), createVNode(BusinessReselectPlaceMap, {
113
116
  "class": demo,
114
117
  "unavailableTitle": "当前区域暂未开通服务",
118
+ "forbiddenTitle": "当前区域不可叫车",
115
119
  "emptyTitle": "当前位置",
116
120
  "queryingTitle": "正在获取地址信息",
117
121
  "recomendDescription": "您将在此处上车",
@@ -119,7 +123,7 @@ const DemoBusinessReselectPlace = defineSetup("DemoBusinessReselectPlace", funct
119
123
  "defaultPlace": {
120
124
  lng: 139.777777,
121
125
  lat: 35.777777,
122
- type: "gcj02",
126
+ type: "wgs84",
123
127
  name: "default place name",
124
128
  displayName: "default place display name"
125
129
  },
@@ -135,10 +139,11 @@ const DemoBusinessReselectPlace = defineSetup("DemoBusinessReselectPlace", funct
135
139
  "onChangeRecomandPlace": ({
136
140
  place,
137
141
  inputPlace,
138
- isInZone
142
+ type,
143
+ zone
139
144
  }) => {
140
145
  console.log("用户操作地图,计算推荐点后得出的最终位置时触发,此时可以向后端查询城市信息");
141
- console.log("计算推荐点之前的地址是: ", inputPlace, " 最终的地址是: ", place, " 是否在绿区内: ", isInZone);
146
+ console.log("计算推荐点之前的地址是: ", inputPlace, " 最终的地址是: ", place, " 推荐类型: ", type, "绿区(或红区):", zone);
142
147
  },
143
148
  "onClickLocatorText": () => console.log("用户点击了蓝色光标文字触发,此时可以执行用户点击起点输入框相同的逻辑"),
144
149
  "onClickLocatorPhoto": () => console.log("用户点击了蓝色光标图片触发,此时可以执行用户点击起点输入框相同的逻辑"),
@@ -24,6 +24,7 @@ export interface BusinessRecomendPlaceMapProps extends CoordinatifyProps<Omit<He
24
24
  log?: boolean;
25
25
  geoLoadingTitle: string;
26
26
  unavailableTitle: string;
27
+ forbiddenTitle: string;
27
28
  emptyTitle: string;
28
29
  queryingTitle: string;
29
30
  recomendDescription: string;
@@ -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.7133beea.js";
30
+ import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.4c38b1fb.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.7133beea.js";
1
+ import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.4c38b1fb.js";
2
2
  export {
3
3
  B as BusinessRecomendPlaceMap,
4
4
  f as BusinessRecomendPlaceMapInner,
@@ -1,6 +1,6 @@
1
1
  import { type CoordinatePlace, type Place } from "../../types/interface";
2
2
  import { type BusinessRecomendPlaceMapProps } from "../BusinessRecomendPlaceMap";
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"> {
3
+ export interface BusinessReselectPlaceMapProps extends Pick<BusinessRecomendPlaceMapProps, "geoErrorOnceNotificationKey" | "loading" | "fallback" | "log" | "getAvailable" | "getRecomendPlace" | "unavailableTitle" | "forbiddenTitle" | "emptyTitle" | "queryingTitle" | "recomendDescription" | "disableLocator" | "disableLocatorPhoto" | "mapContext" | "renderPlacePhoto" | "renderPlaceTag" | "onChangeGeoLocation" | "onChangePlace" | "onChangeRecomandPlace" | "onGeoError" | "onGeoErrorOnce" | "onClickLocatorText" | "onClickLocatorPhoto"> {
4
4
  defaultPlace?: CoordinatePlace;
5
5
  }
6
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<{