@heycar/heycars-map 0.5.4 → 0.5.6

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.
@@ -2052,5 +2052,8 @@ export declare const DemoBusinessTaxiService: import("vue").DefineComponent<Read
2052
2052
  status: DriverStatus;
2053
2053
  contentHeight: number;
2054
2054
  }, {}, {
2055
- getDriverPosition(): Promise<Point>;
2055
+ getDriverPosition(): Promise<{
2056
+ position: Point;
2057
+ angle: number;
2058
+ }>;
2056
2059
  }, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<Readonly<{}>>>, {}>;
@@ -18,6 +18,9 @@ export type BusinessTaxiServiceMapProps = Omit<HeycarMapProps, "center" | "zoom"
18
18
  distance: number;
19
19
  duration: number;
20
20
  }) => string;
21
- getDriverPosition: () => Promise<Point>;
21
+ getDriverPosition: () => Promise<{
22
+ position: Point;
23
+ angle?: number;
24
+ }>;
22
25
  };
23
26
  export declare const BusinessTaxiServiceMap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<BusinessTaxiServiceMapProps>, 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<BusinessTaxiServiceMapProps, Required<BusinessTaxiServiceMapProps>>, "resize" | "dragEnd" | "zoomEnd", BusinessTaxiServiceMapProps, {} | {}>;
