@heycar/heycars-map 0.5.3 → 0.5.5

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, {} | {}>;
package/dist/index.cjs CHANGED
@@ -2327,7 +2327,10 @@ const useADrivingRoute = (props) => {
2327
2327
  const outputRoute = Vue.reactive({ path: [], distance: 0, duration: 0 });
2328
2328
  const amapDriving = new AMap.Driving({});
2329
2329
  watchPostEffectForDeepOption(
2330
- () => ({ ...props }),
2330
+ () => {
2331
+ const { from, to } = props;
2332
+ return { from, to };
2333
+ },
2331
2334
  ({ from, to }) => {
2332
2335
  amapDriving.search(
2333
2336
  AMap.LngLat.from(from),
@@ -2422,7 +2425,8 @@ const amapComputeHeading = (from, to, map) => {
2422
2425
  const { x: xFrom, y: yFrom } = map.lngLatToContainer(from);
2423
2426
  const { x: xTo, y: yTo } = map.lngLatToContainer(to);
2424
2427
  const theta = Math.atan2(yFrom - yTo, xTo - xFrom);
2425
- 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;
2426
2430
  };
2427
2431
  const useAmapAngle = (props) => {
2428
2432
  return Vue.computed(() => {
@@ -2952,6 +2956,16 @@ const isPlace = (place) => {
2952
2956
  return place.lng !== void 0 && place.lat !== void 0;
2953
2957
  };
2954
2958
  const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
2959
+ const assertPoint = (point) => {
2960
+ if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
2961
+ return;
2962
+ throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
2963
+ };
2964
+ const assertAngle = (angle) => {
2965
+ if (typeof angle === "number" || typeof angle === "undefined")
2966
+ return;
2967
+ throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
2968
+ };
2955
2969
  class SingleGeoWatch {
2956
2970
  constructor(option) {
2957
2971
  __publicField(this, "id", 0);
@@ -3855,7 +3869,8 @@ const DEFAULT_PLACE_NAME = "当前位置";
3855
3869
  const DEFAULT_ZOOM = 8;
3856
3870
  const READY_ZOOM = 17;
3857
3871
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
3858
- emit
3872
+ emit,
3873
+ slots
3859
3874
  }) {
3860
3875
  var _a, _b;
3861
3876
  const {
@@ -4038,7 +4053,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4038
4053
  "center": centerPoint.value,
4039
4054
  "zoom": zoomRef.value,
4040
4055
  "touchZoomCenter": true,
4041
- "mapRef": setMap
4056
+ "mapRef": setMap,
4057
+ "fallback": slots.fallback,
4058
+ "loading": slots.loading
4042
4059
  }
4043
4060
  }, [!geoLoading.value && !geoError.value && Vue.h(PassengerCircle, {
4044
4061
  "attrs": {
@@ -4128,7 +4145,7 @@ const ATaxiCar = defineSetup(function ATaxiCar2(props) {
4128
4145
  "registerOverlay": props.registerOverlay,
4129
4146
  "zIndex": ZINDEX_CAR_LAYER
4130
4147
  }
4131
- }), Vue.h(AmapMarker, {
4148
+ }), !!contentRef.value.box && Vue.h(AmapMarker, {
4132
4149
  "attrs": {
4133
4150
  "position": props.position,
4134
4151
  "content": contentRef.value.box,
@@ -4176,7 +4193,7 @@ const GTaxiCar = defineSetup(function GTaxiCar2(props) {
4176
4193
  "registerOverlay": props.registerOverlay,
4177
4194
  "zIndex": ZINDEX_CAR_LAYER
4178
4195
  }
4179
- }), Vue.h(GmapAdvancedMarkerView, {
4196
+ }), !!contentRef.value.box && Vue.h(GmapAdvancedMarkerView, {
4180
4197
  "attrs": {
4181
4198
  "position": vec2lnglat(props.position),
4182
4199
  "content": contentRef.value.box,
@@ -4265,7 +4282,10 @@ const useAWalkingRoute = (props) => {
4265
4282
  const pathRef = Vue.shallowRef([]);
4266
4283
  const amapWalking = new AMap.Walking({});
4267
4284
  watchPostEffectForDeepOption(
4268
- () => ({ ...props }),
4285
+ () => {
4286
+ const { from, to } = props;
4287
+ return { from, to };
4288
+ },
4269
4289
  ({ from, to }) => {
4270
4290
  amapWalking.search(AMap.LngLat.from(from), AMap.LngLat.from(to), (status, result) => {
4271
4291
  switch (status) {
@@ -4529,6 +4549,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4529
4549
  const {
4530
4550
  from: fromPlace,
4531
4551
  carPosition,
4552
+ carAngle,
4532
4553
  passengerPosition,
4533
4554
  renderTitle,
4534
4555
  registerOverlay
@@ -4560,31 +4581,37 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4560
4581
  "to": from,
4561
4582
  "render": ({
4562
4583
  path,
4584
+ angle,
4563
4585
  distance,
4564
4586
  duration
4565
- }) => [Vue.h(DrivingLine, {
4566
- "attrs": {
4567
- "path": path
4568
- }
4569
- }), Vue.h(TaxiCar, {
4570
- "attrs": {
4571
- "position": carPosition,
4572
- "title": renderTitle({
4573
- distance,
4574
- duration
4575
- }),
4576
- "registerOverlay": registerOverlay
4577
- }
4578
- }), Vue.h(KeyedFitView, {
4579
- "attrs": {
4580
- "registerOverlay": registerOverlay,
4581
- "fitViewKey": JSON.stringify(carPosition)
4582
- }
4583
- })]
4587
+ }) => {
4588
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4589
+ return [Vue.h(DrivingLine, {
4590
+ "attrs": {
4591
+ "path": path
4592
+ }
4593
+ }), Vue.h(TaxiCar, {
4594
+ "attrs": {
4595
+ "position": carPosition,
4596
+ "angle": angle,
4597
+ "title": renderTitle({
4598
+ distance,
4599
+ duration
4600
+ }),
4601
+ "registerOverlay": registerOverlay
4602
+ }
4603
+ }), Vue.h(KeyedFitView, {
4604
+ "attrs": {
4605
+ "registerOverlay": registerOverlay,
4606
+ "fitViewKey": JSON.stringify(carPosition)
4607
+ }
4608
+ })];
4609
+ }
4584
4610
  }
4585
4611
  }) : [Vue.h(TaxiCar, {
4586
4612
  "attrs": {
4587
4613
  "position": carPosition,
4614
+ "angle": carAngle,
4588
4615
  "title": renderTitle({
4589
4616
  distance: carDistance,
4590
4617
  duration: carDurationWithinMinDistance(carDistance)
@@ -4698,6 +4725,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4698
4725
  const {
4699
4726
  from: fromPlace,
4700
4727
  carPosition,
4728
+ carAngle,
4701
4729
  passengerPosition,
4702
4730
  title,
4703
4731
  registerOverlay
@@ -4725,6 +4753,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4725
4753
  }), !!carPosition && [Vue.h(TaxiCar, {
4726
4754
  "attrs": {
4727
4755
  "position": carPosition,
4756
+ "angle": carAngle,
4728
4757
  "title": title,
4729
4758
  "registerOverlay": registerOverlay
4730
4759
  }
@@ -4757,6 +4786,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4757
4786
  const {
4758
4787
  to: toPlace,
4759
4788
  carPosition,
4789
+ carAngle,
4760
4790
  renderTitle,
4761
4791
  registerOverlay
4762
4792
  } = props;
@@ -4771,31 +4801,37 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4771
4801
  "to": to,
4772
4802
  "render": ({
4773
4803
  path,
4804
+ angle,
4774
4805
  distance,
4775
4806
  duration
4776
- }) => [Vue.h(DrivingLine, {
4777
- "attrs": {
4778
- "path": path
4779
- }
4780
- }), Vue.h(TaxiCar, {
4781
- "attrs": {
4782
- "position": carPosition,
4783
- "title": renderTitle({
4784
- distance,
4785
- duration
4786
- }),
4787
- "registerOverlay": registerOverlay
4788
- }
4789
- }), Vue.h(KeyedFitView, {
4790
- "attrs": {
4791
- "registerOverlay": registerOverlay,
4792
- "fitViewKey": JSON.stringify(carPosition)
4793
- }
4794
- })]
4807
+ }) => {
4808
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4809
+ return [Vue.h(DrivingLine, {
4810
+ "attrs": {
4811
+ "path": path
4812
+ }
4813
+ }), Vue.h(TaxiCar, {
4814
+ "attrs": {
4815
+ "position": carPosition,
4816
+ "angle": angle,
4817
+ "title": renderTitle({
4818
+ distance,
4819
+ duration
4820
+ }),
4821
+ "registerOverlay": registerOverlay
4822
+ }
4823
+ }), Vue.h(KeyedFitView, {
4824
+ "attrs": {
4825
+ "registerOverlay": registerOverlay,
4826
+ "fitViewKey": JSON.stringify(carPosition)
4827
+ }
4828
+ })];
4829
+ }
4795
4830
  }
4796
4831
  }) : [Vue.h(TaxiCar, {
4797
4832
  "attrs": {
4798
4833
  "position": carPosition,
4834
+ "angle": carAngle,
4799
4835
  "title": renderTitle({
4800
4836
  distance: carDistance,
4801
4837
  duration: carDurationWithinMinDistance(carDistance)
@@ -4974,12 +5010,26 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
4974
5010
  geoError
4975
5011
  } = useGeoLocation();
4976
5012
  const carPositionRef = Vue.ref();
5013
+ const carAngleRef = Vue.ref();
5014
+ const {
5015
+ toGcj02
5016
+ } = useMapGCJ02();
4977
5017
  Vue.watch(() => props.driverStatus, (status, _, onCleanup) => {
4978
5018
  if (!STATUS_NEED_CAR_POSITION.includes(status))
4979
5019
  return;
4980
- const timer = setInterval(() => {
4981
- getDriverPosition().then((pos) => carPositionRef.value = pos);
4982
- }, interval);
5020
+ const update = () => {
5021
+ getDriverPosition().then(async ({
5022
+ position,
5023
+ angle
5024
+ }) => {
5025
+ assertPoint(position);
5026
+ assertAngle(angle);
5027
+ carPositionRef.value = position ? await toGcj02(position) : void 0;
5028
+ carAngleRef.value = angle;
5029
+ });
5030
+ };
5031
+ const timer = setInterval(update, interval);
5032
+ update();
4983
5033
  onCleanup(() => clearInterval(timer));
4984
5034
  }, {
4985
5035
  immediate: true
@@ -4994,6 +5044,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
4994
5044
  driverArrivedTitle
4995
5045
  } = props;
4996
5046
  const carPosition = carPositionRef.value;
5047
+ const carAngle = carAngleRef.value;
4997
5048
  const touchEnable = !["canceled", "canceling", "completed", "endService", "waitpay", "waitRechargePay", "refund", "rechargePayed", "payed"].includes(driverStatus);
4998
5049
  const passengerPosition = geoError.value ? void 0 : geoPosition.value;
4999
5050
  return Vue.h(HeycarMap, {
@@ -5029,6 +5080,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5029
5080
  "attrs": {
5030
5081
  "from": from,
5031
5082
  "carPosition": carPosition,
5083
+ "carAngle": carAngle,
5032
5084
  "passengerPosition": passengerPosition,
5033
5085
  "renderTitle": renderStartSerivceTitle,
5034
5086
  "registerOverlay": registerOverlay
@@ -5044,6 +5096,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5044
5096
  "attrs": {
5045
5097
  "to": to,
5046
5098
  "carPosition": carPosition,
5099
+ "carAngle": carAngle,
5047
5100
  "renderTitle": renderInServiceTitle,
5048
5101
  "registerOverlay": registerOverlay
5049
5102
  }
@@ -5051,6 +5104,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5051
5104
  "attrs": {
5052
5105
  "from": from,
5053
5106
  "carPosition": carPosition,
5107
+ "carAngle": carAngle,
5054
5108
  "passengerPosition": passengerPosition,
5055
5109
  "title": driverArrivedTitle,
5056
5110
  "registerOverlay": registerOverlay
package/dist/index.js CHANGED
@@ -2325,7 +2325,10 @@ const useADrivingRoute = (props) => {
2325
2325
  const outputRoute = reactive({ path: [], distance: 0, duration: 0 });
2326
2326
  const amapDriving = new AMap.Driving({});
2327
2327
  watchPostEffectForDeepOption(
2328
- () => ({ ...props }),
2328
+ () => {
2329
+ const { from, to } = props;
2330
+ return { from, to };
2331
+ },
2329
2332
  ({ from, to }) => {
2330
2333
  amapDriving.search(
2331
2334
  AMap.LngLat.from(from),
@@ -2420,7 +2423,8 @@ const amapComputeHeading = (from, to, map) => {
2420
2423
  const { x: xFrom, y: yFrom } = map.lngLatToContainer(from);
2421
2424
  const { x: xTo, y: yTo } = map.lngLatToContainer(to);
2422
2425
  const theta = Math.atan2(yFrom - yTo, xTo - xFrom);
2423
- 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;
2424
2428
  };
2425
2429
  const useAmapAngle = (props) => {
2426
2430
  return computed(() => {
@@ -2950,6 +2954,16 @@ const isPlace = (place) => {
2950
2954
  return place.lng !== void 0 && place.lat !== void 0;
2951
2955
  };
2952
2956
  const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
2957
+ const assertPoint = (point) => {
2958
+ if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
2959
+ return;
2960
+ throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
2961
+ };
2962
+ const assertAngle = (angle) => {
2963
+ if (typeof angle === "number" || typeof angle === "undefined")
2964
+ return;
2965
+ throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
2966
+ };
2953
2967
  class SingleGeoWatch {
2954
2968
  constructor(option) {
2955
2969
  __publicField(this, "id", 0);
@@ -3853,7 +3867,8 @@ const DEFAULT_PLACE_NAME = "当前位置";
3853
3867
  const DEFAULT_ZOOM = 8;
3854
3868
  const READY_ZOOM = 17;
3855
3869
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
3856
- emit
3870
+ emit,
3871
+ slots
3857
3872
  }) {
3858
3873
  var _a, _b;
3859
3874
  const {
@@ -4036,7 +4051,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4036
4051
  "center": centerPoint.value,
4037
4052
  "zoom": zoomRef.value,
4038
4053
  "touchZoomCenter": true,
4039
- "mapRef": setMap
4054
+ "mapRef": setMap,
4055
+ "fallback": slots.fallback,
4056
+ "loading": slots.loading
4040
4057
  }
4041
4058
  }, [!geoLoading.value && !geoError.value && h(PassengerCircle, {
4042
4059
  "attrs": {
@@ -4126,7 +4143,7 @@ const ATaxiCar = defineSetup(function ATaxiCar2(props) {
4126
4143
  "registerOverlay": props.registerOverlay,
4127
4144
  "zIndex": ZINDEX_CAR_LAYER
4128
4145
  }
4129
- }), h(AmapMarker, {
4146
+ }), !!contentRef.value.box && h(AmapMarker, {
4130
4147
  "attrs": {
4131
4148
  "position": props.position,
4132
4149
  "content": contentRef.value.box,
@@ -4174,7 +4191,7 @@ const GTaxiCar = defineSetup(function GTaxiCar2(props) {
4174
4191
  "registerOverlay": props.registerOverlay,
4175
4192
  "zIndex": ZINDEX_CAR_LAYER
4176
4193
  }
4177
- }), h(GmapAdvancedMarkerView, {
4194
+ }), !!contentRef.value.box && h(GmapAdvancedMarkerView, {
4178
4195
  "attrs": {
4179
4196
  "position": vec2lnglat(props.position),
4180
4197
  "content": contentRef.value.box,
@@ -4263,7 +4280,10 @@ const useAWalkingRoute = (props) => {
4263
4280
  const pathRef = shallowRef([]);
4264
4281
  const amapWalking = new AMap.Walking({});
4265
4282
  watchPostEffectForDeepOption(
4266
- () => ({ ...props }),
4283
+ () => {
4284
+ const { from, to } = props;
4285
+ return { from, to };
4286
+ },
4267
4287
  ({ from, to }) => {
4268
4288
  amapWalking.search(AMap.LngLat.from(from), AMap.LngLat.from(to), (status, result) => {
4269
4289
  switch (status) {
@@ -4527,6 +4547,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4527
4547
  const {
4528
4548
  from: fromPlace,
4529
4549
  carPosition,
4550
+ carAngle,
4530
4551
  passengerPosition,
4531
4552
  renderTitle,
4532
4553
  registerOverlay
@@ -4558,31 +4579,37 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
4558
4579
  "to": from,
4559
4580
  "render": ({
4560
4581
  path,
4582
+ angle,
4561
4583
  distance,
4562
4584
  duration
4563
- }) => [h(DrivingLine, {
4564
- "attrs": {
4565
- "path": path
4566
- }
4567
- }), h(TaxiCar, {
4568
- "attrs": {
4569
- "position": carPosition,
4570
- "title": renderTitle({
4571
- distance,
4572
- duration
4573
- }),
4574
- "registerOverlay": registerOverlay
4575
- }
4576
- }), h(KeyedFitView, {
4577
- "attrs": {
4578
- "registerOverlay": registerOverlay,
4579
- "fitViewKey": JSON.stringify(carPosition)
4580
- }
4581
- })]
4585
+ }) => {
4586
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4587
+ return [h(DrivingLine, {
4588
+ "attrs": {
4589
+ "path": path
4590
+ }
4591
+ }), h(TaxiCar, {
4592
+ "attrs": {
4593
+ "position": carPosition,
4594
+ "angle": angle,
4595
+ "title": renderTitle({
4596
+ distance,
4597
+ duration
4598
+ }),
4599
+ "registerOverlay": registerOverlay
4600
+ }
4601
+ }), h(KeyedFitView, {
4602
+ "attrs": {
4603
+ "registerOverlay": registerOverlay,
4604
+ "fitViewKey": JSON.stringify(carPosition)
4605
+ }
4606
+ })];
4607
+ }
4582
4608
  }
4583
4609
  }) : [h(TaxiCar, {
4584
4610
  "attrs": {
4585
4611
  "position": carPosition,
4612
+ "angle": carAngle,
4586
4613
  "title": renderTitle({
4587
4614
  distance: carDistance,
4588
4615
  duration: carDurationWithinMinDistance(carDistance)
@@ -4696,6 +4723,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4696
4723
  const {
4697
4724
  from: fromPlace,
4698
4725
  carPosition,
4726
+ carAngle,
4699
4727
  passengerPosition,
4700
4728
  title,
4701
4729
  registerOverlay
@@ -4723,6 +4751,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
4723
4751
  }), !!carPosition && [h(TaxiCar, {
4724
4752
  "attrs": {
4725
4753
  "position": carPosition,
4754
+ "angle": carAngle,
4726
4755
  "title": title,
4727
4756
  "registerOverlay": registerOverlay
4728
4757
  }
@@ -4755,6 +4784,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4755
4784
  const {
4756
4785
  to: toPlace,
4757
4786
  carPosition,
4787
+ carAngle,
4758
4788
  renderTitle,
4759
4789
  registerOverlay
4760
4790
  } = props;
@@ -4769,31 +4799,37 @@ const SectionInService = defineSetup(function SectionInService2(props) {
4769
4799
  "to": to,
4770
4800
  "render": ({
4771
4801
  path,
4802
+ angle,
4772
4803
  distance,
4773
4804
  duration
4774
- }) => [h(DrivingLine, {
4775
- "attrs": {
4776
- "path": path
4777
- }
4778
- }), h(TaxiCar, {
4779
- "attrs": {
4780
- "position": carPosition,
4781
- "title": renderTitle({
4782
- distance,
4783
- duration
4784
- }),
4785
- "registerOverlay": registerOverlay
4786
- }
4787
- }), h(KeyedFitView, {
4788
- "attrs": {
4789
- "registerOverlay": registerOverlay,
4790
- "fitViewKey": JSON.stringify(carPosition)
4791
- }
4792
- })]
4805
+ }) => {
4806
+ spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
4807
+ return [h(DrivingLine, {
4808
+ "attrs": {
4809
+ "path": path
4810
+ }
4811
+ }), h(TaxiCar, {
4812
+ "attrs": {
4813
+ "position": carPosition,
4814
+ "angle": angle,
4815
+ "title": renderTitle({
4816
+ distance,
4817
+ duration
4818
+ }),
4819
+ "registerOverlay": registerOverlay
4820
+ }
4821
+ }), h(KeyedFitView, {
4822
+ "attrs": {
4823
+ "registerOverlay": registerOverlay,
4824
+ "fitViewKey": JSON.stringify(carPosition)
4825
+ }
4826
+ })];
4827
+ }
4793
4828
  }
4794
4829
  }) : [h(TaxiCar, {
4795
4830
  "attrs": {
4796
4831
  "position": carPosition,
4832
+ "angle": carAngle,
4797
4833
  "title": renderTitle({
4798
4834
  distance: carDistance,
4799
4835
  duration: carDurationWithinMinDistance(carDistance)
@@ -4972,12 +5008,26 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
4972
5008
  geoError
4973
5009
  } = useGeoLocation();
4974
5010
  const carPositionRef = ref();
5011
+ const carAngleRef = ref();
5012
+ const {
5013
+ toGcj02
5014
+ } = useMapGCJ02();
4975
5015
  watch(() => props.driverStatus, (status, _, onCleanup) => {
4976
5016
  if (!STATUS_NEED_CAR_POSITION.includes(status))
4977
5017
  return;
4978
- const timer = setInterval(() => {
4979
- getDriverPosition().then((pos) => carPositionRef.value = pos);
4980
- }, interval);
5018
+ const update = () => {
5019
+ getDriverPosition().then(async ({
5020
+ position,
5021
+ angle
5022
+ }) => {
5023
+ assertPoint(position);
5024
+ assertAngle(angle);
5025
+ carPositionRef.value = position ? await toGcj02(position) : void 0;
5026
+ carAngleRef.value = angle;
5027
+ });
5028
+ };
5029
+ const timer = setInterval(update, interval);
5030
+ update();
4981
5031
  onCleanup(() => clearInterval(timer));
4982
5032
  }, {
4983
5033
  immediate: true
@@ -4992,6 +5042,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
4992
5042
  driverArrivedTitle
4993
5043
  } = props;
4994
5044
  const carPosition = carPositionRef.value;
5045
+ const carAngle = carAngleRef.value;
4995
5046
  const touchEnable = !["canceled", "canceling", "completed", "endService", "waitpay", "waitRechargePay", "refund", "rechargePayed", "payed"].includes(driverStatus);
4996
5047
  const passengerPosition = geoError.value ? void 0 : geoPosition.value;
4997
5048
  return h(HeycarMap, {
@@ -5027,6 +5078,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5027
5078
  "attrs": {
5028
5079
  "from": from,
5029
5080
  "carPosition": carPosition,
5081
+ "carAngle": carAngle,
5030
5082
  "passengerPosition": passengerPosition,
5031
5083
  "renderTitle": renderStartSerivceTitle,
5032
5084
  "registerOverlay": registerOverlay
@@ -5042,6 +5094,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5042
5094
  "attrs": {
5043
5095
  "to": to,
5044
5096
  "carPosition": carPosition,
5097
+ "carAngle": carAngle,
5045
5098
  "renderTitle": renderInServiceTitle,
5046
5099
  "registerOverlay": registerOverlay
5047
5100
  }
@@ -5049,6 +5102,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5049
5102
  "attrs": {
5050
5103
  "from": from,
5051
5104
  "carPosition": carPosition,
5105
+ "carAngle": carAngle,
5052
5106
  "passengerPosition": passengerPosition,
5053
5107
  "title": driverArrivedTitle,
5054
5108
  "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.3",
3
+ "version": "0.5.5",
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
 
@@ -89,3 +87,13 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
89
87
  - 5366
90
88
  - 5364
91
89
  - 5373
90
+
91
+ 0.5.4
92
+
93
+ - 5375
94
+ - 4946
95
+
96
+ 0.5.5
97
+
98
+ - 4977
99
+ - 5381