@heycar/heycars-map 2.13.0-relay2 → 2.15.0-domestic1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +47 -4
  2. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +2 -1
  3. package/dist/v2/Demo/DemoBusinessTaxiEnd.d.ts +2 -1
  4. package/dist/v2/Demo/DemoBusinessTaxiEnd.js +9 -2
  5. package/dist/v2/Demo/DemoBusinessTaxiService.d.ts +4 -1
  6. package/dist/v2/Demo/DemoBusinessTaxiService.js +19 -1
  7. package/dist/v2/Demo/demo.data.mock.d.ts +4 -0
  8. package/dist/v2/Demo/demo.data.mock.js +1194 -0
  9. package/dist/v2/api/contants.d.ts +3 -0
  10. package/dist/v2/api/contants.js +6 -0
  11. package/dist/v2/business-components/AuxiliaryPassanger/AuxiliaryPassanger.d.ts +6 -0
  12. package/dist/v2/business-components/AuxiliaryPassanger/AuxiliaryPassanger.js +50 -0
  13. package/dist/v2/business-components/AuxiliaryPassanger/index.d.ts +1 -0
  14. package/dist/v2/business-components/AuxiliaryPassanger/index.js +4 -0
  15. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
  16. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  17. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  18. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +1 -1
  19. package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
  20. package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +6 -2
  21. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +4 -1
  22. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +51 -7
  23. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.d.ts +6 -1
  24. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +81 -19
  25. package/dist/v2/business-components/TaxiCar/RandomCars.d.ts +6 -0
  26. package/dist/v2/business-components/TaxiCar/RandomCars.js +47 -0
  27. package/dist/v2/chunks/{BusinessRecomendPlaceMap.e9166e7d.js → BusinessRecomendPlaceMap.eebd0822.js} +7 -1
  28. package/dist/v2/hooks/useMapCoordinatify.d.ts +2 -1
  29. package/dist/v2/hooks/useMapCoordinatify.js +6 -1
  30. package/dist/v2/hooks/useMapGeometry.d.ts +3 -3
  31. package/dist/v2/hooks/useMapGeometry.js +3 -3
  32. package/dist/v2/hooks/useWalkingRoute.js +46 -4
  33. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  34. package/dist/v2/index.js +1 -1
  35. package/dist/v2/types/interface.d.ts +12 -0
  36. package/dist/v2/utils/geometry.d.ts +1 -0
  37. package/dist/v2/utils/geometry.js +4 -2
  38. package/dist/v2/utils/geometryPolygon.d.ts +14 -0
  39. package/dist/v2/utils/geometryPolygon.js +46 -0
  40. package/dist/v2/utils/log.js +11 -3
  41. package/dist/v2/utils/platform.d.ts +2 -1
  42. package/dist/v2/utils/platform.js +2 -1
  43. package/dist/v2/utils/ttlCache.d.ts +34 -0
  44. package/dist/v2/utils/ttlCache.js +64 -0
  45. package/dist/v2/utils/typeChecking.d.ts +7 -1
  46. package/dist/v2/utils/typeChecking.js +18 -0
  47. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +2 -1
  48. package/dist/v3/Demo/DemoBusinessTaxiEnd.d.ts +2 -1
  49. package/dist/v3/Demo/DemoBusinessTaxiEnd.js +9 -2
  50. package/dist/v3/Demo/DemoBusinessTaxiService.d.ts +4 -1
  51. package/dist/v3/Demo/DemoBusinessTaxiService.js +19 -1
  52. package/dist/v3/Demo/demo.data.mock.d.ts +4 -0
  53. package/dist/v3/Demo/demo.data.mock.js +1194 -0
  54. package/dist/v3/api/contants.d.ts +3 -0
  55. package/dist/v3/api/contants.js +6 -0
  56. package/dist/v3/business-components/AuxiliaryPassanger/AuxiliaryPassanger.d.ts +8 -0
  57. package/dist/v3/business-components/AuxiliaryPassanger/AuxiliaryPassanger.js +46 -0
  58. package/dist/v3/business-components/AuxiliaryPassanger/index.d.ts +1 -0
  59. package/dist/v3/business-components/AuxiliaryPassanger/index.js +4 -0
  60. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
  61. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  62. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  63. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +1 -1
  64. package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
  65. package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +6 -2
  66. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +4 -1
  67. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +49 -7
  68. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.d.ts +6 -1
  69. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +63 -19
  70. package/dist/v3/business-components/TaxiCar/RandomCars.d.ts +8 -0
  71. package/dist/v3/business-components/TaxiCar/RandomCars.js +45 -0
  72. package/dist/v3/chunks/{BusinessRecomendPlaceMap.c71d0b97.js → BusinessRecomendPlaceMap.71c439c6.js} +5 -1
  73. package/dist/v3/hooks/useMapCoordinatify.d.ts +2 -1
  74. package/dist/v3/hooks/useMapCoordinatify.js +6 -1
  75. package/dist/v3/hooks/useMapGeometry.d.ts +3 -3
  76. package/dist/v3/hooks/useMapGeometry.js +3 -3
  77. package/dist/v3/hooks/useWalkingRoute.js +46 -4
  78. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  79. package/dist/v3/index.js +1 -1
  80. package/dist/v3/types/interface.d.ts +12 -0
  81. package/dist/v3/utils/geometry.d.ts +1 -0
  82. package/dist/v3/utils/geometry.js +4 -2
  83. package/dist/v3/utils/geometryPolygon.d.ts +14 -0
  84. package/dist/v3/utils/geometryPolygon.js +46 -0
  85. package/dist/v3/utils/log.js +11 -3
  86. package/dist/v3/utils/platform.d.ts +2 -1
  87. package/dist/v3/utils/platform.js +2 -1
  88. package/dist/v3/utils/ttlCache.d.ts +34 -0
  89. package/dist/v3/utils/ttlCache.js +64 -0
  90. package/dist/v3/utils/typeChecking.d.ts +7 -1
  91. package/dist/v3/utils/typeChecking.js +18 -0
  92. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { h } from "vue";
