@heycar/heycars-map 0.5.9 → 0.6.1

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.
@@ -1,10 +1 @@
1
- export declare const SomeAutoComplete: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<{
2
- cityName: string;
3
- }>, 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<{
4
- cityName: string;
5
- }, Required<{
6
- cityName: string;
7
- }>>, never, {
8
- cityName: string;
9
- }, {}>;
10
- export declare const DemoBusinessRecomendPlace: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, 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<unknown, Required<unknown>>, never, unknown, {}>;
1
+ export declare const DemoBusinessRecomendPlace: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, 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<unknown, Required<unknown>>, never, unknown, {}>;
@@ -22,9 +22,8 @@ export interface BusinessRecomendPlaceMapProps extends Omit<HeycarMapProps, "cen
22
22
  onChangeByDrag?: UseMapDragProps["onChange"];
23
23
  onChangeGeoLocation?: UseGeoLocationProps["onChange"];
24
24
  onChangePlace?: UseMapPlaceProps["onChange"];
25
- onChangeCity?: UseMapPlaceProps["onChangeCity"];
26
25
  onChangeRecomandPlace?: UseMapRecomendPlaceProps["onChange"];
27
26
  onGeoError?: UseGeoLocationProps["onError"];
28
27
  onClickLocator?: AbsoluteAddressBoxProps["onClick"];
29
28
  }
30
- export declare const BusinessRecomendPlaceMap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").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" | "changeCity" | "changePlace" | "loadGeoLocation" | "loadDefaultGeoLocation" | "changeByDrag" | "changeGeoLocation" | "changeRecomandPlace" | "geoError" | "clickLocator", BusinessRecomendPlaceMapProps, {}>;
29
+ export declare const BusinessRecomendPlaceMap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").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" | "clickLocator", BusinessRecomendPlaceMapProps, {}>;
@@ -1,52 +1,34 @@
1
1
  import { Ref } from "vue-demi";
2
2
  import type { Place, Point } from "../types/interface";
3
- export interface UseMapPlaceOnChangeCityProps extends Place {
4
- cityName?: string;
5
- cityParentName?: string;
6
- countryName?: string;
7
- }
8
3
  export interface UseMapPlaceProps {
9
4
  pointRef: Ref<Point>;
10
5
  emptyPlaceName: string;
11
6
  onChange?: (value: Place) => any;
12
- onChangeCity?: (value: UseMapPlaceOnChangeCityProps) => any;
13
7
  }
14
8
  export declare const useAmapPlace: (props: UseMapPlaceProps) => {
15
9
  place: {
16
10
  lng: number;
17
11
  lat: number;
18
12
  name: string;
19
- cityName?: string | undefined;
20
- cityParentName?: string | undefined;
21
- countryName?: string | undefined;
22
13
  };
23
14
  updatePlace: (value: Point) => void;
24
15
  setPlace: (value: Place) => void;
25
- updateCity: (value: Place) => void;
26
16
  };
27
17
  export declare const useGmapPlace: (props: UseMapPlaceProps) => {
28
18
  place: {
29
19
  lng: number;
30
20
  lat: number;
31
21
  name: string;
32
- cityName?: string | undefined;
33
- cityParentName?: string | undefined;
34
- countryName?: string | undefined;
35
22
  };
36
23
  updatePlace: (value: Point) => void;
37
24
  setPlace: (value: Place) => void;
38
- updateCity: (value: Place) => Promise<void>;
39
25
  };
40
26
  export declare const useMapPlace: (props: UseMapPlaceProps) => {
41
27
  place: {
42
28
  lng: number;
43
29
  lat: number;
44
30
  name: string;
45
- cityName?: string | undefined;
46
- cityParentName?: string | undefined;
47
- countryName?: string | undefined;
48
31
  };
49
32
  updatePlace: (value: Point) => void;
50
33
  setPlace: (value: Place) => void;
51
- updateCity: (value: Place) => void;
52
34
  };
@@ -7,7 +7,6 @@ export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
7
7
  emptyPlaceName: string;
8
8
  getLimit: (context?: C) => number;
9
9
  getRecomendPlace: (place: Place, context?: C) => Promise<Place[] | undefined>;
10
- onChangeCity?: UseMapPlaceProps["onChangeCity"];
11
10
  onChangePlace?: UseMapPlaceProps["onChange"];
12
11
  onChange?: (place: Place) => any;
13
12
  }
@@ -16,17 +15,11 @@ export declare const useAmapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C
16
15
  lng: number;
17
16
  lat: number;
18
17
  name: string;
19
- cityName?: string | undefined;
20
- cityParentName?: string | undefined;
21
- countryName?: string | undefined;
22
18
  };
23
19
  placeCandidates: Ref<{
24
20
  lng: number;
25
21
  lat: number;
26
22
  name: string;
27
- cityName?: string | undefined;
28
- cityParentName?: string | undefined;
29
- countryName?: string | undefined;
30
23
  }[]>;
31
24
  availableRef: Ref<boolean>;
32
25
  isElectedRef: import("vue-demi").ComputedRef<boolean>;
@@ -34,24 +27,17 @@ export declare const useAmapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C
34
27
  updatePlaceCandidates: (place: Place) => Promise<void>;
35
28
  updatePlace: (value: Point) => void;
36
29
  setPlace: (value: Place) => void;
37
- updateCity: (value: Place) => void;
38
30
  };
39
31
  export declare const useGmapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C>) => {
40
32
  recomendPlace: {
41
33
  lng: number;
42
34
  lat: number;
43
35
  name: string;
44
- cityName?: string | undefined;
45
- cityParentName?: string | undefined;
46
- countryName?: string | undefined;
47
36
  };
48
37
  placeCandidates: Ref<{
49
38
  lng: number;
50
39
  lat: number;
51
40
  name: string;
52
- cityName?: string | undefined;
53
- cityParentName?: string | undefined;
54
- countryName?: string | undefined;
55
41
  }[]>;
56
42
  availableRef: Ref<boolean>;
57
43
  isElectedRef: import("vue-demi").ComputedRef<boolean>;
@@ -59,24 +45,17 @@ export declare const useGmapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C
59
45
  updatePlaceCandidates: (place: Place) => Promise<void>;
60
46
  updatePlace: (value: Point) => void;
61
47
  setPlace: (value: Place) => void;
62
- updateCity: (value: Place) => Promise<void>;
63
48
  };