@@ -15,6 +15,7 @@ export declare const SectionConfirmed: import("vue").DefineComponent<import("vue
15
15
  type SectionDriverStartServiceProps = Required<MROP> & {
16
16
  passengerPosition?: Point;
17
17
  carPosition?: Point;
18
+ carAngle?: number;
18
19
  from: Place;
19
20
  renderTitle: (props: Pick<DrivingRouteRenderProps, "duration" | "distance">) => string;
20
21
  };
@@ -28,6 +29,7 @@ export declare const SectionBookDispatched: import("vue").DefineComponent<import
28
29
  type SectionDriverArrivedProps = Required<MROP> & {
29
30
  from: Place;
30
31
  carPosition?: Point;
32
+ carAngle?: number;
31
33
  passengerPosition?: Point;
32
34
  title: string;
33
35
  };
@@ -35,6 +37,7 @@ export declare const SectionDriverArrived: import("vue").DefineComponent<import(
35
37
  type SectionInServiceProps = Required<MROP> & {
36
38
  to: Place;
37
39
  carPosition?: Point;
40
+ carAngle?: number;
38
41
  renderTitle: (props: Pick<DrivingRouteRenderProps, "duration" | "distance">) => string;
39
42
  };
40
43
  export declare const SectionInService: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<SectionInServiceProps>, 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<SectionInServiceProps, Required<SectionInServiceProps>>, never, SectionInServiceProps, {} | {}>;
@@ -0,0 +1,10 @@
1
+ import type { Point } from "../types/interface";
2
+ interface UseDrivingTrackCorrectionProps {
3
+ track: Point[];
4
+ path: Point[];
5
+ onDeviation: (point: Point) => any;
6
+ }
7
+ export declare const useDrivingTrackCorrection: (props: UseDrivingTrackCorrectionProps) => {
8
+ path: import("vue").Ref<[number, number][]>;
9
+ };
10
+ export {};
@@ -1,10 +1,13 @@
1
1
  import type { Point } from "../types/interface";
2
2
  export declare const useAmapGeometry: () => {
3
3
  apiMapDistance: (from: Point, to: Point) => number | undefined;
4
+ apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
4
5
  };
5
6
  export declare const useGmapGeometry: () => {
6
7
  apiMapDistance: (from: Point, to: Point) => number | undefined;
8
+ apiMapDistanceToLine: (from: Point, line: Point[]) => 0 | undefined;
7
9
  };
8
10
  export declare const useMapGeometry: () => {
9
11
  apiMapDistance: (from: Point, to: Point) => number | undefined;
12
+ apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
10
13
  };
package/dist/index.cjs CHANGED
@@ -2425,7 +2425,8 @@ const amapComputeHeading = (from, to, map) => {
2425
2425
  const { x: xFrom, y: yFrom } = map.lngLatToContainer(from);
2426
2426
  const { x: xTo, y: yTo } = map.lngLatToContainer(to);
2427
2427
  const theta = Math.atan2(yFrom - yTo, xTo - xFrom);
2428
- return (Math.PI / 2 - theta) / Math.PI * 180;
2428
+ const signedAngle = (Math.PI / 2 - theta) / Math.PI * 180;
2429
+ return signedAngle < 0 ? 360 + signedAngle : signedAngle;
2429
2430
  };
2430
2431
  const useAmapAngle = (props) => {
2431
2432
  return Vue.computed(() => {
@@ -2548,11 +2549,20 @@ const useAmapFitView = (props) => {
2548
2549
  },
2549
2550
  setFitView
2550
2551
  };
2551
- const handleMoveEndOrZomEnd = () => {
2552
+ const handleDraggingOrZoomChange = () => {
2553
+ if (!autoFitTimeout || !timer)
2554
+ return;
2555
+ clearTimeout(timer);
2556
+ timer = void 0;
2557
+ };
2558
+ const handleMoveEndOrZomEnd = (eventName) => {
2559
+ spaceLog("useAmapFitViewHandleMoveEndOrZomEnd", "eventName = ", eventName);
2552
2560
  if (!autoFitTimeout)
2553
2561
  return;
2554
- if (timer)
2562
+ if (timer) {
2555
2563
  clearTimeout(timer);
2564
+ timer = void 0;
2565
+ }
2556
2566
  timer = setTimeout(() => {
2557
2567
  timer = void 0;
2558
2568
  setFitView();
@@ -2562,7 +2572,13 @@ const useAmapFitView = (props) => {
2562
2572
  mapRef,
2563
2573
  {},
2564
2574
  handleMoveEndOrZomEnd,
2565
- ["onDragEnd"]
2575
+ ["onDragEnd", "onZoomEnd"]
2576
+ );
2577
+ watchPostEffectForAMapEvent(
2578
+ mapRef,
2579
+ {},
2580
+ handleDraggingOrZoomChange,
2581
+ ["onDragging", "onZoomchange"]
2566
2582
  );
2567
2583
  return { registerFitVeiw, setFitView };
2568
2584
  };
@@ -2607,6 +2623,12 @@ const useGmapFitView = (props) => {
2607
2623
  },
2608
2624
  setFitView
2609
2625
  };
2626
+ const handleDrag = () => {
2627
+ if (!autoFitTimeout || !timer)
2628
+ return;
2629
+ clearTimeout(timer);
2630
+ timer = void 0;
2631
+ };
2610
2632
  const handleMoveEnd = () => {
2611
2633
  const eventSource = getMapEvnetSource();
2612
2634
  if (!autoFitTimeout || eventSource !== "user")
@@ -2625,6 +2647,9 @@ const useGmapFitView = (props) => {
2625
2647
  watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
2626
2648
  "onZoom_changed"
2627
2649
  ]);
2650
+ watchPostEffectForGMapEvent(mapRef, {}, handleDrag, [
2651
+ "onDrag"
2652
+ ]);
2628
2653
  return { registerFitVeiw, setFitView };
2629
2654
  };
2630
2655
  const useMapFitView = (props) => {
@@ -2955,6 +2980,16 @@ const isPlace = (place) => {
2955
2980
  return place.lng !== void 0 && place.lat !== void 0;
2956
2981
  };
2957
2982
  const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
2983
+ const assertPoint = (point) => {
2984
+ if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
2985
+ return;
2986
+ throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
2987
+ };
2988
+ const assertAngle = (angle) => {
2989
+ if (typeof angle === "number" || typeof angle === "undefined")
2990
+ return;
2991
+ throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
2992
+ };
2958
2993
  class SingleGeoWatch {
2959
2994
  constructor(option) {
2960
2995
  __publicField(this, "id", 0);
@@ -3858,7 +3893,8 @@ const DEFAULT_PLACE_NAME = "当前位置";
3858
3893
  const DEFAULT_ZOOM = 8;
3859
3894
  const READY_ZOOM = 17;
3860
3895
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
3861
- emit
3896
+ emit,
3897
+ slots
3862
3898
  }) {
3863
3899
  var _a, _b;
3864
3900
  const {
@@ -4041,7 +4077,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4041
4077
  "center": centerPoint.value,
4042
4078
  "zoom": zoomRef.value,
4043
4079
  "touchZoomCenter": true,
4044
- "mapRef": setMap
4080
+ "mapRef": setMap,
4081
+ "fallback": slots.fallback,
4082
+ "loading": slots.loading
4045
4083
  }
4046
4084
  }, [!geoLoading.value && !geoError.value && Vue.h(PassengerCircle, {
4047
4085
  "attrs": {
@@ -4074,7 +4112,12 @@ const useAmapGeometry = () => {
4074
4112
  return void 0;
4075
4113
  return AMap.GeometryUtil.distance(from, to);
4076
4114
  };
4077
- return { apiMapDistance };
4115
+ const apiMapDistanceToLine = (from, line) => {
4116
+ if (payload.status !== Status.SUCCESS)
4117
+ return void 0;
4118
+ return AMap.GeometryUtil.distanceToLine(from, line);
4119
+ };
4120
+ return { apiMapDistance, apiMapDistanceToLine };
4078
4121
  };
4079
4122
  const useGmapGeometry = () => {
4080
4123
  const payload = useMapSupplier();
@@ -4083,7 +4126,12 @@ const useGmapGeometry = () => {
4083
4126
  return void 0;
4084
4127
  return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
4085
4128
  };
4086
- return { apiMapDistance };
4129
+ const apiMapDistanceToLine = (from, line) => {
4130
+ if (payload.status !== Status.SUCCESS)
4131
+ return void 0;
4132
+ return 0;
4133
+ };
4134
+ return { apiMapDistance, apiMapDistanceToLine };
4087
4135
  };
4088
4136
  const useMapGeometry = () => {
4089
4137
  const { supplier } = useMapSupplier();
@@ -4535,6 +4583,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4535
4583
  const {
4536
4584
  from: fromPlace,
4537
4585
  carPosition,
4586
+ carAngle,
4538
4587
  passengerPosition,
4539
4588
  renderTitle,
4540
4589
  registerOverlay
@@ -4566,31 +4615,37 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4566
4615
  "to": from,
4567
4616
  "render": ({
4568
4617
  path,
4618
+ angle,
4569
4619
  distance,
4570
4620
  duration
4571
- }) => [Vue.h(DrivingLine, {
4572
- "attrs": {
4573
- "path": path
4574
- }
4575
- }), Vue.h(TaxiCar, {
4576
- "attrs": {
4577
- "position": carPosition,
4578
- "title": renderTitle({
4579
- distance,
4580
- duration
4581
- }),
4582
- "registerOverlay": registerOverlay
4583
- }
4584
- }), Vue.h(KeyedFitView, {
4585
- "attrs": {
4586
- "registerOverlay": registerOverlay,
4587
- "fitViewKey": JSON.stringify(carPosition)
4588
- }
4589
- })]
4621
+ }) => {
4622
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4623
+ return [Vue.h(DrivingLine, {
4624
+ "attrs": {
4625
+ "path": path
4626
+ }
4627
+ }), Vue.h(TaxiCar, {
4628
+ "attrs": {
4629
+ "position": carPosition,
4630
+ "angle": angle,
4631
+ "title": renderTitle({
4632
+ distance,
4633
+ duration
4634
+ }),
4635
+ "registerOverlay": registerOverlay
4636
+ }
4637
+ }), Vue.h(KeyedFitView, {
4638
+ "attrs": {
4639
+ "registerOverlay": registerOverlay,
4640
+ "fitViewKey": JSON.stringify(carPosition)
4641
+ }
4642
+ })];
4643
+ }
4590
4644
  }
4591
4645
  }) : [Vue.h(TaxiCar, {
4592
4646
  "attrs": {
4593
4647
  "position": carPosition,
4648
+ "angle": carAngle,
4594
4649
  "title": renderTitle({
4595
4650
  distance: carDistance,
4596
4651
  duration: carDurationWithinMinDistance(carDistance)
@@ -4704,6 +4759,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4704
4759
  const {
4705
4760
  from: fromPlace,
4706
4761
  carPosition,
4762
+ carAngle,
4707
4763
  passengerPosition,
4708
4764
  title,
4709
4765
  registerOverlay
@@ -4731,6 +4787,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4731
4787
  }), !!carPosition && [Vue.h(TaxiCar, {
4732
4788
  "attrs": {
4733
4789
  "position": carPosition,
4790
+ "angle": carAngle,
4734
4791
  "title": title,
4735
4792
  "registerOverlay": registerOverlay
4736
4793
  }
@@ -4763,6 +4820,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4763
4820
  const {
4764
4821
  to: toPlace,
4765
4822
  carPosition,
4823
+ carAngle,
4766
4824
  renderTitle,
4767
4825
  registerOverlay
4768
4826
  } = props;
@@ -4777,31 +4835,37 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4777
4835
  "to": to,
4778
4836
  "render": ({
4779
4837
  path,
4838
+ angle,
4780
4839
  distance,
4781
4840
  duration
4782
- }) => [Vue.h(DrivingLine, {
4783
- "attrs": {
4784
- "path": path
4785
- }
4786
- }), Vue.h(TaxiCar, {
4787
- "attrs": {
4788
- "position": carPosition,
4789
- "title": renderTitle({
4790
- distance,
4791
- duration
4792
- }),
4793
- "registerOverlay": registerOverlay
4794
- }
4795
- }), Vue.h(KeyedFitView, {
4796
- "attrs": {
4797
- "registerOverlay": registerOverlay,
4798
- "fitViewKey": JSON.stringify(carPosition)
4799
- }
4800
- })]
4841
+ }) => {
4842
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4843
+ return [Vue.h(DrivingLine, {
4844
+ "attrs": {
4845
+ "path": path
4846
+ }
4847
+ }), Vue.h(TaxiCar, {
4848
+ "attrs": {
4849
+ "position": carPosition,
4850
+ "angle": angle,
4851
+ "title": renderTitle({
4852
+ distance,
4853
+ duration
4854
+ }),
4855
+ "registerOverlay": registerOverlay
4856
+ }
4857
+ }), Vue.h(KeyedFitView, {
4858
+ "attrs": {
4859
+ "registerOverlay": registerOverlay,
4860
+ "fitViewKey": JSON.stringify(carPosition)
4861
+ }
4862
+ })];
4863
+ }
4801
4864
  }
4802
4865
  }) : [Vue.h(TaxiCar, {
4803
4866
  "attrs": {
4804
4867
  "position": carPosition,
4868
+ "angle": carAngle,
4805
4869
  "title": renderTitle({
4806
4870
  distance: carDistance,
4807
4871
  duration: carDurationWithinMinDistance(carDistance)
@@ -4980,12 +5044,26 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
4980
5044
  geoError
4981
5045
  } = useGeoLocation();
4982
5046
  const carPositionRef = Vue.ref();
5047
+ const carAngleRef = Vue.ref();
5048
+ const {
5049
+ toGcj02
5050
+ } = useMapGCJ02();
4983
5051
  Vue.watch(() => props.driverStatus, (status, _, onCleanup) => {
4984
5052
  if (!STATUS_NEED_CAR_POSITION.includes(status))
4985
5053
  return;
4986
- const timer = setInterval(() => {
4987
- getDriverPosition().then((pos) => carPositionRef.value = pos);
4988
- }, interval);
5054
+ const update = () => {
5055
+ getDriverPosition().then(async ({
5056
+ position,
5057
+ angle
5058
+ }) => {
5059
+ assertPoint(position);
5060
+ assertAngle(angle);
5061
+ carPositionRef.value = position ? await toGcj02(position) : void 0;
5062
+ carAngleRef.value = angle;
5063
+ });
5064
+ };
5065
+ const timer = setInterval(update, interval);
5066
+ update();
4989
5067
  onCleanup(() => clearInterval(timer));
4990
5068
  }, {
4991
5069
  immediate: true
@@ -5000,6 +5078,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5000
5078
  driverArrivedTitle
5001
5079
  } = props;
5002
5080
  const carPosition = carPositionRef.value;
5081
+ const carAngle = carAngleRef.value;
5003
5082
  const touchEnable = !["canceled", "canceling", "completed", "endService", "waitpay", "waitRechargePay", "refund", "rechargePayed", "payed"].includes(driverStatus);
5004
5083
  const passengerPosition = geoError.value ? void 0 : geoPosition.value;
5005
5084
  return Vue.h(HeycarMap, {
@@ -5035,6 +5114,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5035
5114
  "attrs": {
5036
5115
  "from": from,
5037
5116
  "carPosition": carPosition,
5117
+ "carAngle": carAngle,
5038
5118
  "passengerPosition": passengerPosition,
5039
5119
  "renderTitle": renderStartSerivceTitle,
5040
5120
  "registerOverlay": registerOverlay
@@ -5050,6 +5130,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5050
5130
  "attrs": {
5051
5131
  "to": to,
5052
5132
  "carPosition": carPosition,
5133
+ "carAngle": carAngle,
5053
5134
  "renderTitle": renderInServiceTitle,
5054
5135
  "registerOverlay": registerOverlay
5055
5136
  }
@@ -5057,6 +5138,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5057
5138
  "attrs": {
5058
5139
  "from": from,
5059
5140
  "carPosition": carPosition,
5141
+ "carAngle": carAngle,
5060
5142
  "passengerPosition": passengerPosition,
5061
5143
  "title": driverArrivedTitle,
5062
5144
  "registerOverlay": registerOverlay
package/dist/index.js CHANGED
@@ -2423,7 +2423,8 @@ const amapComputeHeading = (from, to, map) => {
2423
2423
  const { x: xFrom, y: yFrom } = map.lngLatToContainer(from);
2424
2424
  const { x: xTo, y: yTo } = map.lngLatToContainer(to);
2425
2425
  const theta = Math.atan2(yFrom - yTo, xTo - xFrom);
2426
- return (Math.PI / 2 - theta) / Math.PI * 180;
2426
+ const signedAngle = (Math.PI / 2 - theta) / Math.PI * 180;
2427
+ return signedAngle < 0 ? 360 + signedAngle : signedAngle;
2427
2428
  };
2428
2429
  const useAmapAngle = (props) => {
2429
2430
  return computed(() => {
@@ -2546,11 +2547,20 @@ const useAmapFitView = (props) => {
2546
2547
  },
2547
2548
  setFitView
2548
2549
  };
2549
- const handleMoveEndOrZomEnd = () => {
2550
+ const handleDraggingOrZoomChange = () => {
2551
+ if (!autoFitTimeout || !timer)
2552
+ return;
2553
+ clearTimeout(timer);
2554
+ timer = void 0;
2555
+ };
2556
+ const handleMoveEndOrZomEnd = (eventName) => {
2557
+ spaceLog("useAmapFitViewHandleMoveEndOrZomEnd", "eventName = ", eventName);
2550
2558
  if (!autoFitTimeout)
2551
2559
  return;
2552
- if (timer)
2560
+ if (timer) {
2553
2561
  clearTimeout(timer);
2562
+ timer = void 0;
2563
+ }
2554
2564
  timer = setTimeout(() => {
2555
2565
  timer = void 0;
2556
2566
  setFitView();
@@ -2560,7 +2570,13 @@ const useAmapFitView = (props) => {
2560
2570
  mapRef,
2561
2571
  {},
2562
2572
  handleMoveEndOrZomEnd,
2563
- ["onDragEnd"]
2573
+ ["onDragEnd", "onZoomEnd"]
2574
+ );
2575
+ watchPostEffectForAMapEvent(
2576
+ mapRef,
2577
+ {},
2578
+ handleDraggingOrZoomChange,
2579
+ ["onDragging", "onZoomchange"]
2564
2580
  );
2565
2581
  return { registerFitVeiw, setFitView };
2566
2582
  };
@@ -2605,6 +2621,12 @@ const useGmapFitView = (props) => {
2605
2621
  },
2606
2622
  setFitView
2607
2623
  };
2624
+ const handleDrag = () => {
2625
+ if (!autoFitTimeout || !timer)
2626
+ return;
2627
+ clearTimeout(timer);
2628
+ timer = void 0;
2629
+ };
2608
2630
  const handleMoveEnd = () => {
2609
2631
  const eventSource = getMapEvnetSource();
2610
2632
  if (!autoFitTimeout || eventSource !== "user")
@@ -2623,6 +2645,9 @@ const useGmapFitView = (props) => {
2623
2645
  watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
2624
2646
  "onZoom_changed"
2625
2647
  ]);
2648
+ watchPostEffectForGMapEvent(mapRef, {}, handleDrag, [
2649
+ "onDrag"
2650
+ ]);
2626
2651
  return { registerFitVeiw, setFitView };
2627
2652
  };
2628
2653
  const useMapFitView = (props) => {
@@ -2953,6 +2978,16 @@ const isPlace = (place) => {
2953
2978
  return place.lng !== void 0 && place.lat !== void 0;
2954
2979
  };
2955
2980
  const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
2981
+ const assertPoint = (point) => {
2982
+ if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
2983
+ return;
2984
+ throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
2985
+ };
2986
+ const assertAngle = (angle) => {
2987
+ if (typeof angle === "number" || typeof angle === "undefined")
2988
+ return;
2989
+ throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
2990
+ };
2956
2991
  class SingleGeoWatch {
2957
2992
  constructor(option) {
2958
2993
  __publicField(this, "id", 0);
@@ -3856,7 +3891,8 @@ const DEFAULT_PLACE_NAME = "当前位置";
3856
3891
  const DEFAULT_ZOOM = 8;
3857
3892
  const READY_ZOOM = 17;
3858
3893
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
3859
- emit
3894
+ emit,
3895
+ slots
3860
3896
  }) {
3861
3897
  var _a, _b;
3862
3898
  const {
@@ -4039,7 +4075,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4039
4075
  "center": centerPoint.value,
4040
4076
  "zoom": zoomRef.value,
4041
4077
  "touchZoomCenter": true,
4042
- "mapRef": setMap
4078
+ "mapRef": setMap,
4079
+ "fallback": slots.fallback,
4080
+ "loading": slots.loading
4043
4081
  }
4044
4082
  }, [!geoLoading.value && !geoError.value && h(PassengerCircle, {
4045
4083
  "attrs": {
@@ -4072,7 +4110,12 @@ const useAmapGeometry = () => {
4072
4110
  return void 0;
4073
4111
  return AMap.GeometryUtil.distance(from, to);
4074
4112
  };
4075
- return { apiMapDistance };
4113
+ const apiMapDistanceToLine = (from, line) => {
4114
+ if (payload.status !== Status.SUCCESS)
4115
+ return void 0;
4116
+ return AMap.GeometryUtil.distanceToLine(from, line);
4117
+ };
4118
+ return { apiMapDistance, apiMapDistanceToLine };
4076
4119
  };
4077
4120
  const useGmapGeometry = () => {
4078
4121
  const payload = useMapSupplier();
@@ -4081,7 +4124,12 @@ const useGmapGeometry = () => {
4081
4124
  return void 0;
4082
4125
  return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
4083
4126
  };
4084
- return { apiMapDistance };
4127
+ const apiMapDistanceToLine = (from, line) => {
4128
+ if (payload.status !== Status.SUCCESS)
4129
+ return void 0;
4130
+ return 0;
4131
+ };
4132
+ return { apiMapDistance, apiMapDistanceToLine };
4085
4133
  };
4086
4134
  const useMapGeometry = () => {
4087
4135
  const { supplier } = useMapSupplier();
@@ -4533,6 +4581,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4533
4581
  const {
4534
4582
  from: fromPlace,
4535
4583
  carPosition,
4584
+ carAngle,
4536
4585
  passengerPosition,
4537
4586
  renderTitle,
4538
4587
  registerOverlay
@@ -4564,31 +4613,37 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4564
4613
  "to": from,
4565
4614
  "render": ({
4566
4615
  path,
4616
+ angle,
4567
4617
  distance,
4568
4618
  duration
4569
- }) => [h(DrivingLine, {
4570
- "attrs": {
4571
- "path": path
4572
- }
4573
- }), h(TaxiCar, {
4574
- "attrs": {
4575
- "position": carPosition,
4576
- "title": renderTitle({
4577
- distance,
4578
- duration
4579
- }),
4580
- "registerOverlay": registerOverlay
4581
- }
4582
- }), h(KeyedFitView, {
4583
- "attrs": {
4584
- "registerOverlay": registerOverlay,
4585
- "fitViewKey": JSON.stringify(carPosition)
4586
- }
4587
- })]
4619
+ }) => {
4620
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4621
+ return [h(DrivingLine, {
4622
+ "attrs": {
4623
+ "path": path
4624
+ }
4625
+ }), h(TaxiCar, {
4626
+ "attrs": {
4627
+ "position": carPosition,
4628
+ "angle": angle,
4629
+ "title": renderTitle({
4630
+ distance,
4631
+ duration
4632
+ }),
4633
+ "registerOverlay": registerOverlay
4634
+ }
4635
+ }), h(KeyedFitView, {
4636
+ "attrs": {
4637
+ "registerOverlay": registerOverlay,
4638
+ "fitViewKey": JSON.stringify(carPosition)
4639
+ }
4640
+ })];
4641
+ }
4588
4642
  }
4589
4643
  }) : [h(TaxiCar, {
4590
4644
  "attrs": {
4591
4645
  "position": carPosition,
4646
+ "angle": carAngle,
4592
4647
  "title": renderTitle({
4593
4648
  distance: carDistance,
4594
4649
  duration: carDurationWithinMinDistance(carDistance)
@@ -4702,6 +4757,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4702
4757
  const {
4703
4758
  from: fromPlace,
4704
4759
  carPosition,
4760
+ carAngle,
4705
4761
  passengerPosition,
4706
4762
  title,
4707
4763
  registerOverlay
@@ -4729,6 +4785,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4729
4785
  }), !!carPosition && [h(TaxiCar, {
4730
4786
  "attrs": {
4731
4787
  "position": carPosition,
4788
+ "angle": carAngle,
4732
4789
  "title": title,
4733
4790
  "registerOverlay": registerOverlay
4734
4791
  }
@@ -4761,6 +4818,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4761
4818
  const {
4762
4819
  to: toPlace,
4763
4820
  carPosition,
4821
+ carAngle,
4764
4822
  renderTitle,
4765
4823
  registerOverlay
4766
4824
  } = props;
@@ -4775,31 +4833,37 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4775
4833
  "to": to,
4776
4834
  "render": ({
4777
4835
  path,
4836
+ angle,
4778
4837
  distance,
4779
4838
  duration
4780
- }) => [h(DrivingLine, {
4781
- "attrs": {
4782
- "path": path
4783
- }
4784
- }), h(TaxiCar, {
4785
- "attrs": {
4786
- "position": carPosition,
4787
- "title": renderTitle({
4788
- distance,
4789
- duration
4790
- }),
4791
- "registerOverlay": registerOverlay
4792
- }
4793
- }), h(KeyedFitView, {
4794
- "attrs": {
4795
- "registerOverlay": registerOverlay,
4796
- "fitViewKey": JSON.stringify(carPosition)
4797
- }
4798
- })]
4839
+ }) => {
4840
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4841
+ return [h(DrivingLine, {
4842
+ "attrs": {
4843
+ "path": path
4844
+ }
4845
+ }), h(TaxiCar, {
4846
+ "attrs": {
4847
+ "position": carPosition,
4848
+ "angle": angle,
4849
+ "title": renderTitle({
4850
+ distance,
4851
+ duration
4852
+ }),
4853
+ "registerOverlay": registerOverlay
4854
+ }
4855
+ }), h(KeyedFitView, {
4856
+ "attrs": {
4857
+ "registerOverlay": registerOverlay,
4858
+ "fitViewKey": JSON.stringify(carPosition)
4859
+ }
4860
+ })];
4861
+ }
4799
4862
  }
4800
4863
  }) : [h(TaxiCar, {
4801
4864
  "attrs": {
4802
4865
  "position": carPosition,
4866
+ "angle": carAngle,
4803
4867
  "title": renderTitle({
4804
4868
  distance: carDistance,
4805
4869
  duration: carDurationWithinMinDistance(carDistance)
@@ -4978,12 +5042,26 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
4978
5042
  geoError
4979
5043
  } = useGeoLocation();
4980
5044
  const carPositionRef = ref();
5045
+ const carAngleRef = ref();
5046
+ const {
5047
+ toGcj02
5048
+ } = useMapGCJ02();
4981
5049
  watch(() => props.driverStatus, (status, _, onCleanup) => {
4982
5050
  if (!STATUS_NEED_CAR_POSITION.includes(status))
4983
5051
  return;
4984
- const timer = setInterval(() => {
4985
- getDriverPosition().then((pos) => carPositionRef.value = pos);
4986
- }, interval);
5052
+ const update = () => {
5053
+ getDriverPosition().then(async ({
5054
+ position,
5055
+ angle
5056
+ }) => {
5057
+ assertPoint(position);
5058
+ assertAngle(angle);
5059
+ carPositionRef.value = position ? await toGcj02(position) : void 0;
5060
+ carAngleRef.value = angle;
5061
+ });
5062
+ };
5063
+ const timer = setInterval(update, interval);
5064
+ update();
4987
5065
  onCleanup(() => clearInterval(timer));
4988
5066
  }, {
4989
5067
  immediate: true
@@ -4998,6 +5076,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
4998
5076
  driverArrivedTitle
4999
5077
  } = props;
5000
5078
  const carPosition = carPositionRef.value;
5079
+ const carAngle = carAngleRef.value;
5001
5080
  const touchEnable = !["canceled", "canceling", "completed", "endService", "waitpay", "waitRechargePay", "refund", "rechargePayed", "payed"].includes(driverStatus);
5002
5081
  const passengerPosition = geoError.value ? void 0 : geoPosition.value;
5003
5082
  return h(HeycarMap, {
@@ -5033,6 +5112,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5033
5112
  "attrs": {
5034
5113
  "from": from,
5035
5114
  "carPosition": carPosition,
5115
+ "carAngle": carAngle,
5036
5116
  "passengerPosition": passengerPosition,
5037
5117
  "renderTitle": renderStartSerivceTitle,
5038
5118
  "registerOverlay": registerOverlay
@@ -5048,6 +5128,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5048
5128
  "attrs": {
5049
5129
  "to": to,
5050
5130
  "carPosition": carPosition,
5131
+ "carAngle": carAngle,
5051
5132
  "renderTitle": renderInServiceTitle,
5052
5133
  "registerOverlay": registerOverlay
5053
5134
  }
@@ -5055,6 +5136,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5055
5136
  "attrs": {
5056
5137
  "from": from,
5057
5138
  "carPosition": carPosition,
5139
+ "carAngle": carAngle,
5058
5140
  "passengerPosition": passengerPosition,
5059
5141
  "title": driverArrivedTitle,
5060
5142
  "registerOverlay": registerOverlay
@@ -1,3 +1,5 @@
1
1
  import type { Place } from "../types/interface";
2
2
  export declare const isPlace: (place: Partial<Place>) => place is Place;
3
3
  export declare const sleep: (milliSeconds: number) => Promise<unknown>;
4
+ export declare const assertPoint: (point: unknown) => void;
5
+ export declare const assertAngle: (angle: unknown) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
package/todo.md CHANGED
@@ -2,10 +2,8 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
2
2
 
3
3
  2. Google 地址名称太长
4
4
  3. 高德地图加载期间出现大量的请求
5
- 4. 做完其他事情进入首页,变成了获取定位失败,但其实 gps ok 的,因为刷新页面是有点位的
6
- 5. map 的两个 slot loading 和 error slot 没有生效
7
- 6. 企业微信如果关闭定位,会不停的跳 geoError 事件
8
- 7. 司机已接单页面,title 倒计时, 1s 更新一次 title,引起 walking 接口 1s 触发
5
+ 4. map 的两个 slot loading 和 error slot 没有生效
6
+ 5. 企业微信如果关闭定位,会不停的跳 geoError 事件
9
7
 
10
8
  缩放问题
11
9
 
@@ -94,3 +92,8 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
94
92
 
95
93
  - 5375
96
94
  - 4946
95
+
96
+ 0.5.5
97
+
98
+ - 4977
99
+ - 5381