2
2
  import { apiGetAuxiliaryGrapStatus } from "../../api/browser.js";
3
- import { MAX_DEVIATION_DISTANCE, CAR_DISTANCE_MIN } from "../../api/contants.js";
3
+ import { PASSENGER_DISTANCE_MAX, MAX_DEVIATION_DISTANCE, PASSENGER_DISTANCE_MIN, CAR_DISTANCE_MIN } from "../../api/contants.js";
4
4
  import { useMapGeometry } from "../../hooks/useMapGeometry.js";
5
5
  import { useMapSupplier } from "../../hooks/useMapSupplier.js";
6
6
  import { defineSetup } from "../../types/helper.js";
@@ -19,8 +19,6 @@ import { WalkingLine } from "../WalkingLine/WalkingLine.js";
19
19
  import { WalkingRoute } from "../WalkingRoute/WalkingRoute.js";
20
20
  import { WaveCircle } from "../WaveCircle/WaveCircle.js";
21
21
  const IS_ENABLE_AUXILIARY_GRASP_ROAD = apiGetAuxiliaryGrapStatus();
22
- const PASSENGER_DISTANCE_MAX = 2e3;
23
- const PASSENGER_DISTANCE_MIN = 20;
24
22
  const AUTO_FIT_VIEW_INTERVAL = IS_ENABLE_AUXILIARY_GRASP_ROAD ? 24 * 3600 * 1e3 : 15e3;
25
23
  const carDurationWithinMinDistance = (distance) => Math.floor(distance / 5);