64
49
  export declare const useMapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C>) => {
65
50
  recomendPlace: {
66
51
  lng: number;
67
52
  lat: number;
68
53
  name: string;
69
- cityName?: string | undefined;
70
- cityParentName?: string | undefined;
71
- countryName?: string | undefined;
72
54
  };
73
55
  placeCandidates: Ref<{
74
56
  lng: number;
75
57
  lat: number;
76
58
  name: string;
77
- cityName?: string | undefined;
78
- cityParentName?: string | undefined;
79
- countryName?: string | undefined;
80
59
  }[]>;
81
60
  availableRef: Ref<boolean>;
82
61
  isElectedRef: import("vue-demi").ComputedRef<boolean>;
@@ -84,5 +63,4 @@ export declare const useMapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C>
84
63
  updatePlaceCandidates: (place: Place) => Promise<void>;
85
64
  updatePlace: (value: Point) => void;
86
65
  setPlace: (value: Place) => void;
87
- updateCity: (value: Place) => void;
88
66
  };
@@ -11,17 +11,11 @@ export declare const useBusinessRecomendPlaceMap: () => {
11
11
  lng: number;
12
12
  lat: number;
13
13
  name: string;
14
- cityName?: string | undefined;
15
- cityParentName?: string | undefined;
16
- countryName?: string | undefined;
17
14
  };
18
15
  placeCandidates: import("vue-demi").Ref<{
19
16
  lng: number;
20
17
  lat: number;
21
18
  name: string;
22
- cityName?: string | undefined;
23
- cityParentName?: string | undefined;
24
- countryName?: string | undefined;
25
19
  }[]>;
26
20
  panToGeoPositionByRecomend: (value: Point) => void;
27
21
  setCenterPlaceByUserSpecified: (value: Place) => void;
package/dist/index.cjs CHANGED
@@ -937,18 +937,6 @@ const pipeOnlyLastEffect = (fn) => {
937
937
  });
938
938
  };
939
939
  };
940
- const geocoderResult2cityName = (value) => {
941
- const { address_components } = value;
942
- const address = address_components.find(
943
- (item) => item.types[0] === "administrative_area_level_1" || item.types[0] === "administrative_area_level_2"
944
- );
945
- if (address)
946
- return address.long_name;
947
- const countryIdx = address_components.findIndex((item) => item.types[0] === "country");
948
- if (countryIdx > 0)
949
- return address_components[countryIdx - 1].long_name;
950
- return void 0;
951
- };
952
940
  const isPlaceEqual = (p1, p2) => {
953
941
  return p1.lng === (p2 == null ? void 0 : p2.lng) && p1.lat === (p2 == null ? void 0 : p2.lat);
954
942
  };
@@ -3254,7 +3242,7 @@ const useUpdate = () => {
3254
3242
  return { idx, update };
3255
3243
  };
3256
3244
  const useAmapPlace = (props) => {
3257
- const { onChange, onChangeCity, emptyPlaceName } = props;
3245
+ const { onChange, emptyPlaceName } = props;
3258
3246
  const defaultPoint = [...props.pointRef.value];
3259
3247
  const pointRef = Vue.ref(defaultPoint);
3260
3248
  const { readyPromise } = useMapSupplier();
@@ -3264,19 +3252,6 @@ const useAmapPlace = (props) => {
3264
3252
  name: ""
3265
3253
  });
3266
3254
  const { idx: placeKey, update } = useUpdate();
3267
- const updateCity = (value) => {
3268
- const geocoder = new AMap.Geocoder({ lang: LANGUAGE });
3269
- const { lng, lat } = value;
3270
- geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3271
- if (status !== "complete")
3272
- return;
3273
- const { formattedAddress, addressComponent } = result.regeocode;
3274
- const name = formattedAddress ? formattedAddress : emptyPlaceName;
3275
- const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3276
- const cityParentName = addressComponent.province;
3277
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName: "" });
3278
- });
3279
- };
3280
3255
  const updatePlace = (value) => {
3281
3256
  pointRef.value = value;
3282
3257
  update();
@@ -3295,15 +3270,12 @@ const useAmapPlace = (props) => {
3295
3270
  geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3296
3271
  switch (status) {
3297
3272
  case "complete": {
3298
- const { formattedAddress, addressComponent } = result.regeocode;
3299
- const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3300
- const cityParentName = addressComponent.province;
3273
+ const { formattedAddress } = result.regeocode;
3301
3274
  const name = formattedAddress ? formattedAddress : emptyPlaceName;
3302
3275
  place.name = name;
3303
3276
  place.lng = lng;
3304
3277
  place.lat = lat;
3305
3278
  onChange == null ? void 0 : onChange({ lng, lat, name });
3306
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName: "" });
3307
3279
  return;
3308
3280
  }
3309
3281
  case "no_data":
@@ -3311,14 +3283,6 @@ const useAmapPlace = (props) => {
3311
3283
  place.lng = lng;
3312
3284
  place.lat = lat;
3313
3285
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3314
- onChangeCity == null ? void 0 : onChangeCity({
3315
- name: "",
3316
- lng,
3317
- lat,
3318
- cityName: "",
3319
- cityParentName: "",
3320
- countryName: ""
3321
- });
3322
3286
  return;
3323
3287
  case "error":
3324
3288
  throw result;
@@ -3326,10 +3290,10 @@ const useAmapPlace = (props) => {
3326
3290
  });
3327
3291
  }
3328
3292
  );
3329
- return { place, updatePlace, setPlace, updateCity };
3293
+ return { place, updatePlace, setPlace };
3330
3294
  };
3331
3295
  const useGmapPlace = (props) => {
3332
- const { onChange, onChangeCity, emptyPlaceName } = props;
3296
+ const { onChange, emptyPlaceName } = props;
3333
3297
  const defaultPoint = [...props.pointRef.value];
3334
3298
  const pointRef = Vue.ref(defaultPoint);
3335
3299
  const { readyPromise } = useMapSupplier();
@@ -3348,16 +3312,6 @@ const useGmapPlace = (props) => {
3348
3312
  place.lat = value.lat;
3349
3313
  place.name = value.name;
3350
3314
  };
3351
- const updateCity = async (value) => {
3352
- const geocoder = new google.maps.Geocoder();
3353
- const { lng, lat } = value;
3354
- const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3355
- const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3356
- const cityName = geocoderResult2cityName(results[0]);
3357
- const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3358
- const countryName = results.slice(-1)[0].address_components[0].long_name;
3359
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName });
3360
- };
3361
3315
  Vue.watch(
3362
3316
  () => placeKey.value,
3363
3317
  async () => {
@@ -3366,17 +3320,13 @@ const useGmapPlace = (props) => {
3366
3320
  const [lng, lat] = pointRef.value;
3367
3321
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3368
3322
  const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3369
- const cityName = geocoderResult2cityName(results[0]);
3370
- const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3371
- const countryName = results.slice(-1)[0].address_components[0].long_name;
3372
3323
  place.lng = lng;
3373
3324
  place.lat = lat;
3374
3325
  place.name = name;
3375
3326
  onChange == null ? void 0 : onChange({ lng, lat, name });
3376
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName });
3377
3327
  }
3378
3328
  );
3379
- return { place, updatePlace, setPlace, updateCity };
3329
+ return { place, updatePlace, setPlace };
3380
3330
  };
3381
3331
  const useMapPlace = (props) => {
3382
3332
  const { supplier } = useMapSupplier();
@@ -3407,25 +3357,15 @@ const findGmapNearestPlace = (place, candidates) => {
3407
3357
  return { shortestPlace, shortestDistance };
3408
3358
  };
3409
3359
  const useAmapRecomendPlace = (props) => {
3410
- const {
3411
- pointRef,
3412
- getRecomendPlace,
3413
- getLimit,
3414
- context: context2,
3415
- emptyPlaceName,
3416
- onChange,
3417
- onChangePlace,
3418
- onChangeCity
3419
- } = props;
3360
+ const { pointRef, getRecomendPlace, getLimit, context: context2, emptyPlaceName, onChange, onChangePlace } = props;
3420
3361
  const availableRef = Vue.ref(true);
3421
3362
  const placeCandidatesRef = Vue.ref([]);
3422
3363
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3423
3364
  const { readyPromise } = useMapSupplier();
3424
- const { place, updatePlace, setPlace, updateCity } = useAmapPlace({
3365
+ const { place, updatePlace, setPlace } = useAmapPlace({
3425
3366
  emptyPlaceName,
3426
3367
  pointRef,
3427
- onChange: onChangePlace,
3428
- onChangeCity
3368
+ onChange: onChangePlace
3429
3369
  });
3430
3370
  const recomendPlace = Vue.reactive({ ...place });
3431
3371
  const isElectedRef = Vue.computed(() => {
@@ -3468,30 +3408,19 @@ const useAmapRecomendPlace = (props) => {
3468
3408
  updateRecomandPlace,
3469
3409
  updatePlaceCandidates,
3470
3410
  updatePlace,
3471
- setPlace,
3472
- updateCity
3411
+ setPlace
3473
3412
  };
3474
3413
  };
3475
3414
  const useGmapRecomendPlace = (props) => {
3476
- const {
3477
- pointRef,
3478
- getRecomendPlace,
3479
- getLimit,
3480
- context: context2,
3481
- emptyPlaceName,
3482
- onChange,
3483
- onChangePlace,
3484
- onChangeCity
3485
- } = props;
3415
+ const { pointRef, getRecomendPlace, getLimit, context: context2, emptyPlaceName, onChange, onChangePlace } = props;
3486
3416
  const availableRef = Vue.ref(true);
3487
3417
  const placeCandidatesRef = Vue.ref([]);
3488
3418
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3489
3419
  const { readyPromise } = useMapSupplier();
3490
- const { place, updatePlace, setPlace, updateCity } = useGmapPlace({
3420
+ const { place, updatePlace, setPlace } = useGmapPlace({
3491
3421
  emptyPlaceName,
3492
3422
  pointRef,
3493
- onChange: onChangePlace,
3494
- onChangeCity
3423
+ onChange: onChangePlace
3495
3424
  });
3496
3425
  const recomendPlace = Vue.reactive({ ...place });
3497
3426
  const isElectedRef = Vue.computed(() => {
@@ -3534,8 +3463,7 @@ const useGmapRecomendPlace = (props) => {
3534
3463
  updateRecomandPlace,
3535
3464
  updatePlaceCandidates,
3536
3465
  updatePlace,
3537
- setPlace,
3538
- updateCity
3466
+ setPlace
3539
3467
  };
3540
3468
  };
3541
3469
  const useMapRecomendPlace = (props) => {
@@ -3971,7 +3899,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3971
3899
  centerPlace.lng = place.lng;
3972
3900
  centerPlace.lat = place.lat;
3973
3901
  centerPlace.name = place.name;
3974
- updateCity(place);
3902
+ emit("changePlace", {
3903
+ ...place
3904
+ });
3975
3905
  updatePlaceCandidates(place);
3976
3906
  await pipeDefer(setZoom)(READY_ZOOM);
3977
3907
  };
@@ -4033,7 +3963,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4033
3963
  });
4034
3964
  const {
4035
3965
  updatePlace,
4036
- updateCity,
4037
3966
  updateRecomandPlace,
4038
3967
  updatePlaceCandidates,
4039
3968
  placeCandidates,
@@ -4073,9 +4002,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4073
4002
  if (isFirstWorkflowRecomendLoadingRef.value)
4074
4003
  await pipeDefer(setZoom)(READY_ZOOM);
4075
4004
  completeFirstWorkflowRecomend();
4076
- },
4077
- onChangeCity: (value) => {
4078
- emit("changeCity", value);
4079
4005
  }
4080
4006
  });
4081
4007
  Vue.watchEffect(() => {
@@ -4641,6 +4567,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4641
4567
  distance,
4642
4568
  duration
4643
4569
  }) => {
4570
+ var _a;
4644
4571
  spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4645
4572
  return [Vue.h(DrivingLine, {
4646
4573
  "attrs": {
@@ -4648,7 +4575,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4648
4575
  }
4649
4576
  }), Vue.h(TaxiCar, {
4650
4577
  "attrs": {
4651
- "position": carPosition,
4578
+ "position": (_a = path[0]) != null ? _a : carPosition,
4652
4579
  "angle": angle,
4653
4580
  "title": renderTitle({
4654
4581
  distance,
@@ -4861,6 +4788,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4861
4788
  distance,
4862
4789
  duration
4863
4790
  }) => {
4791
+ var _a;
4864
4792
  spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4865
4793
  return [Vue.h(DrivingLine, {
4866
4794
  "attrs": {
@@ -4868,7 +4796,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4868
4796
  }
4869
4797
  }), Vue.h(TaxiCar, {
4870
4798
  "attrs": {
4871
- "position": carPosition,
4799
+ "position": (_a = path[0]) != null ? _a : carPosition,
4872
4800
  "angle": angle,
4873
4801
  "title": renderTitle({
4874
4802
  distance,
@@ -5189,193 +5117,6 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5189
5117
  )]);
5190
5118
  };
5191
5119
  }).props(["bookDispatchingTitle", "dispatchingTitle", "driverArrivedTitle", "driverStatus", "fallback", "from", "getDriverPosition", "interval", "loading", "mapRef", "renderInServiceTitle", "renderStartSerivceTitle", "to", "registerOverlay"]);
5192
- const useAmapAutoComplete = (props) => {
5193
- const { city } = props;
5194
- const cityRef = Vue.ref(city);
5195
- const { readyPromise } = useMapSupplier();
5196
- const { apiMapDistance } = useMapGeometry();
5197
- const { geoPosition } = useGeoLocation();
5198
- const keywordRef = Vue.ref("");
5199
- const autoCompletePlacesRef = Vue.ref([]);
5200
- const { update, idx: updateKey } = useUpdate();
5201
- const setCity = (value) => {
5202
- cityRef.value = value;
5203
- update();
5204
- };
5205
- const setKeyword = (value) => {
5206
- keywordRef.value = value;
5207
- update();
5208
- };
5209
- Vue.watch(
5210
- () => updateKey.value,
5211
- async () => {
5212
- if (!keywordRef.value)
5213
- return;
5214
- await readyPromise;
5215
- const amapPlaceSearch = new AMap.PlaceSearch({ city: cityRef.value.name });
5216
- amapPlaceSearch.search(keywordRef.value, (status, result) => {
5217
- const from = geoPosition.value;
5218
- switch (status) {
5219
- case "complete": {
5220
- autoCompletePlacesRef.value = result.poiList.pois.map(
5221
- (poi) => {
5222
- const { lat, lng } = poi.location;
5223
- return {
5224
- lat,
5225
- lng,
5226
- name: poi.name,
5227
- description: poi.address,
5228
- distance: from ? apiMapDistance(from, [lng, lat]) : void 0
5229
- };
5230
- }
5231
- );
5232
- return;
5233
- }
5234
- case "no_data":
5235
- autoCompletePlacesRef.value = [];
5236
- return;
5237
- default:
5238
- throw result;
5239
- }
5240
- });
5241
- },
5242
- {
5243
- immediate: true
5244
- }
5245
- );
5246
- return { setKeyword, setCity, autoCompletePlaces: autoCompletePlacesRef };
5247
- };
5248
- const useGmapAutoComplete = (props) => {
5249
- const { city } = props;
5250
- const cityRef = Vue.ref({ ...city });
5251
- const { readyPromise } = useMapSupplier();
5252
- const { apiMapDistance } = useMapGeometry();
5253
- const { geoPosition } = useGeoLocation();
5254
- const keywordRef = Vue.ref("");
5255
- const autoCompletePlacesRef = Vue.ref([]);
5256
- const { update, idx: updateKey } = useUpdate();
5257
- const setCity = (value) => {
5258
- cityRef.value = value;
5259
- update();
5260
- };
5261
- const setKeyword = (value) => {
5262
- keywordRef.value = value;
5263
- update();
5264
- };
5265
- const div = document.createElement("div");
5266
- Vue.watch(
5267
- () => updateKey.value,
5268
- async () => {
5269
- if (!keywordRef.value)
5270
- return;
5271
- await readyPromise;
5272
- const gmapPlacesService = new google.maps.places.PlacesService(div);
5273
- gmapPlacesService.textSearch(
5274
- {
5275
- query: keywordRef.value,
5276
- bounds: cityRef.value.bound
5277
- },
5278
- (result, status) => {
5279
- const from = geoPosition.value;
5280
- switch (status) {
5281
- case google.maps.places.PlacesServiceStatus.OK:
5282
- autoCompletePlacesRef.value = result.map(({ geometry, name, formatted_address }) => {
5283
- var _a, _b, _c, _d;
5284
- const lng = (_b = (_a = geometry == null ? void 0 : geometry.location) == null ? void 0 : _a.lng()) != null ? _b : 0;
5285
- const lat = (_d = (_c = geometry == null ? void 0 : geometry.location) == null ? void 0 : _c.lat()) != null ? _d : 0;
5286
- return {
5287
- lng,
5288
- lat,
5289
- name: name != null ? name : "",
5290
- description: formatted_address != null ? formatted_address : "",
5291
- distance: from ? apiMapDistance(from, [lng, lat]) : void 0
5292
- };
5293
- });
5294
- return;
5295
- case google.maps.places.PlacesServiceStatus.ZERO_RESULTS:
5296
- case google.maps.places.PlacesServiceStatus.NOT_FOUND:
5297
- autoCompletePlacesRef.value = [];
5298
- return;
5299
- }
5300
- }
5301
- );
5302
- }
5303
- );
5304
- return { setKeyword, setCity, autoCompletePlaces: autoCompletePlacesRef };
5305
- };
5306
- const useMapAutoComplete = (props) => {
5307
- const { supplier } = useMapSupplier();
5308
- return supplier === "gmap" ? useGmapAutoComplete(props) : useAmapAutoComplete(props);
5309
- };
5310
- const useAmapBoundCity = (props) => {
5311
- var _a;
5312
- const { cityNameRef, onChange } = props;
5313
- const city = Vue.reactive({ name: (_a = cityNameRef.value) != null ? _a : "" });
5314
- Vue.watch(
5315
- () => cityNameRef.value,
5316
- (cityName) => {
5317
- const name = cityName != null ? cityName : "";
5318
- city.name = name;
5319
- onChange == null ? void 0 : onChange({ name });
5320
- }
5321
- );
5322
- return city;
5323
- };
5324
- const useGmapBoundCity = (props) => {
5325
- var _a;
5326
- const { cityNameRef, onChange } = props;
5327
- const { readyPromise } = useMapSupplier();
5328
- const city = Vue.reactive({
5329
- name: (_a = cityNameRef.value) != null ? _a : "",
5330
- bound: {
5331
- east: 0,
5332
- north: 0,
5333
- south: 0,
5334
- west: 0
5335
- }
5336
- });
5337
- Vue.watchEffect(async () => {
5338
- var _a2, _b;
5339
- const cityName = cityNameRef.value;
5340
- if (!cityName)
5341
- return;
5342
- await readyPromise;
5343
- const geocoder = new google.maps.Geocoder();
5344
- const { results } = await geocoder.geocode({
5345
- address: cityName,
5346
- componentRestrictions: {
5347
- administrativeArea: "administrative_area_level_1"
5348
- },
5349
- language: LANGUAGE
5350
- });
5351
- if (results.length !== 1) {
5352
- throw new Error("MyError: multiple city found");
5353
- }
5354
- const { geometry } = results[0];
5355
- const cityBound = (_b = (_a2 = geometry.bounds) == null ? void 0 : _a2.toJSON()) != null ? _b : geometry.viewport.toJSON();
5356
- city.name = cityName;
5357
- city.bound = cityBound;
5358
- onChange == null ? void 0 : onChange({ name: cityName, bound: cityBound });
5359
- });
5360
- return city;
5361
- };
5362
- const useMapBoundCity = (props) => {
5363
- const { supplier } = useMapSupplier();
5364
- return supplier === "gmap" ? useGmapBoundCity(props) : useAmapBoundCity(props);
5365
- };
5366
- const useBusinessMapAutoComplete = (props) => {
5367
- const { cityNameRef } = props;
5368
- const city = useMapBoundCity({
5369
- cityNameRef,
5370
- onChange: (v) => setCity(v)
5371
- });
5372
- const { autoCompletePlaces, setKeyword, setCity } = useMapAutoComplete({ city });
5373
- const handleKeywordInput = (e) => {
5374
- const target = e.target;
5375
- setKeyword(target.value);
5376
- };
5377
- return { autoCompletePlaces, setKeyword, setCity, handleKeywordInput };
5378
- };
5379
5120
  const useBusinessQuotingMap = () => {
5380
5121
  const { setMap, mapRef } = useHeycarMap();
5381
5122
  const { registerFitVeiw, setFitView } = useMapFitView({
@@ -5444,7 +5185,6 @@ exports.TaxiCar = TaxiCar;
5444
5185
  exports.WalkingLine = WalkingLine;
5445
5186
  exports.WalkingRoute = WalkingRoute;
5446
5187
  exports.WaveCircle = WaveCircle;
5447
- exports.useBusinessMapAutoComplete = useBusinessMapAutoComplete;
5448
5188
  exports.useBusinessQuotingMap = useBusinessQuotingMap;
5449
5189
  exports.useBusinessRecomendPlaceMap = useBusinessRecomendPlaceMap;
5450
5190
  exports.useBusinessTaxiServiceMap = useBusinessTaxiServiceMap;
package/dist/index.d.ts CHANGED
@@ -16,7 +16,6 @@ export { WalkingLine } from "./business-components/WalkingLine";
16
16
  export { WalkingRoute } from "./business-components/WalkingRoute";
17
17
  export { WaveCircle } from "./business-components/WaveCircle";
18
18
  export * from "./components/MapProvider";
19
- export * from "./hooks-business/useBusinessMapAutoComplete";
20
19
  export * from "./hooks-business/useBusinessQuotingMap";
21
20
  export * from "./hooks-business/useBusinessRecomendPlaceMap";
22
21
  export * from "./hooks-business/useBusinessTaxiServiceMap";
package/dist/index.js CHANGED
@@ -935,18 +935,6 @@ const pipeOnlyLastEffect = (fn) => {
935
935
  });
936
936
  };
937
937
  };
938
- const geocoderResult2cityName = (value) => {
939
- const { address_components } = value;
940
- const address = address_components.find(
941
- (item) => item.types[0] === "administrative_area_level_1" || item.types[0] === "administrative_area_level_2"
942
- );
943
- if (address)
944
- return address.long_name;
945
- const countryIdx = address_components.findIndex((item) => item.types[0] === "country");
946
- if (countryIdx > 0)
947
- return address_components[countryIdx - 1].long_name;
948
- return void 0;
949
- };
950
938
  const isPlaceEqual = (p1, p2) => {
951
939
  return p1.lng === (p2 == null ? void 0 : p2.lng) && p1.lat === (p2 == null ? void 0 : p2.lat);
952
940
  };
@@ -3252,7 +3240,7 @@ const useUpdate = () => {
3252
3240
  return { idx, update };
3253
3241
  };
3254
3242
  const useAmapPlace = (props) => {
3255
- const { onChange, onChangeCity, emptyPlaceName } = props;
3243
+ const { onChange, emptyPlaceName } = props;
3256
3244
  const defaultPoint = [...props.pointRef.value];
3257
3245
  const pointRef = ref(defaultPoint);
3258
3246
  const { readyPromise } = useMapSupplier();
@@ -3262,19 +3250,6 @@ const useAmapPlace = (props) => {
3262
3250
  name: ""
3263
3251
  });
3264
3252
  const { idx: placeKey, update } = useUpdate();
3265
- const updateCity = (value) => {
3266
- const geocoder = new AMap.Geocoder({ lang: LANGUAGE });
3267
- const { lng, lat } = value;
3268
- geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3269
- if (status !== "complete")
3270
- return;
3271
- const { formattedAddress, addressComponent } = result.regeocode;
3272
- const name = formattedAddress ? formattedAddress : emptyPlaceName;
3273
- const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3274
- const cityParentName = addressComponent.province;
3275
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName: "" });
3276
- });
3277
- };
3278
3253
  const updatePlace = (value) => {
3279
3254
  pointRef.value = value;
3280
3255
  update();
@@ -3293,15 +3268,12 @@ const useAmapPlace = (props) => {
3293
3268
  geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3294
3269
  switch (status) {
3295
3270
  case "complete": {
3296
- const { formattedAddress, addressComponent } = result.regeocode;
3297
- const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3298
- const cityParentName = addressComponent.province;
3271
+ const { formattedAddress } = result.regeocode;
3299
3272
  const name = formattedAddress ? formattedAddress : emptyPlaceName;
3300
3273
  place.name = name;
3301
3274
  place.lng = lng;
3302
3275
  place.lat = lat;
3303
3276
  onChange == null ? void 0 : onChange({ lng, lat, name });
3304
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName: "" });
3305
3277
  return;
3306
3278
  }
3307
3279
  case "no_data":
@@ -3309,14 +3281,6 @@ const useAmapPlace = (props) => {
3309
3281
  place.lng = lng;
3310
3282
  place.lat = lat;
3311
3283
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3312
- onChangeCity == null ? void 0 : onChangeCity({
3313
- name: "",
3314
- lng,
3315
- lat,
3316
- cityName: "",
3317
- cityParentName: "",
3318
- countryName: ""
3319
- });
3320
3284
  return;
3321
3285
  case "error":
3322
3286
  throw result;
@@ -3324,10 +3288,10 @@ const useAmapPlace = (props) => {
3324
3288
  });
3325
3289
  }
3326
3290
  );
3327
- return { place, updatePlace, setPlace, updateCity };
3291
+ return { place, updatePlace, setPlace };
3328
3292
  };
3329
3293
  const useGmapPlace = (props) => {
3330
- const { onChange, onChangeCity, emptyPlaceName } = props;
3294
+ const { onChange, emptyPlaceName } = props;
3331
3295
  const defaultPoint = [...props.pointRef.value];
3332
3296
  const pointRef = ref(defaultPoint);
3333
3297
  const { readyPromise } = useMapSupplier();
@@ -3346,16 +3310,6 @@ const useGmapPlace = (props) => {
3346
3310
  place.lat = value.lat;
3347
3311
  place.name = value.name;
3348
3312
  };
3349
- const updateCity = async (value) => {
3350
- const geocoder = new google.maps.Geocoder();
3351
- const { lng, lat } = value;
3352
- const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3353
- const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3354
- const cityName = geocoderResult2cityName(results[0]);
3355
- const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3356
- const countryName = results.slice(-1)[0].address_components[0].long_name;
3357
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName });
3358
- };
3359
3313
  watch(
3360
3314
  () => placeKey.value,
3361
3315
  async () => {
@@ -3364,17 +3318,13 @@ const useGmapPlace = (props) => {
3364
3318
  const [lng, lat] = pointRef.value;
3365
3319
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3366
3320
  const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3367
- const cityName = geocoderResult2cityName(results[0]);
3368
- const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3369
- const countryName = results.slice(-1)[0].address_components[0].long_name;
3370
3321
  place.lng = lng;
3371
3322
  place.lat = lat;
3372
3323
  place.name = name;
3373
3324
  onChange == null ? void 0 : onChange({ lng, lat, name });
3374
- onChangeCity == null ? void 0 : onChangeCity({ name, lng, lat, cityName, cityParentName, countryName });
3375
3325
  }
3376
3326
  );
3377
- return { place, updatePlace, setPlace, updateCity };
3327
+ return { place, updatePlace, setPlace };
3378
3328
  };
3379
3329
  const useMapPlace = (props) => {
3380
3330
  const { supplier } = useMapSupplier();
@@ -3405,25 +3355,15 @@ const findGmapNearestPlace = (place, candidates) => {
3405
3355
  return { shortestPlace, shortestDistance };
3406
3356
  };
3407
3357
  const useAmapRecomendPlace = (props) => {
3408
- const {
3409
- pointRef,
3410
- getRecomendPlace,
3411
- getLimit,
3412
- context: context2,
3413
- emptyPlaceName,
3414
- onChange,
3415
- onChangePlace,
3416
- onChangeCity
3417
- } = props;
3358
+ const { pointRef, getRecomendPlace, getLimit, context: context2, emptyPlaceName, onChange, onChangePlace } = props;
3418
3359
  const availableRef = ref(true);
3419
3360
  const placeCandidatesRef = ref([]);
3420
3361
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3421
3362
  const { readyPromise } = useMapSupplier();
3422
- const { place, updatePlace, setPlace, updateCity } = useAmapPlace({
3363
+ const { place, updatePlace, setPlace } = useAmapPlace({
3423
3364
  emptyPlaceName,
3424
3365
  pointRef,
3425
- onChange: onChangePlace,
3426
- onChangeCity
3366
+ onChange: onChangePlace
3427
3367
  });
3428
3368
  const recomendPlace = reactive({ ...place });
3429
3369
  const isElectedRef = computed(() => {
@@ -3466,30 +3406,19 @@ const useAmapRecomendPlace = (props) => {
3466
3406
  updateRecomandPlace,
3467
3407
  updatePlaceCandidates,
3468
3408
  updatePlace,
3469
- setPlace,
3470
- updateCity
3409
+ setPlace
3471
3410
  };
3472
3411
  };
3473
3412
  const useGmapRecomendPlace = (props) => {
3474
- const {
3475
- pointRef,
3476
- getRecomendPlace,
3477
- getLimit,
3478
- context: context2,
3479
- emptyPlaceName,
3480
- onChange,
3481
- onChangePlace,
3482
- onChangeCity
3483
- } = props;
3413
+ const { pointRef, getRecomendPlace, getLimit, context: context2, emptyPlaceName, onChange, onChangePlace } = props;
3484
3414
  const availableRef = ref(true);
3485
3415
  const placeCandidatesRef = ref([]);
3486
3416
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3487
3417
  const { readyPromise } = useMapSupplier();
3488
- const { place, updatePlace, setPlace, updateCity } = useGmapPlace({
3418
+ const { place, updatePlace, setPlace } = useGmapPlace({
3489
3419
  emptyPlaceName,
3490
3420
  pointRef,
3491
- onChange: onChangePlace,
3492
- onChangeCity
3421
+ onChange: onChangePlace
3493
3422
  });
3494
3423
  const recomendPlace = reactive({ ...place });
3495
3424
  const isElectedRef = computed(() => {
@@ -3532,8 +3461,7 @@ const useGmapRecomendPlace = (props) => {
3532
3461
  updateRecomandPlace,
3533
3462
  updatePlaceCandidates,
3534
3463
  updatePlace,
3535
- setPlace,
3536
- updateCity
3464
+ setPlace
3537
3465
  };
3538
3466
  };
3539
3467
  const useMapRecomendPlace = (props) => {
@@ -3969,7 +3897,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3969
3897
  centerPlace.lng = place.lng;
3970
3898
  centerPlace.lat = place.lat;
3971
3899
  centerPlace.name = place.name;
3972
- updateCity(place);
3900
+ emit("changePlace", {
3901
+ ...place
3902
+ });
3973
3903
  updatePlaceCandidates(place);
3974
3904
  await pipeDefer(setZoom)(READY_ZOOM);
3975
3905
  };
@@ -4031,7 +3961,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4031
3961
  });
4032
3962
  const {
4033
3963
  updatePlace,
4034
- updateCity,
4035
3964
  updateRecomandPlace,
4036
3965
  updatePlaceCandidates,
4037
3966
  placeCandidates,
@@ -4071,9 +4000,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4071
4000
  if (isFirstWorkflowRecomendLoadingRef.value)
4072
4001
  await pipeDefer(setZoom)(READY_ZOOM);
4073
4002
  completeFirstWorkflowRecomend();
4074
- },
4075
- onChangeCity: (value) => {
4076
- emit("changeCity", value);
4077
4003
  }
4078
4004
  });
4079
4005
  watchEffect(() => {
@@ -4639,6 +4565,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4639
4565
  distance,
4640
4566
  duration
4641
4567
  }) => {
4568
+ var _a;
4642
4569
  spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4643
4570
  return [h(DrivingLine, {
4644
4571
  "attrs": {
@@ -4646,7 +4573,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4646
4573
  }
4647
4574
  }), h(TaxiCar, {
4648
4575
  "attrs": {
4649
- "position": carPosition,
4576
+ "position": (_a = path[0]) != null ? _a : carPosition,
4650
4577
  "angle": angle,
4651
4578
  "title": renderTitle({
4652
4579
  distance,
@@ -4859,6 +4786,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4859
4786
  distance,
4860
4787
  duration
4861
4788
  }) => {
4789
+ var _a;
4862
4790
  spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4863
4791
  return [h(DrivingLine, {
4864
4792
  "attrs": {
@@ -4866,7 +4794,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4866
4794
  }
4867
4795
  }), h(TaxiCar, {
4868
4796
  "attrs": {
4869
- "position": carPosition,
4797
+ "position": (_a = path[0]) != null ? _a : carPosition,
4870
4798
  "angle": angle,
4871
4799
  "title": renderTitle({
4872
4800
  distance,
@@ -5187,193 +5115,6 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5187
5115
  )]);
5188
5116
  };
5189
5117
  }).props(["bookDispatchingTitle", "dispatchingTitle", "driverArrivedTitle", "driverStatus", "fallback", "from", "getDriverPosition", "interval", "loading", "mapRef", "renderInServiceTitle", "renderStartSerivceTitle", "to", "registerOverlay"]);
5190
- const useAmapAutoComplete = (props) => {
5191
- const { city } = props;
5192
- const cityRef = ref(city);
5193
- const { readyPromise } = useMapSupplier();
5194
- const { apiMapDistance } = useMapGeometry();
5195
- const { geoPosition } = useGeoLocation();
5196
- const keywordRef = ref("");
5197
- const autoCompletePlacesRef = ref([]);
5198
- const { update, idx: updateKey } = useUpdate();
5199
- const setCity = (value) => {
5200
- cityRef.value = value;
5201
- update();
5202
- };
5203
- const setKeyword = (value) => {
5204
- keywordRef.value = value;
5205
- update();
5206
- };
5207
- watch(
5208
- () => updateKey.value,
5209
- async () => {
5210
- if (!keywordRef.value)
5211
- return;
5212
- await readyPromise;
5213
- const amapPlaceSearch = new AMap.PlaceSearch({ city: cityRef.value.name });
5214
- amapPlaceSearch.search(keywordRef.value, (status, result) => {
5215
- const from = geoPosition.value;
5216
- switch (status) {
5217
- case "complete": {
5218
- autoCompletePlacesRef.value = result.poiList.pois.map(
5219
- (poi) => {
5220
- const { lat, lng } = poi.location;
5221
- return {
5222
- lat,
5223
- lng,
5224
- name: poi.name,
5225
- description: poi.address,
5226
- distance: from ? apiMapDistance(from, [lng, lat]) : void 0
5227
- };
5228
- }
5229
- );
5230
- return;
5231
- }
5232
- case "no_data":
5233
- autoCompletePlacesRef.value = [];
5234
- return;
5235
- default:
5236
- throw result;
5237
- }
5238
- });
5239
- },
5240
- {
5241
- immediate: true
5242
- }
5243
- );
5244
- return { setKeyword, setCity, autoCompletePlaces: autoCompletePlacesRef };
5245
- };
5246
- const useGmapAutoComplete = (props) => {
5247
- const { city } = props;
5248
- const cityRef = ref({ ...city });
5249
- const { readyPromise } = useMapSupplier();
5250
- const { apiMapDistance } = useMapGeometry();
5251
- const { geoPosition } = useGeoLocation();
5252
- const keywordRef = ref("");
5253
- const autoCompletePlacesRef = ref([]);
5254
- const { update, idx: updateKey } = useUpdate();
5255
- const setCity = (value) => {
5256
- cityRef.value = value;
5257
- update();
5258
- };
5259
- const setKeyword = (value) => {
5260
- keywordRef.value = value;
5261
- update();
5262
- };
5263
- const div = document.createElement("div");
5264
- watch(
5265
- () => updateKey.value,
5266
- async () => {
5267
- if (!keywordRef.value)
5268
- return;
5269
- await readyPromise;
5270
- const gmapPlacesService = new google.maps.places.PlacesService(div);
5271
- gmapPlacesService.textSearch(
5272
- {
5273
- query: keywordRef.value,
5274
- bounds: cityRef.value.bound
5275
- },
5276
- (result, status) => {
5277
- const from = geoPosition.value;
5278
- switch (status) {
5279
- case google.maps.places.PlacesServiceStatus.OK:
5280
- autoCompletePlacesRef.value = result.map(({ geometry, name, formatted_address }) => {
5281
- var _a, _b, _c, _d;
5282
- const lng = (_b = (_a = geometry == null ? void 0 : geometry.location) == null ? void 0 : _a.lng()) != null ? _b : 0;
5283
- const lat = (_d = (_c = geometry == null ? void 0 : geometry.location) == null ? void 0 : _c.lat()) != null ? _d : 0;
5284
- return {
5285
- lng,
5286
- lat,
5287
- name: name != null ? name : "",
5288
- description: formatted_address != null ? formatted_address : "",
5289
- distance: from ? apiMapDistance(from, [lng, lat]) : void 0
5290
- };
5291
- });
5292
- return;
5293
- case google.maps.places.PlacesServiceStatus.ZERO_RESULTS:
5294
- case google.maps.places.PlacesServiceStatus.NOT_FOUND:
5295
- autoCompletePlacesRef.value = [];
5296
- return;
5297
- }
5298
- }
5299
- );
5300
- }
5301
- );
5302
- return { setKeyword, setCity, autoCompletePlaces: autoCompletePlacesRef };
5303
- };
5304
- const useMapAutoComplete = (props) => {
5305
- const { supplier } = useMapSupplier();
5306
- return supplier === "gmap" ? useGmapAutoComplete(props) : useAmapAutoComplete(props);
5307
- };
5308
- const useAmapBoundCity = (props) => {
5309
- var _a;
5310
- const { cityNameRef, onChange } = props;
5311
- const city = reactive({ name: (_a = cityNameRef.value) != null ? _a : "" });
5312
- watch(
5313
- () => cityNameRef.value,
5314
- (cityName) => {
5315
- const name = cityName != null ? cityName : "";
5316
- city.name = name;
5317
- onChange == null ? void 0 : onChange({ name });
5318
- }
5319
- );
5320
- return city;
5321
- };
5322
- const useGmapBoundCity = (props) => {
5323
- var _a;
5324
- const { cityNameRef, onChange } = props;
5325
- const { readyPromise } = useMapSupplier();
5326
- const city = reactive({
5327
- name: (_a = cityNameRef.value) != null ? _a : "",
5328
- bound: {
5329
- east: 0,
5330
- north: 0,
5331
- south: 0,
5332
- west: 0
5333
- }
5334
- });
5335
- watchEffect(async () => {
5336
- var _a2, _b;
5337
- const cityName = cityNameRef.value;
5338
- if (!cityName)
5339
- return;
5340
- await readyPromise;
5341
- const geocoder = new google.maps.Geocoder();
5342
- const { results } = await geocoder.geocode({
5343
- address: cityName,
5344
- componentRestrictions: {
5345
- administrativeArea: "administrative_area_level_1"
5346
- },
5347
- language: LANGUAGE
5348
- });
5349
- if (results.length !== 1) {
5350
- throw new Error("MyError: multiple city found");
5351
- }
5352
- const { geometry } = results[0];
5353
- const cityBound = (_b = (_a2 = geometry.bounds) == null ? void 0 : _a2.toJSON()) != null ? _b : geometry.viewport.toJSON();
5354
- city.name = cityName;
5355
- city.bound = cityBound;
5356
- onChange == null ? void 0 : onChange({ name: cityName, bound: cityBound });
5357
- });
5358
- return city;
5359
- };
5360
- const useMapBoundCity = (props) => {
5361
- const { supplier } = useMapSupplier();
5362
- return supplier === "gmap" ? useGmapBoundCity(props) : useAmapBoundCity(props);
5363
- };
5364
- const useBusinessMapAutoComplete = (props) => {
5365
- const { cityNameRef } = props;
5366
- const city = useMapBoundCity({
5367
- cityNameRef,
5368
- onChange: (v) => setCity(v)
5369
- });
5370
- const { autoCompletePlaces, setKeyword, setCity } = useMapAutoComplete({ city });
5371
- const handleKeywordInput = (e) => {
5372
- const target = e.target;
5373
- setKeyword(target.value);
5374
- };
5375
- return { autoCompletePlaces, setKeyword, setCity, handleKeywordInput };
5376
- };
5377
5118
  const useBusinessQuotingMap = () => {
5378
5119
  const { setMap, mapRef } = useHeycarMap();
5379
5120
  const { registerFitVeiw, setFitView } = useMapFitView({
@@ -5443,7 +5184,6 @@ export {
5443
5184
  WalkingLine,
5444
5185
  WalkingRoute,
5445
5186
  WaveCircle,
5446
- useBusinessMapAutoComplete,
5447
5187
  useBusinessQuotingMap,
5448
5188
  useBusinessRecomendPlaceMap,
5449
5189
  useBusinessTaxiServiceMap,
@@ -6,23 +6,6 @@ export type Place = {
6
6
  lng: number;
7
7
  lat: number;
8
8
  name: string;
9
- cityName?: string;
10
- cityParentName?: string;
11
- countryName?: string;
12
- };
13
- export interface AutoCompletePlace extends Place {
14
- placeId?: string;
15
- description: string;
16
- distance?: number;
17
- }
18
- export type Region = {
19
- bound?: {
20
- east: number;
21
- north: number;
22
- south: number;
23
- west: number;
24
- };
25
- name: string;
26
9
  };
27
10
  export interface RegisterOverlay<T> {
28
11
  add: (overlay: T) => void;
@@ -14,6 +14,5 @@ export declare const place2point: (place: Place) => Point;
14
14
  export declare const pipeAsync: <P extends any[]>(fn?: ((...args: P) => any) | undefined) => (...args: P) => void;
15
15
  export declare const pipeDefer: <P extends any[], R>(fn: (...args: P) => R) => (...args: P) => Promise<R>;
16
16
  export declare const pipeOnlyLastEffect: <P extends any[], R>(fn: (...arg: P) => Promise<R>) => (...args: P) => Promise<R>;
17
- export declare const geocoderResult2cityName: (value: google.maps.GeocoderResult) => string | undefined;
18
17
  export declare const isPlaceEqual: (p1: Place, p2?: Place) => boolean;
19
18
  export declare const isPointEqual: (p1: Point, p2?: Point) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.5.9",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
@@ -1,49 +0,0 @@
1
- import type { Region } from "../types/interface";
2
- export interface UseMapAutoCompleteProps {
3
- city: Region;
4
- }
5
- export declare const useAmapAutoComplete: (props: UseMapAutoCompleteProps) => {
6
- setKeyword: (value: string) => void;
7
- setCity: (value: Region) => void;
8
- autoCompletePlaces: import("vue-demi").Ref<{
9
- placeId?: string | undefined;
10
- description: string;
11
- distance?: number | undefined;
12
- lng: number;
13
- lat: number;
14
- name: string;
15
- cityName?: string | undefined;
16
- cityParentName?: string | undefined;
17
- countryName?: string | undefined;
18
- }[]>;
19
- };
20
- export declare const useGmapAutoComplete: (props: UseMapAutoCompleteProps) => {
21
- setKeyword: (value: string) => void;
22
- setCity: (value: Region) => void;
23
- autoCompletePlaces: import("vue-demi").Ref<{
24
- placeId?: string | undefined;
25
- description: string;
26
- distance?: number | undefined;
27
- lng: number;
28
- lat: number;
29
- name: string;
30
- cityName?: string | undefined;
31
- cityParentName?: string | undefined;
32
- countryName?: string | undefined;
33
- }[]>;
34
- };
35
- export declare const useMapAutoComplete: (props: UseMapAutoCompleteProps) => {
36
- setKeyword: (value: string) => void;
37
- setCity: (value: Region) => void;
38
- autoCompletePlaces: import("vue-demi").Ref<{
39
- placeId?: string | undefined;
40
- description: string;
41
- distance?: number | undefined;
42
- lng: number;
43
- lat: number;
44
- name: string;
45
- cityName?: string | undefined;
46
- cityParentName?: string | undefined;
47
- countryName?: string | undefined;
48
- }[]>;
49
- };
@@ -1,9 +0,0 @@
1
- import { Ref } from "vue-demi";
2
- import type { Region } from "../types/interface";
3
- export interface UseMapCityBoundProps {
4
- cityNameRef: Ref<string | undefined>;
5
- onChange?: (value: Region) => any;
6
- }
7
- export declare const useAmapBoundCity: (props: UseMapCityBoundProps) => Region;
8
- export declare const useGmapBoundCity: (props: UseMapCityBoundProps) => Region;
9
- export declare const useMapBoundCity: (props: UseMapCityBoundProps) => Region;
@@ -1,20 +0,0 @@
1
- import type { Ref } from "vue-demi";
2
- export interface UseBusinessMapAutoCompleteProps {
3
- cityNameRef: Ref<string>;
4
- }
5
- export declare const useBusinessMapAutoComplete: (props: UseBusinessMapAutoCompleteProps) => {
6
- autoCompletePlaces: Ref<{
7
- placeId?: string | undefined;
8
- description: string;
9
- distance?: number | undefined;
10
- lng: number;
11
- lat: number;
12
- name: string;
13
- cityName?: string | undefined;
14
- cityParentName?: string | undefined;
15
- countryName?: string | undefined;
16
- }[]>;
17
- setKeyword: (value: string) => void;
18
- setCity: (value: import("..").Region) => void;
19
- handleKeywordInput: (e: Event) => void;
20
- };