26
24
  const SectionDispatching = defineSetup("SectionDispatching", function(props) {
@@ -79,12 +77,17 @@ const SectionConfirmed = defineSetup("SectionConfirmed", function(props) {
79
77
  to: toPlace,
80
78
  passengerPosition,
81
79
  passengerAngle,
80
+ routePath,
82
81
  registerOverlay
83
82
  } = props;
84
83
  const from = place2point(fromPlace);
85
84
  const to = place2point(toPlace);
86
85
  const passengerDistance = passengerPosition ? apiMapDistance(passengerPosition, from) : void 0;
87
- return h("div", [h(DrivingRoute, {
86
+ return h("div", [routePath ? h(DrivingLine, {
87
+ "attrs": {
88
+ "path": routePath
89
+ }
90
+ }) : h(DrivingRoute, {
88
91
  "attrs": {
89
92
  "to": to,
90
93
  "from": from,
@@ -159,12 +162,14 @@ const SectionDriverStartRelayService = defineSetup("SectionDriverStartRelayServi
159
162
  apiMapDistance
160
163
  } = useMapGeometry();
161
164
  return () => {
165
+ var _a;
162
166
  const {
163
167
  from: fromPlace,
164
168
  relayTo: relayToPlace,
165
169
  carPosition,
166
170
  carAngle,
167
171
  carTrackPositions,
172
+ carRoute,
168
173
  passengerPosition,
169
174
  passengerAngle,
170
175
  relayToTitle,
@@ -208,7 +213,21 @@ const SectionDriverStartRelayService = defineSetup("SectionDriverStartRelayServi
208
213
  "label": relayToTitle,
209
214
  "hideIcon": true
210
215
  }
211
- }), !(carTrackPositions == null ? void 0 : carTrackPositions.length) || !carDistance ? null : h(DeviationCorrectionDrivingRoute, {
216
+ }), carRoute ? [h(DrivingLine, {
217
+ "attrs": {
218
+ "path": carRoute.path
219
+ }
220
+ }), h(TaxiCar, {
221
+ "attrs": {
222
+ "position": (_a = carRoute.path[0]) != null ? _a : carPosition,
223
+ "angle": carAngle,
224
+ "title": renderTitle({
225
+ distance: carRoute.distance,
226
+ duration: carRoute.duration
227
+ }),
228
+ "registerOverlay": fittableRegistryOverlay
229
+ }
230
+ })] : !(carTrackPositions == null ? void 0 : carTrackPositions.length) || !carDistance ? null : h(DeviationCorrectionDrivingRoute, {
212
231
  "attrs": {
213
232
  "tracks": carTrackPositions,
214
233
  "to": from,
@@ -221,7 +240,7 @@ const SectionDriverStartRelayService = defineSetup("SectionDriverStartRelayServi
221
240
  duration,
222
241
  trafficJams
223
242
  }) => {
224
- var _a;
243
+ var _a2;
225
244
  return [relayTo ? h(TrafficDrivingLine, {
226
245
  "attrs": {
227
246
  "path": path,
@@ -229,7 +248,7 @@ const SectionDriverStartRelayService = defineSetup("SectionDriverStartRelayServi
229
248
  }
230
249
  }) : null, h(TaxiCar, {
231
250
  "attrs": {
232
- "position": (_a = path[0]) != null ? _a : carPosition,
251
+ "position": (_a2 = path[0]) != null ? _a2 : carPosition,
233
252
  "angle": angle != null ? angle : carAngle,
234
253
  "title": renderTitle({
235
254
  distance,
@@ -280,11 +299,13 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
280
299
  apiMapDistance
281
300
  } = useMapGeometry();
282
301
  return () => {
302
+ var _a;
283
303
  const {
284
304
  from: fromPlace,
285
305
  carPosition,
286
306
  carAngle,
287
307
  carTrackPositions,
308
+ carRoute,
288
309
  passengerPosition,
289
310
  passengerAngle,
290
311
  renderTitle
@@ -312,7 +333,21 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
312
333
  "label": fromPlace.displayName,
313
334
  "hideIcon": true
314
335
  }
315
- }), !(carTrackPositions == null ? void 0 : carTrackPositions.length) || !carDistance ? null : carDistance > CAR_DISTANCE_MIN ? h(DeviationCorrectionDrivingRoute, {
336
+ }), carRoute ? [h(DrivingLine, {
337
+ "attrs": {
338
+ "path": carRoute.path
339
+ }
340
+ }), h(TaxiCar, {
341
+ "attrs": {
342
+ "position": (_a = carRoute.path[0]) != null ? _a : carPosition,
343
+ "angle": carAngle,
344
+ "title": renderTitle({
345
+ distance: carRoute.distance,
346
+ duration: carRoute.duration
347
+ }),
348
+ "registerOverlay": fittableRegistryOverlay
349
+ }
350
+ })] : !(carTrackPositions == null ? void 0 : carTrackPositions.length) || !carDistance ? null : carDistance > CAR_DISTANCE_MIN ? h(DeviationCorrectionDrivingRoute, {
316
351
  "attrs": {
317
352
  "tracks": carTrackPositions,
318
353
  "to": from,
@@ -324,7 +359,7 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
324
359
  duration,
325
360
  trafficJams
326
361
  }) => {
327
- var _a;
362
+ var _a2;
328
363
  return [h(TrafficDrivingLine, {
329
364
  "attrs": {
330
365
  "path": path,
@@ -332,7 +367,7 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
332
367
  }
333
368
  }), h(TaxiCar, {
334
369
  "attrs": {
335
- "position": (_a = path[0]) != null ? _a : carPosition,
370
+ "position": (_a2 = path[0]) != null ? _a2 : carPosition,
336
371
  "angle": angle != null ? angle : carAngle,
337
372
  "title": renderTitle({
338
373
  distance,
@@ -350,10 +385,10 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
350
385
  path: graspRoadPath,
351
386
  angle
352
387
  }) => {
353
- var _a;
388
+ var _a2;
354
389
  return h(TaxiCar, {
355
390
  "attrs": {
356
- "position": (_a = graspRoadPath[graspRoadPath.length - 1]) != null ? _a : carPosition,
391
+ "position": (_a2 = graspRoadPath[graspRoadPath.length - 1]) != null ? _a2 : carPosition,
357
392
  "angle": angle != null ? angle : carAngle,
358
393
  "title": renderTitle({
359
394
  distance: carDistance,
@@ -403,12 +438,17 @@ const SectionBookDispatched = defineSetup("SectionBookDispatched", function(prop
403
438
  title,
404
439
  passengerPosition,
405
440
  passengerAngle,
441
+ routePath,
406
442
  registerOverlay
407
443
  } = props;
408
444
  const from = place2point(fromPlace);
409
445
  const to = place2point(toPlace);
410
446
  const passengerDistance = passengerPosition ? apiMapDistance(passengerPosition, from) : void 0;
411
- return h("div", [h(DrivingRoute, {
447
+ return h("div", [routePath ? h(DrivingLine, {
448
+ "attrs": {
449
+ "path": routePath
450
+ }
451
+ }) : h(DrivingRoute, {
412
452
  "attrs": {
413
453
  "to": to,
414
454
  "from": from,
@@ -567,11 +607,13 @@ const SectionInService = defineSetup("SectionInService", function(props) {
567
607
  immediate: true
568
608
  });
569
609
  return () => {
610
+ var _a;
570
611
  const {
571
612
  to: toPlace,
572
613
  carPosition,
573
614
  carAngle,
574
615
  carTrackPositions,
616
+ carRoute,
575
617
  renderTitle
576
618
  } = props;
577
619
  const to = place2point(toPlace);
@@ -582,7 +624,21 @@ const SectionInService = defineSetup("SectionInService", function(props) {
582
624
  apiMapDistance
583
625
  } = useMapGeometry();
584
626
  const carDistance = carPosition ? apiMapDistance(carPosition, to) : void 0;
585
- return h("div", [!(carTrackPositions == null ? void 0 : carTrackPositions.length) || !carDistance ? null : carDistance > CAR_DISTANCE_MIN ? h(DeviationCorrectionDrivingRoute, {
627
+ return h("div", [carRoute ? [h(DrivingLine, {
628
+ "attrs": {
629
+ "path": carRoute.path
630
+ }
631
+ }), h(TaxiCar, {
632
+ "attrs": {
633
+ "position": (_a = carRoute.path[0]) != null ? _a : carPosition,
634
+ "angle": carAngle,
635
+ "title": renderTitle({
636
+ distance: carRoute.distance,
637
+ duration: carRoute.duration
638
+ }),
639
+ "registerOverlay": fittableRegistryOverlay
640
+ }
641
+ })] : !(carTrackPositions == null ? void 0 : carTrackPositions.length) || !carDistance ? null : carDistance > CAR_DISTANCE_MIN ? h(DeviationCorrectionDrivingRoute, {
586
642
  "attrs": {
587
643
  "tracks": carTrackPositions,
588
644
  "to": to,
@@ -594,7 +650,7 @@ const SectionInService = defineSetup("SectionInService", function(props) {
594
650
  duration,
595
651
  trafficJams
596
652
  }) => {
597
- var _a;
653
+ var _a2;
598
654
  return [h(TrafficDrivingLine, {
599
655
  "attrs": {
600
656
  "path": path,
@@ -602,7 +658,7 @@ const SectionInService = defineSetup("SectionInService", function(props) {
602
658
  }
603
659
  }), h(TaxiCar, {
604
660
  "attrs": {
605
- "position": (_a = path[0]) != null ? _a : carPosition,
661
+ "position": (_a2 = path[0]) != null ? _a2 : carPosition,
606
662
  "angle": angle != null ? angle : carAngle,
607
663
  "title": renderTitle({
608
664
  distance,
@@ -620,10 +676,10 @@ const SectionInService = defineSetup("SectionInService", function(props) {
620
676
  path: graspRoadPath,
621
677
  angle
622
678
  }) => {
623
- var _a;
679
+ var _a2;
624
680
  return h(TaxiCar, {
625
681
  "attrs": {
626
- "position": (_a = graspRoadPath[graspRoadPath.length - 1]) != null ? _a : carPosition,
682
+ "position": (_a2 = graspRoadPath[graspRoadPath.length - 1]) != null ? _a2 : carPosition,
627
683
  "angle": angle != null ? angle : carAngle,
628
684
  "title": renderTitle({
629
685
  distance: carDistance,
@@ -720,11 +776,17 @@ const SectionEndService = defineSetup("SectionEndService", function(props) {
720
776
  const {
721
777
  from: fromPlace,
722
778
  to: toPlace,
779
+ routePath,
723
780
  registerOverlay
724
781
  } = props;
725
782
  const from = place2point(fromPlace);
726
783
  const to = place2point(toPlace);
727
- return h("div", [h(DrivingRoute, {
784
+ return h("div", [routePath ? h(DrivingLine, {
785
+ "attrs": {
786
+ "path": routePath,
787
+ "status": "DONE"
788
+ }
789
+ }) : h(DrivingRoute, {
728
790
  "attrs": {
729
791
  "from": from,
730
792
  "to": to,
@@ -0,0 +1,6 @@
1
+ import type { Point } from "../../types/interface";
2
+ interface RandomCarsProps {
3
+ center: Point;
4
+ }
5
+ export declare const RandomCars: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<RandomCarsProps>, 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<RandomCarsProps, Required<RandomCarsProps>>, never, RandomCarsProps>;
6
+ export {};
@@ -0,0 +1,47 @@
1
+ import { h } from "vue";
2
+ import { computed } from "vue-demi";
3
+ import { defineSetup } from "../../types/helper.js";
4
+ import { TaxiCar } from "./TaxiCar.js";
5
+ const RANDOM_CARS_RADIUS = 300;
6
+ const RANDOM_CARS_COUNT = 2;
7
+ const createRandomPoint = (center, radius) => {
8
+ const [lng, lat] = center;
9
+ const R_EARTH_METERS = 6371e3;
10
+ const randomAngle = Math.random() * 2 * Math.PI;
11
+ const randomRadiusInMeters = radius * Math.sqrt(Math.random());
12
+ const dx = randomRadiusInMeters * Math.cos(randomAngle);
13
+ const dy = randomRadiusInMeters * Math.sin(randomAngle);
14
+ const dLat = dy / R_EARTH_METERS;
15
+ const centerLatRadians = lat * (Math.PI / 180);
16
+ const dLng = dx / (R_EARTH_METERS * Math.cos(centerLatRadians));
17
+ return [lng + dLng * (180 / Math.PI), lat + dLat * (180 / Math.PI)];
18
+ };
19
+ const useRandomCars = (center) => {
20
+ return computed(() => {
21
+ return Array.from({
22
+ length: RANDOM_CARS_COUNT
23
+ }).map(() => {
24
+ const position = createRandomPoint(center, RANDOM_CARS_RADIUS);
25
+ const angle = Math.random() * 360;
26
+ return {
27
+ position,
28
+ angle
29
+ };
30
+ });
31
+ });
32
+ };
33
+ const RandomCars = defineSetup("RandomCars", function(props) {
34
+ const {
35
+ center
36
+ } = props;
37
+ const randomCarsRef = useRandomCars(center);
38
+ return () => h("div", [randomCarsRef.value.map((car) => h(TaxiCar, {
39
+ "attrs": {
40
+ "position": car.position,
41
+ "angle": car.angle
42
+ }
43
+ }))]);
44
+ });
45
+ export {
46
+ RandomCars
47
+ };
@@ -26,6 +26,7 @@ import { DeviceOrientation } from "../business-components/DeviceOrientation/Devi
26
26
  import { GreenZone } from "../business-components/GreenZone/GreenZone.js";
27
27
  import { PassengerCircle } from "../business-components/PassengerCircle/PassengerCircle.js";
28
28
  import { PickupPoints } from "../business-components/PickupPoints/PickupPoints.js";
29
+ import { RandomCars } from "../business-components/TaxiCar/RandomCars.js";
29
30
  import { useCacheCenterPlace } from "../business-components/BusinessRecomendPlaceMap/useCacheCenterPlace.js";
30
31
  import { b as baseGetTag, r as root } from "./isSymbol.555c14bf.js";
31
32
  import { i as isObject } from "./debounce.5afe7867.js";
@@ -556,6 +557,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
556
557
  recomendDescription,
557
558
  unavailableTitle,
558
559
  forbiddenTitle,
560
+ enableNearbyCars,
559
561
  disableLocator,
560
562
  renderPlacePhoto,
561
563
  renderPlaceTag
@@ -618,6 +620,10 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
618
620
  "on": {
619
621
  "click": panToCenterByPlace
620
622
  }
623
+ }), !!enableNearbyCars && zoomRef.value >= RECOMMEND_PLACE_ZONE_ICON_MIN && h(RandomCars, {
624
+ "attrs": {
625
+ "center": [centerPlace.lng, centerPlace.lat]
626
+ }
621
627
  })]);
622
628
  };
623
629
  });
@@ -640,7 +646,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup("BusinessRecomendPlaceMap", f
640
646
  key: `${payload.supplier}${instanceNo}`,
641
647
  on: generateCreateElementV2PropsOn(props, emit, ["loadGeoLocation", "loadDefaultGeoLocation", "changeByDrag", "changeGeoLocation", "changePlace", "changeRecomandPlace", "geoError", "geoErrorOnce", "clickLocatorText", "clickLocatorPhoto"])
642
648
  });
643
- }).props(["log", "geoLoadingTitle", "emptyTitle", "queryingTitle", "defaultCenterPlace", "geoErrorOnceNotificationKey", "unavailableTitle", "forbiddenTitle", "recomendDescription", "disableLocator", "fallback", "getRecomendPlace", "getAvailable", "renderPlacePhoto", "renderPlaceTag", "loading", "mapContext"]);
649
+ }).props(["log", "geoLoadingTitle", "emptyTitle", "queryingTitle", "defaultCenterPlace", "geoErrorOnceNotificationKey", "unavailableTitle", "forbiddenTitle", "recomendDescription", "enableNearbyCars", "disableLocator", "fallback", "getRecomendPlace", "getAvailable", "renderPlacePhoto", "renderPlaceTag", "loading", "mapContext"]);
644
650
  export {
645
651
  BusinessRecomendPlaceMap as B,
646
652
  DEFAULT_ZOOM as D,
@@ -1,4 +1,4 @@
1
- import { type CoordinateGeoPosition, type CoordinatePlace, type CoordinatePoint, type CoordinateRecommendZonePlaces, type CoordinateTrackPoint, type CoordinateValueOfOnChangeRecommendPlace, type CoordinateZone, type GeoPosition, type Place, type Point, type RecommendZonePlaces, type TrackPoint, type ValueOfOnChangeRecommendPlace, type Zone } from "../types/interface";
1
+ import { type CoordinateExternalRoute, type CoordinateGeoPosition, type CoordinatePlace, type CoordinatePoint, type CoordinateRecommendZonePlaces, type CoordinateTrackPoint, type CoordinateValueOfOnChangeRecommendPlace, type CoordinateZone, type ExternalRoute, type GeoPosition, type Place, type Point, type RecommendZonePlaces, type TrackPoint, type ValueOfOnChangeRecommendPlace, type Zone } from "../types/interface";
2
2
  export declare function useMapCoordinatify(): {
3
3
  coordinatifyPoint: (value: Point) => CoordinatePoint;
4
4
  unCoordinatifyPoint: (value: CoordinatePoint) => Point;
@@ -12,4 +12,5 @@ export declare function useMapCoordinatify(): {
12
12
  unCoordinatifyValueOfOnChangeRecommendPlace: (value: CoordinateValueOfOnChangeRecommendPlace) => ValueOfOnChangeRecommendPlace;
13
13
  coordinatifyGeoPosition: (value: GeoPosition) => CoordinateGeoPosition;
14
14
  unCoordinatifyTrackPoint: (value: CoordinateTrackPoint) => TrackPoint;
15
+ unCoordinatifyExternalRoute: (value: CoordinateExternalRoute) => ExternalRoute;
15
16
  };
@@ -74,6 +74,10 @@ function useMapCoordinatify() {
74
74
  const [lng, lat] = unCoordinatifyPoint(value);
75
75
  return { ...others, lng, lat };
76
76
  };
77
+ const unCoordinatifyExternalRoute = (value) => {
78
+ const { path, duration, distance } = value;
79
+ return { path: path.map(unCoordinatifyPoint), duration, distance };
80
+ };
77
81
  const coordinatifyGeoPosition = (value) => {
78
82
  return {
79
83
  ...value,
@@ -92,7 +96,8 @@ function useMapCoordinatify() {
92
96
  coordinatifyValueOfOnChangeRecommendPlace,
93
97
  unCoordinatifyValueOfOnChangeRecommendPlace,
94
98
  coordinatifyGeoPosition,
95
- unCoordinatifyTrackPoint
99
+ unCoordinatifyTrackPoint,
100
+ unCoordinatifyExternalRoute
96
101
  };
97
102
  }
98
103
  export {
@@ -1,17 +1,17 @@
1
1
  import type { Point } from "../types/interface";
2
2
  export declare const apiLocalIsPointInRing: (point: Point, path: Point[]) => boolean;
3
3
  export declare const useAmapGeometry: () => {
4
- apiMapDistance: (from: Point, to: Point) => number | undefined;
4
+ apiMapDistance: (from: Point, to: Point) => number;
5
5
  apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
6
6
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
7
7
  };
8
8
  export declare const useGmapGeometry: () => {
9
- apiMapDistance: (from: Point, to: Point) => number | undefined;
9
+ apiMapDistance: (from: Point, to: Point) => number;
10
10
  apiMapDistanceToLine: (from: Point, line: Point[]) => 0 | undefined;
11
11
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
12
12
  };
13
13
  export declare const useMapGeometry: () => {
14
- apiMapDistance: (from: Point, to: Point) => number | undefined;
14
+ apiMapDistance: (from: Point, to: Point) => number;
15
15
  apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
16
16
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
17
17
  };
@@ -1,4 +1,4 @@
1
- import { pointInPolygon } from "../utils/geometryPolygon.js";
1
+ import { pointInPolygon, distanceBetweenTwoPoints } from "../utils/geometryPolygon.js";
2
2
  import { vec2lnglat } from "../utils/transform.js";
3
3
  import { Status } from "./useMapLoader.js";
4
4
  import { useMapSupplier } from "./useMapSupplier.js";
@@ -7,7 +7,7 @@ const useAmapGeometry = () => {
7
7
  const payload = useMapSupplier();
8
8
  const apiMapDistance = (from, to) => {
9
9
  if (payload.status !== Status.SUCCESS)
10
- return void 0;
10
+ return distanceBetweenTwoPoints(from, to);
11
11
  return AMap.GeometryUtil.distance(from, to);
12
12
  };
13
13
  const apiMapDistanceToLine = (from, line) => {
@@ -26,7 +26,7 @@ const useGmapGeometry = () => {
26
26
  const payload = useMapSupplier();
27
27
  const apiMapDistance = (from, to) => {
28
28
  if (payload.status !== Status.SUCCESS)
29
- return void 0;
29
+ return distanceBetweenTwoPoints(from, to);
30
30
  return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
31
31
  };
32
32
  const apiMapDistanceToLine = (from, line) => {
@@ -1,15 +1,56 @@
1
1
  import { shallowRef } from "vue-demi";
2
+ import { MAX_DEVIATION_DISTANCE_WALKING } from "../api/contants.js";
2
3
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
4
  import { googleServiceApiWalkingRoute, amapJsApiWalkingRoute, gaodeServiceApiWalkingRoute, gmapJsApiWalkingRoute } from "../utils/compatibleWalkingRoute.js";
5
+ import { findClosestPointInLine } from "../utils/geometry.js";
6
+ import { distanceBetweenTwoPoints } from "../utils/geometryPolygon.js";
7
+ import { spaceLog } from "../utils/log.js";
8
+ import { createMemoizeWithTTL } from "../utils/ttlCache.js";
4
9
  import { inTaiwan, inKorean } from "./useMapInChina.js";
5
10
  import { useMapSupplier } from "./useMapSupplier.js";
11
+ const WALKING_ROUTE_CACHE_TTL = 30 * 60 * 1e3;
12
+ const findBestContinuation = (args, cacheEntries) => {
13
+ const [from, to] = args;
14
+ let bestPath;
15
+ for (const [[cacheFrom, cacheTo], path] of cacheEntries) {
16
+ if (!path || path.length < 2)
17
+ continue;
18
+ const deviationOfEndPoint = distanceBetweenTwoPoints(cacheTo, to);
19
+ if (deviationOfEndPoint > MAX_DEVIATION_DISTANCE_WALKING)
20
+ continue;
21
+ {
22
+ const { distance: deviationOfStartPoint } = findClosestPointInLine(
23
+ from,
24
+ [cacheFrom, ...path],
25
+ distanceBetweenTwoPoints
26
+ );
27
+ if (deviationOfStartPoint > MAX_DEVIATION_DISTANCE_WALKING)
28
+ continue;
29
+ }
30
+ const { point: projectedPoint, index } = findClosestPointInLine(
31
+ from,
32
+ path,
33
+ distanceBetweenTwoPoints
34
+ );
35
+ const trimmedPath = [projectedPoint, ...path.slice(index + 1)];
36
+ if (trimmedPath.length < 2)
37
+ continue;
38
+ if (!bestPath || trimmedPath.length < bestPath.length) {
39
+ bestPath = trimmedPath;
40
+ }
41
+ }
42
+ return bestPath;
43
+ };
44
+ const memoizeAmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
45
+ const memoizeGmapWalkingRoute = createMemoizeWithTTL(WALKING_ROUTE_CACHE_TTL, findBestContinuation);
6
46
  const useAWalkingRoute = (props) => {
7
47
  const { googleRoutesProxyUrl } = useMapSupplier();
8
48
  const pathRef = shallowRef([]);
9
49
  const amapWalking = new AMap.Walking({});
10
- const apiMapWalkingRoute = (from, to) => {
50
+ const apiMapWalkingRoute = memoizeAmapWalkingRoute((from, to) => {
51
+ spaceLog("apiMapWalkingRoute", `amap from = ${from} to = ${to}`);
11
52
  return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : amapJsApiWalkingRoute(from, to, amapWalking);
12
- };
53
+ });
13
54
  watchPostEffectForDeepOption(
14
55
  () => {
15
56
  const { from, to } = props;
@@ -27,11 +68,12 @@ const useGWalkingRoute = (props) => {
27
68
  const { gaodeDirectionWalkingProxyUrl, googleRoutesProxyUrl } = useMapSupplier();
28
69
  const pathRef = shallowRef([]);
29
70
  const gmapDirectionsService = new google.maps.DirectionsService();
30
- const apiMapWalkingRoute = (from, to) => {
71
+ const apiMapWalkingRoute = memoizeGmapWalkingRoute((from, to) => {
72
+ spaceLog("apiMapWalkingRoute", `gmap from = ${from} to = ${to}`);
31
73
  if (inKorean(from))
32
74
  return Promise.resolve([]);
33
75
  return gaodeDirectionWalkingProxyUrl && inKorean(from) ? gaodeServiceApiWalkingRoute(from, to, gaodeDirectionWalkingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiWalkingRoute(from, to, googleRoutesProxyUrl) : gmapJsApiWalkingRoute(from, to, gmapDirectionsService);
34
- };
76
+ });
35
77
  watchPostEffectForDeepOption(
36
78
  () => {
37
79
  const { from, to } = props;
@@ -1,5 +1,5 @@
1
1
  import { reactive, ref, readonly } from "vue-demi";
2
- import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.e9166e7d.js";
2
+ import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.eebd0822.js";
3
3
  import { CenterPlaceStatus } from "../types/interface.js";
4
4
  import { proxyFunctionalProperty, assertAssingedBeforeUsed } from "../utils/helper.js";
5
5
  const useBusinessRecomendPlaceMap = () => {
package/dist/v2/index.js CHANGED
@@ -2,7 +2,7 @@ import "./utils/alipayPolyfill.js";
2
2
  import { isCoordinatePointEqual } from "./api/geometry.js";
3
3
  import { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
4
4
  import { BusinessQuotingMap } from "./business-components/BusinessQuotingMap/BusinessQuotingMap.js";
5
- import { B } from "./chunks/BusinessRecomendPlaceMap.e9166e7d.js";
5
+ import { B } from "./chunks/BusinessRecomendPlaceMap.eebd0822.js";
6
6
  import { BusinessReselectPlaceMap } from "./business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js";
7
7
  import { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js";
8
8
  import { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js";
@@ -80,6 +80,11 @@ export interface Route {
80
80
  steps: RouteStep[];
81
81
  trafficJams?: TrafficJams;
82
82
  }
83
+ export interface ExternalRoute {
84
+ path: Point[];
85
+ duration: number;
86
+ distance: number;
87
+ }
83
88
  export interface TrackPoint {
84
89
  lng: number;
85
90
  lat: number;
@@ -90,6 +95,13 @@ export interface TrackPoint {
90
95
  export interface CoordinateTrackPoint extends TrackPoint {
91
96
  type: CoordinateType;
92
97
  }
98
+ export interface CoordinateExternalRoute extends Omit<ExternalRoute, "path"> {
99
+ path: CoordinatePoint[];
100
+ }
101
+ export type GetDriverRouteOrTrackOutput = {
102
+ routes?: CoordinateExternalRoute;
103
+ tracks?: CoordinateTrackPoint[];
104
+ };
93
105
  export type RecommendType = "Restricted" | "Forbidden" | "Recommend";
94
106
  export type DriverStatus = "dispatching" | "book-dispatching" | "dispatched" | "driverStartService" | "driverStartRelayService" | "book-driverStartService" | "book-dispatched" | "driverArrived" | "inService" | "canceled" | "endService" | "completed" | "canceling" | "banlanceRefund" | "waitBanlanceRefund" | "rechargePayed" | "waitRechargePay" | "payed" | "waitpay" | "refund" | "confirmed" | "assign" | "orderReassigned";
95
107
  export declare enum CenterPlaceStatus {
@@ -4,6 +4,7 @@ export declare const findClosestPointInSegment: (point: Point, segment: [Point,
4
4
  export declare const findClosestPointInLine: (point: Point, path: Point[], distanceFn: DistanceFn) => {
5
5
  point: Point;
6
6
  distance: number;
7
+ index: number;
7
8
  };
8
9
  export declare const isPointInSegment: (point: Point, segment: [Point, Point]) => boolean;
9
10
  export declare const isPointInHalfOpenSegment: (point: Point, segment: [Point, Point]) => boolean;
@@ -23,9 +23,10 @@ const findClosestPointInLine = (point, path, distanceFn) => {
23
23
  var _a, _b;
24
24
  let min = Infinity;
25
25
  let target;
26
+ let idx;
26
27
  assertPropNoEmptyArray(path, "findClosestPointInLine", "path");
27
28
  if (path.length === 1)
28
- return { point: path[0], distance: (_a = distanceFn(point, path[0])) != null ? _a : 0 };
29
+ return { point: path[0], distance: (_a = distanceFn(point, path[0])) != null ? _a : 0, index: 0 };
29
30
  for (let index = 0; index < path.length - 1; index++) {
30
31
  const closestPoint = findClosestPointInSegment(point, [path[index], path[index + 1]]);
31
32
  const distance = (_b = distanceFn(point, closestPoint)) != null ? _b : 0;
@@ -33,8 +34,9 @@ const findClosestPointInLine = (point, path, distanceFn) => {
33
34
  continue;
34
35
  target = closestPoint;
35
36
  min = distance;
37
+ idx = index;
36
38
  }
37
- return { point: target, distance: min };
39
+ return { point: target, distance: min, index: idx };
38
40
  };
39
41
  const floatEqual = (x1, x2) => {
40
42
  return Math.abs(x1 - x2) < 1e4 * Number.EPSILON;
@@ -4,3 +4,17 @@ import type { Point } from "../types/interface";
4
4
  * @returns 1 在内部, 0 边界上 , -1 在外部
5
5
  */
6
6
  export declare function pointInPolygon(point: Point, polygon: Point[]): 1 | 0 | -1;
7
+ export declare const distanceBetweenTwoPoints: (from: Point, to: Point) => number;
8
+ /**
9
+ * 计算折线(按顺序连接各点)总长度。
10
+ */
11
+ export declare const computeLineLength: (line: Point[]) => number;
12
+ /**
13
+ * 计算从起点指向终点的初始方位角(heading)。
14
+ * 说明:
15
+ * - 基于球面大圆航线计算(WGS84 半径近似),与常见地图 SDK 的 heading 含义一致
16
+ * - 返回范围为 [-180, 180](度):0 表示正北,正值为东偏北,负值为西偏南
17
+ * - 起终点经纬完全相同返回 0
18
+ * @returns 初始方位角(度)
19
+ */
20
+ export declare const computeLineAngle: (from: Point, to: Point) => number;
@@ -22,6 +22,52 @@ function pointInPolygon(point, polygon) {
22
22
  }
23
23
  return inside ? 1 : -1;
24
24
  }
25
+ const distanceBetweenTwoPoints = (from, to) => {
26
+ const [lng1, lat1] = from;
27
+ const [lng2, lat2] = to;
28
+ if (lng1 === lng2 && lat1 === lat2)
29
+ return 0;
30
+ const toRad = (deg) => deg * Math.PI / 180;
31
+ const R = 6378137;
32
+ const phi1 = toRad(lat1);
33
+ const phi2 = toRad(lat2);
34
+ const dPhi = toRad(lat2 - lat1);
35
+ const dLambda = toRad(lng2 - lng1);
36
+ const a = Math.sin(dPhi / 2) * Math.sin(dPhi / 2) + Math.cos(phi1) * Math.cos(phi2) * Math.sin(dLambda / 2) * Math.sin(dLambda / 2);
37
+ const c = 2 * Math.asin(Math.min(1, Math.sqrt(a)));
38
+ return R * c;
39
+ };
40
+ const computeLineLength = (line) => {
41
+ var _a;
42
+ if (!Array.isArray(line) || line.length < 2)
43
+ return 0;
44
+ let totalLength = 0;
45
+ for (let i = 1; i < line.length; i++) {
46
+ totalLength += (_a = distanceBetweenTwoPoints(line[i - 1], line[i])) != null ? _a : 0;
47
+ }
48
+ return totalLength;
49
+ };
50
+ const computeLineAngle = (from, to) => {
51
+ const [lng1, lat1] = from;
52
+ const [lng2, lat2] = to;
53
+ if (lng1 === lng2 && lat1 === lat2)
54
+ return 0;
55
+ const toRad = (deg) => deg * Math.PI / 180;
56
+ const toDeg = (rad) => rad * 180 / Math.PI;
57
+ const phi1 = toRad(lat1);
58
+ const phi2 = toRad(lat2);
59
+ const lambda1 = toRad(lng1);
60
+ const lambda2 = toRad(lng2);
61
+ const deltaLambda = lambda2 - lambda1;
62
+ const y = Math.sin(deltaLambda) * Math.cos(phi2);
63
+ const x = Math.cos(phi1) * Math.sin(phi2) - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda);
64
+ let heading = toDeg(Math.atan2(y, x));
65
+ heading = (heading + 540) % 360 - 180;
66
+ return heading;
67
+ };
25
68
  export {
69
+ computeLineAngle,
70
+ computeLineLength,
71
+ distanceBetweenTwoPoints,
26
72
  pointInPolygon
27
73
  };