@heycar/heycars-map 0.2.8 → 0.2.10

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 (72) hide show
  1. package/dist/Demo/Demo.d.ts +2 -0
  2. package/dist/Demo/DemoBusinessQuoting.d.ts +1 -0
  3. package/dist/Demo/DemoBusinessRecomendPlace.d.ts +1 -0
  4. package/dist/Demo/DemoBusinessTaxiEnd.d.ts +4 -0
  5. package/dist/Demo/DemoBusinessTaxiService.d.ts +1 -0
  6. package/dist/api/contants.d.ts +2 -0
  7. package/dist/business-components/AddressBox/AddressBox.d.ts +2 -1
  8. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +5 -3
  9. package/dist/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +7 -0
  10. package/dist/business-components/BusinessTaxiEndMap/index.d.ts +1 -0
  11. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +7 -0
  12. package/dist/business-components/PassengerCircle/PassengerCircle.d.ts +2 -1
  13. package/dist/business-components/PickupPoints/PickupPoints.d.ts +2 -1
  14. package/dist/components/MapProvider/MapProvider.d.ts +2 -1
  15. package/dist/hooks/useMapAutoComplete.d.ts +3 -3
  16. package/dist/hooks/useMapLog.d.ts +4 -0
  17. package/dist/hooks/useMapPlace.d.ts +3 -3
  18. package/dist/hooks/useMapRecomendPlace.d.ts +10 -7
  19. package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +1 -1
  20. package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +2 -2
  21. package/dist/hooks-business/useLagecyMapRecomendPlace.d.ts +2 -2
  22. package/dist/index.cjs +52 -52
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1015 -938
  25. package/dist/types/interface.d.ts +1 -1
  26. package/dist/utils/helper.d.ts +2 -0
  27. package/package.json +1 -1
  28. package/src/App.tsx +21 -7
  29. package/src/{components/Demo → Demo/CityBound}/SearchDemo.tsx +2 -2
  30. package/src/{components/Demo → Demo}/Demo.tsx +13 -13
  31. package/src/Demo/DemoBusinessQuoting.tsx +18 -0
  32. package/src/Demo/DemoBusinessRecomendPlace.tsx +96 -0
  33. package/src/Demo/DemoBusinessTaxiEnd.tsx +38 -0
  34. package/src/{components/Demo → Demo}/DemoBusinessTaxiService.tsx +6 -26
  35. package/src/api/contants.ts +3 -0
  36. package/src/business-components/AddressBox/AddressBox.tsx +4 -1
  37. package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +55 -41
  38. package/src/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.tsx +43 -0
  39. package/src/business-components/BusinessTaxiEndMap/index.ts +1 -0
  40. package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +5 -2
  41. package/src/business-components/PassengerCircle/PassengerCircle.tsx +4 -1
  42. package/src/business-components/PickupPoints/PickupPoints.tsx +3 -1
  43. package/src/components/MapProvider/MapProvider.tsx +4 -1
  44. package/src/hooks/useMapGeometry.ts +4 -4
  45. package/src/hooks/useMapLog.ts +12 -0
  46. package/src/hooks/useMapPlace.ts +8 -3
  47. package/src/hooks/useMapRecomendPlace.ts +34 -3
  48. package/src/index.ts +1 -0
  49. package/src/types/amap/geocoder.d.ts +2 -0
  50. package/src/types/interface.ts +1 -1
  51. package/src/utils/helper.ts +5 -0
  52. package/todo.md +6 -0
  53. package/dist/components/Demo/BusinessDemo.d.ts +0 -2
  54. package/dist/components/Demo/Demo.d.ts +0 -2
  55. package/dist/components/Demo/DemoBusinessQuoting.d.ts +0 -1
  56. package/dist/components/Demo/DemoBusinessTaxiService.d.ts +0 -2
  57. package/dist/components/Demo/Hello.d.ts +0 -17
  58. package/dist/components/Demo/HeycarDemo.d.ts +0 -3
  59. package/dist/components/Demo/index.d.ts +0 -1
  60. package/src/components/Demo/BusinessDemo.tsx +0 -117
  61. package/src/components/Demo/DemoBusinessQuoting.tsx +0 -38
  62. package/src/components/Demo/Hello.tsx +0 -15
  63. package/src/components/Demo/HeycarDemo.tsx +0 -104
  64. package/src/components/Demo/TemplateDemo.vue +0 -11
  65. package/src/components/Demo/index.ts +0 -1
  66. /package/dist/{components/Demo → Demo/CityBound}/SearchDemo.d.ts +0 -0
  67. /package/dist/{components/Demo → Demo/CityBound}/country.d.ts +0 -0
  68. /package/dist/{components/Demo → Demo/CityBound}/searchResult.d.ts +0 -0
  69. /package/dist/{components/Demo → Demo}/Demo.css.d.ts +0 -0
  70. /package/src/{components/Demo → Demo/CityBound}/country.ts +0 -0
  71. /package/src/{components/Demo → Demo/CityBound}/searchResult.ts +0 -0
  72. /package/src/{components/Demo → Demo}/Demo.css.ts +0 -0
@@ -7,7 +7,7 @@ export type Place = {
7
7
  lat: number;
8
8
  name: string;
9
9
  cityName?: string;
10
- cityId?: string;
10
+ countryName?: string;
11
11
  };
12
12
  export interface AutoCompletePlace extends Place {
13
13
  placeId?: string;
@@ -0,0 +1,2 @@
1
+ import type { Place } from "../types/interface";
2
+ export declare const isPlace: (place: Partial<Place>) => place is Place;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
package/src/App.tsx CHANGED
@@ -1,13 +1,27 @@
1
1
  import { defineComponent } from "vue-demi";
2
- import { HeycarDemo } from "./components/Demo/HeycarDemo";
2
+ import { MapProvider } from "./components/MapProvider";
3
+ import { DemoBusinessTaxiEnd } from "./Demo/DemoBusinessTaxiEnd";
4
+
5
+ const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
6
+ const gmapId = import.meta.env.VITE_GMAP_MAP_ID;
7
+ const amapApiKey = import.meta.env.VITE_AMAP_API_KEY;
8
+ const amapApiSecret = import.meta.env.VITE_AMAP_API_SECRET;
3
9
 
4
10
  export const App = defineComponent({
5
11
  setup() {
6
- // return () => <Hello class={"helloclass2"} qyc={2} style={{ color: "red" }} />;
7
- // return () => <ABusinessDemo />;
8
- // return () => <SearchDemo />;
9
- // return () => <DemoBusinessTaxiService />;
10
- // return () => <DemoBusinessQuoting />;
11
- return () => <HeycarDemo />;
12
+ return () => (
13
+ <MapProvider
14
+ amapKey={amapApiKey}
15
+ amapSecret={amapApiSecret}
16
+ gmapId={gmapId}
17
+ gmapKey={gmapApiKey}
18
+ supplier={"amap"}
19
+ >
20
+ {/* <DemoBusinessRecomendPlace /> */}
21
+ {/* <DemoBusinessQuoting /> */}
22
+ {/* <DemoBusinessTaxiService /> */}
23
+ <DemoBusinessTaxiEnd />
24
+ </MapProvider>
25
+ );
12
26
  },
13
27
  });
@@ -1,9 +1,9 @@
1
1
  import { watchPostEffect } from "vue-demi";
2
+ import { HeycarMap, MapProvider } from "../../components/MapProvider/MapProvider";
2
3
  import { useHeycarMap } from "../../hooks/useHeycarMap";
3
4
  import { defineSetup } from "../../types/helper";
4
- import { HeycarMap, MapProvider } from "../MapProvider/MapProvider";
5
+ import * as css from "../Demo.css";
5
6
  import { citiesWithCountry } from "./country";
6
- import * as css from "./Demo.css";
7
7
  import { searchResult } from "./searchResult";
8
8
 
9
9
  const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
@@ -1,17 +1,17 @@
1
1
  import { ref } from "vue-demi";
2
- import { defineSetup } from "../../types/helper";
3
- import { Amap } from "../Amap";
4
- import { AmapInfoWindow } from "../AmapInfoWindow";
5
- import { AmapLoader } from "../AmapLoader";
6
- import { AmapMarker } from "../AmapMarker";
7
- import { AmapPolygon } from "../AmapPolygon";
8
- import { AmapPolyline } from "../AmapPolyline";
9
- import { Gmap } from "../Gmap";
10
- import { GmapInfoWindow } from "../GmapInfoWindow";
11
- import { GmapLoader } from "../GmapLoader";
12
- import { GmapMarker } from "../GmapMarker";
13
- import { GmapPolygon } from "../GmapPolygon";
14
- import { GmapPolyline } from "../GmapPolyline";
2
+ import { Amap } from "../components/Amap";
3
+ import { AmapInfoWindow } from "../components/AmapInfoWindow";
4
+ import { AmapLoader } from "../components/AmapLoader";
5
+ import { AmapMarker } from "../components/AmapMarker";
6
+ import { AmapPolygon } from "../components/AmapPolygon";
7
+ import { AmapPolyline } from "../components/AmapPolyline";
8
+ import { Gmap } from "../components/Gmap";
9
+ import { GmapInfoWindow } from "../components/GmapInfoWindow";
10
+ import { GmapLoader } from "../components/GmapLoader";
11
+ import { GmapMarker } from "../components/GmapMarker";
12
+ import { GmapPolygon } from "../components/GmapPolygon";
13
+ import { GmapPolyline } from "../components/GmapPolyline";
14
+ import { defineSetup } from "../types/helper";
15
15
 
16
16
  import * as css from "./Demo.css";
17
17
  const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
@@ -0,0 +1,18 @@
1
+ import { BusinessQuotingMap } from "../business-components/BusinessQuotingMap";
2
+ import { useBusinessQuotingMap } from "../hooks-business/useBusinessQuotingMap";
3
+ import { defineSetup } from "../types/helper";
4
+ import * as css from "./Demo.css";
5
+
6
+ export const DemoBusinessQuoting = defineSetup(function DemoBusinessQuoting() {
7
+ const { setMap, registerFitVeiw } = useBusinessQuotingMap();
8
+ return () => (
9
+ <BusinessQuotingMap
10
+ class={css.demo}
11
+ from={{ lng: 121.4, lat: 31.2, name: "from place name" }}
12
+ to={{ lng: 121.5, lat: 31.4, name: "to place name" }}
13
+ renderDescription={({ distance, duration }) => `全程 *${distance}公里* 约行驶 *${duration}*`}
14
+ mapRef={setMap}
15
+ registerOverlay={registerFitVeiw}
16
+ />
17
+ );
18
+ });
@@ -0,0 +1,96 @@
1
+ import { computed } from "vue-demi";
2
+ import {
3
+ BusinessRecomendPlaceMap,
4
+ BusinessRecomendPlaceMapProps,
5
+ } from "../business-components/BusinessRecomendPlaceMap";
6
+ import { useBusinessMapAutoComplete } from "../hooks-business/useBusinessMapAutoComplete";
7
+ import { useBusinessRecomendPlaceMap } from "../hooks-business/useBusinessRecomendPlaceMap";
8
+ import { defineSetup } from "../types/helper";
9
+ import * as css from "./Demo.css";
10
+
11
+ const SomeAutoComplete = defineSetup(function SomeAutoComplete(props: { cityName: string }) {
12
+ const { autoCompletePlaces, handleKeywordInput, setCity } = useBusinessMapAutoComplete({
13
+ cityNameRef: computed(() => props.cityName),
14
+ });
15
+ (window as any).setCity = setCity;
16
+ return () => {
17
+ const list = autoCompletePlaces.value.map((place) => (
18
+ <div>
19
+ {place.lng} | {place.lat} | {place.name} | {place.description}
20
+ </div>
21
+ ));
22
+ return (
23
+ <div>
24
+ <div>
25
+ <input onInput={handleKeywordInput} />
26
+ </div>
27
+ {list}
28
+ </div>
29
+ );
30
+ };
31
+ });
32
+
33
+ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecomendPlace() {
34
+ const getRecomendPlace: BusinessRecomendPlaceMapProps["getRecomendPlace"] = async (
35
+ place,
36
+ context
37
+ ) => {
38
+ const { lat, lng } = place;
39
+ console.log("getRecomendPlace context?.source = ", context?.source);
40
+ return [
41
+ {
42
+ address: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
43
+ distance: 68,
44
+ lat: 1.2961134,
45
+ lng: 103.7722912,
46
+ name: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
47
+ reqFrom: "Recent",
48
+ },
49
+ {
50
+ address: "10 Architecture Drive, Singapore",
51
+ distance: 71,
52
+ lat: 1.2969847,
53
+ lng: 103.7714507,
54
+ name: "Centre for English Language Communication (CELC)",
55
+ reqFrom: "public",
56
+ },
57
+ {
58
+ address: "10 Kent Ridge Crescent, #01-02 Block AS8",
59
+ distance: 75,
60
+ lat: 1.295979,
61
+ lng: 103.7720608,
62
+ name: "The Coffee Roaster Cafe @ NUS",
63
+ reqFrom: "public",
64
+ },
65
+ ];
66
+
67
+ return [
68
+ { lat: lat + 0.0001, lng: lng + 0.0001, name: "place name 1" },
69
+ { lat: lat + 0.002, lng: lng + 0.002, name: "place name 2" },
70
+ ];
71
+ };
72
+ const { centerPlace, placeCandidates, setCenterPlaceByRecomand, mapContext, apiMapDistance } =
73
+ useBusinessRecomendPlaceMap();
74
+ (window as any).setCenterPlaceByRecomand = setCenterPlaceByRecomand;
75
+ return () => {
76
+ return (
77
+ <div>
78
+ placeCandidates: {placeCandidates} <br />
79
+ centerPlace: {centerPlace.lng} | {centerPlace.lat} | {centerPlace.name} |{" "}
80
+ {centerPlace.cityName} | {centerPlace.countryName} <br />
81
+ <SomeAutoComplete cityName="Taiwan"></SomeAutoComplete>
82
+ <BusinessRecomendPlaceMap
83
+ log
84
+ class={css.demo}
85
+ unavailableTitle={"当前区域暂未开通服务"}
86
+ noRecomendDescription={"附近无推荐上车地点"}
87
+ recomendDescription={"最佳上车地点"}
88
+ geoDefaultPosition={[103.771994, 1.296648]}
89
+ getRecomendPlace={getRecomendPlace}
90
+ mapContext={mapContext}
91
+ onGeoError={(e) => console.log("onGeoError e = ", e)}
92
+ />
93
+ </div>
94
+ );
95
+ };
96
+ });
@@ -0,0 +1,38 @@
1
+ import { defineComponent } from "vue";
2
+ import { BusinessTaxiEndMap } from "../business-components/BusinessTaxiEndMap";
3
+ import * as css from "./Demo.css";
4
+
5
+ export const DemoBusinessTaxiEnd = defineComponent({
6
+ name: "DemoBusinessTaxiEnd",
7
+ data() {
8
+ return {
9
+ from: {},
10
+ to: {},
11
+ };
12
+ },
13
+ created() {
14
+ setTimeout(() => {
15
+ this.from = {
16
+ lng: 103.7719939,
17
+ lat: 1.296648,
18
+ name: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
19
+ };
20
+ this.to = {
21
+ lng: 103.781421,
22
+ lat: 1.283855,
23
+ name: "虎豹别墅 (Haw Par Villa)",
24
+ };
25
+ }, 2000);
26
+ },
27
+ render() {
28
+ const { from, to } = this;
29
+ return (
30
+ <div>
31
+ <div>
32
+ {JSON.stringify(from)} | {JSON.stringify(to)}
33
+ </div>
34
+ <BusinessTaxiEndMap class={css.demo} from={from} to={to} log />
35
+ </div>
36
+ );
37
+ },
38
+ });
@@ -1,38 +1,18 @@
1
- import { BusinessTaxiServiceMap } from "../../business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap";
2
- import { useBusinessTaxiServiceMap } from "../../hooks-business/useBusinessTaxiServiceMap";
3
- import { defineSetup } from "../../types/helper";
4
- import type { Point } from "../../types/interface";
5
- import { MapProvider } from "../MapProvider/MapProvider";
1
+ import { BusinessTaxiServiceMap } from "../business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap";
2
+ import { useBusinessTaxiServiceMap } from "../hooks-business/useBusinessTaxiServiceMap";
3
+ import { defineSetup } from "../types/helper";
4
+ import type { Point } from "../types/interface";
6
5
  import * as css from "./Demo.css";
7
6
 
8
- const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
9
- const gmapId = import.meta.env.VITE_GMAP_MAP_ID;
10
- const amapApiKey = import.meta.env.VITE_AMAP_API_KEY;
11
- const amapApiSecret = import.meta.env.VITE_AMAP_API_SECRET;
12
-
13
7
  export const DemoBusinessTaxiService = defineSetup(function DemoBusinessTaxiService() {
14
- return () => (
15
- <MapProvider
16
- amapKey={amapApiKey}
17
- amapSecret={amapApiSecret}
18
- gmapId={gmapId}
19
- gmapKey={gmapApiKey}
20
- supplier={"amap"}
21
- >
22
- <TaxiCarServicePage />
23
- </MapProvider>
24
- );
25
- });
26
-
27
- export const TaxiCarServicePage = defineSetup(function TaxiCarServicePage() {
28
- const { setMap, setFitView, registerFitVeiw } = useBusinessTaxiServiceMap();
8
+ const { setMap, registerFitVeiw } = useBusinessTaxiServiceMap();
29
9
  const getDriverPosition = () => Promise.resolve([121.42, 31.25] as Point);
30
10
  return () => (
31
11
  <BusinessTaxiServiceMap
32
12
  class={css.demo}
33
13
  from={{ lng: 121.4, lat: 31.2, name: "from place name" }}
34
14
  to={{ lng: 121.5, lat: 31.4, name: "to place name" }}
35
- driverStatus="book-driverStartService"
15
+ driverStatus="completed"
36
16
  bookDispatchingTitle="2月14日 11:00 用车"
37
17
  bookDispatchedTitle="司机位置将在临近出发时间展示"
38
18
  dispatchingTitle="正在为您搜索附近司机"
@@ -0,0 +1,3 @@
1
+ import type { Point } from "../types/interface";
2
+
3
+ export const BEIJIN_POINT: Point = [116.2317, 39.5427];
@@ -3,6 +3,7 @@ import imgArrowRight from "../../assets/icons/svg/arrow-right.svg";
3
3
  import imgPlaceCircle from "../../assets/icons/svg/place-circle.svg";
4
4
  import { AmapMarker } from "../../components/AmapMarker";
5
5
  import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView/GmapAdvancedMarkerView";
6
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
6
7
  import { useMapSupplier } from "../../hooks/useMapSupplier";
7
8
  import { createElement, defineSetup } from "../../types/helper";
8
9
  import type { Point } from "../../types/interface";
@@ -11,13 +12,14 @@ import { vec2lnglat } from "../../utils/transform";
11
12
  import { AAddressLocator, GAddressLocator } from "../AddressLocator";
12
13
  import * as css from "./AddressBox.css";
13
14
 
14
- export interface AddressBoxProps {
15
+ export interface AddressBoxProps extends MapLogProps {
15
16
  type: "box" | "locator";
16
17
  position: Point;
17
18
  title: string;
18
19
  description?: string;
19
20
  }
20
21
  export const AAddressBox = defineSetup(function AAddressBox(props: AddressBoxProps) {
22
+ useMapLog(props, "AAddressBox");
21
23
  const contentRef = computed(
22
24
  () => `
23
25
  <div class="${css.addressBoxLayout}">
@@ -42,6 +44,7 @@ export const AAddressBox = defineSetup(function AAddressBox(props: AddressBoxPro
42
44
  });
43
45
 
44
46
  export const GAddressBox = defineSetup(function GAddressBox(props: AddressBoxProps) {
47
+ useMapLog(props, "GAddressBox");
45
48
  const contentRef = computed(() =>
46
49
  createDom(
47
50
  "div",
@@ -4,6 +4,7 @@ import type { BusinessRecomendPlaceContext } from "../../hooks-business/useBusin
4
4
  import { useGeoLocation, UseGeoLocationProps } from "../../hooks/useGeoLocation";
5
5
  import { useHeycarMap } from "../../hooks/useHeycarMap";
6
6
  import { useMapDrag, UseMapDragProps } from "../../hooks/useMapDrag";
7
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
7
8
  import type { UseMapPlaceProps } from "../../hooks/useMapPlace";
8
9
  import { useMapRecomendPlace, UseMapRecomendPlaceProps } from "../../hooks/useMapRecomendPlace";
9
10
  import { useMapSupplier } from "../../hooks/useMapSupplier";
@@ -20,9 +21,11 @@ export interface CenterPlaceSource {
20
21
  }
21
22
  export interface BusinessRecomendPlaceMapProps
22
23
  extends Omit<HeycarMapProps, "center" | "zoom" | "mapRef">,
23
- Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace"> {
24
- title: string;
25
- description: string;
24
+ Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace">,
25
+ MapLogProps {
26
+ unavailableTitle: string;
27
+ recomendDescription: string;
28
+ noRecomendDescription: string;
26
29
  geoDefaultPosition?: Point;
27
30
  mapContext: BusinessRecomendPlaceContext;
28
31
  onLoadGeoLocation?: UseGeoLocationProps["onLoad"];
@@ -35,6 +38,7 @@ export interface BusinessRecomendPlaceMapProps
35
38
  }
36
39
  export const BusinessRecomendPlaceMap = defineLagecySetup(
37
40
  (props: BusinessRecomendPlaceMapProps, { emit }) => {
41
+ useMapLog(props, "BusinessRecomendPlaceMap");
38
42
  const { geoDefaultPosition, getRecomendPlace, mapContext } = props;
39
43
  const { mapRef, setMap, panTo } = useHeycarMap();
40
44
  const { readyPromise } = useMapSupplier();
@@ -94,37 +98,39 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
94
98
  emit("changeByDrag", point);
95
99
  },
96
100
  });
97
- const { updatePlace, updateRecomandPlace, placeCandidates } = useMapRecomendPlace({
98
- pointRef: centerPoint,
99
- context: centerSource,
100
- getRecomendPlace,
101
- getLimit: (context) => {
102
- const source = context?.source;
103
- switch (source) {
104
- case "drag":
105
- case "api":
106
- return RECOMMEND_PLACE_LIMIT;
107
- case "geo":
108
- case "default":
109
- return Infinity;
110
- default:
111
- throw new Error(`MyError: should not call getLimit on source: ${source}`);
112
- }
113
- },
114
- onChangePlace: (place) => {
115
- Object.assign(centerPlace, { ...place });
116
- if (centerSource.source !== "recomend") {
117
- updateRecomandPlace();
118
- }
119
- emit("changePlace", place);
120
- },
121
- onChange: (place) => {
122
- centerSource.source = "recomend";
123
- Object.assign(centerPlace, { ...place });
124
- updatePlace();
125
- emit("changeRecomandPlace", place);
126
- },
127
- });
101
+ const { updatePlace, updateRecomandPlace, placeCandidates, availableRef } = useMapRecomendPlace(
102
+ {
103
+ pointRef: centerPoint,
104
+ context: centerSource,
105
+ getRecomendPlace,
106
+ getLimit: (context) => {
107
+ const source = context?.source;
108
+ switch (source) {
109
+ case "drag":
110
+ case "api":
111
+ return RECOMMEND_PLACE_LIMIT;
112
+ case "geo":
113
+ case "default":
114
+ return Infinity;
115
+ default:
116
+ throw new Error(`MyError: should not call getLimit on source: ${source}`);
117
+ }
118
+ },
119
+ onChangePlace: (place) => {
120
+ Object.assign(centerPlace, { ...place });
121
+ if (centerSource.source !== "recomend") {
122
+ updateRecomandPlace();
123
+ }
124
+ emit("changePlace", place);
125
+ },
126
+ onChange: (place) => {
127
+ centerSource.source = "recomend";
128
+ Object.assign(centerPlace, { ...place });
129
+ updatePlace();
130
+ emit("changeRecomandPlace", place);
131
+ },
132
+ }
133
+ );
128
134
  watchEffect(() => {
129
135
  mapContext.onChangeCenterPlace({ ...centerPlace });
130
136
  });
@@ -132,26 +138,34 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
132
138
  mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
133
139
  });
134
140
  return () => {
141
+ const description = !availableRef.value
142
+ ? undefined
143
+ : placeCandidates.value.length > 0
144
+ ? props.recomendDescription
145
+ : props.noRecomendDescription;
135
146
  return (
136
- <HeycarMap center={centerPoint.value} zoom={18} mapRef={setMap}>
147
+ <HeycarMap center={centerPoint.value} zoom={18} mapRef={setMap} log={props.log}>
137
148
  <PassengerCircle position={geoPosition.value} />
138
- <PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} />
149
+ <PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} log={props.log} />
139
150
  <AddressBox
140
151
  position={centerPoint.value}
141
- title={props.title}
142
- description={props.description}
143
- type={isDragging ? "locator" : "box"}
152
+ title={availableRef.value ? centerPlace.name : props.unavailableTitle}
153
+ description={description}
154
+ type={isDragging.value ? "locator" : "box"}
155
+ log={props.log}
144
156
  />
145
157
  </HeycarMap>
146
158
  );
147
159
  };
148
160
  }
149
161
  ).props([
150
- "description",
162
+ "log",
163
+ "unavailableTitle",
164
+ "recomendDescription",
165
+ "noRecomendDescription",
151
166
  "fallback",
152
167
  "geoDefaultPosition",
153
168
  "getRecomendPlace",
154
169
  "loading",
155
170
  "mapContext",
156
- "title",
157
171
  ]);
@@ -0,0 +1,43 @@
1
+ import { BEIJIN_POINT } from "../../api/contants";
2
+ import { HeycarMap } from "../../components/MapProvider";
3
+ import { useHeycarMap } from "../../hooks/useHeycarMap";
4
+ import { useMapFitView } from "../../hooks/useMapFitView";
5
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
6
+ import { defineSetup } from "../../types/helper";
7
+ import type { Place, Point } from "../../types/interface";
8
+ import { isPlace } from "../../utils/helper";
9
+ import { place2point } from "../../utils/transform";
10
+ import { SectionEndService } from "../BusinessTaxiServiceMap";
11
+
12
+ export interface BusinessTaxiEndMapProps extends MapLogProps {
13
+ from: Partial<Place>;
14
+ to: Partial<Place>;
15
+ }
16
+ export const BusinessTaxiEndMap = defineSetup((props: BusinessTaxiEndMapProps) => {
17
+ useMapLog(props, "BusinessTaxiEndMap");
18
+ const { mapRef, setMap } = useHeycarMap();
19
+ const { registerFitVeiw, setFitView } = useMapFitView({
20
+ mapRef,
21
+ autoFitTimeout: 5000,
22
+ padding: [25, 20, 15, 15],
23
+ });
24
+ return () => {
25
+ const { from, to } = props;
26
+ const isReady = isPlace(from) && isPlace(to);
27
+ const center = isReady ? place2point(from) : ([...BEIJIN_POINT] as Point);
28
+ const zoom = isReady ? 13 : 3;
29
+ return (
30
+ <HeycarMap center={center} zoom={zoom} mapRef={setMap} log={props.log}>
31
+ {isReady && (
32
+ <SectionEndService
33
+ from={from}
34
+ to={to}
35
+ registerOverlay={registerFitVeiw}
36
+ onMapMounted={setFitView}
37
+ log={props.log}
38
+ />
39
+ )}
40
+ </HeycarMap>
41
+ );
42
+ };
43
+ });
@@ -0,0 +1 @@
1
+ export * from "./BusinessTaxiEndMap";
@@ -2,6 +2,7 @@ import { ref, watch } from "vue-demi";
2
2
  import { HeycarMap, HeycarMapProps } from "../../components/MapProvider";
3
3
  import { useGeoLocation } from "../../hooks/useGeoLocation";
4
4
  import { MapMountedProps, onMapMounted } from "../../hooks/useMap";
5
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
5
6
  import type { MROP } from "../../hooks/useOverlay";
6
7
  import { defineLagecySetup, defineSetup } from "../../types/helper";
7
8
  import type { DriverStatus, Place, Point } from "../../types/interface";
@@ -198,12 +199,14 @@ const SectionCanceled = defineSetup((props: SectionCanceledProps, { emit }) => {
198
199
  };
199
200
  });
200
201
 
201
- type SectionEndServiceProps = MROP &
202
+ export type SectionEndServiceProps = MROP &
203
+ MapLogProps &
202
204
  MapMountedProps & {
203
205
  from: Place;
204
206
  to: Place;
205
207
  };
206
- const SectionEndService = defineSetup((props: SectionEndServiceProps, { emit }) => {
208
+ export const SectionEndService = defineSetup((props: SectionEndServiceProps, { emit }) => {
209
+ useMapLog(props, "SectionEndService");
207
210
  onMapMounted(() => emit("mapMounted"));
208
211
  return () => {
209
212
  const { from: fromPlace, to: toPlace, registerOverlay } = props;
@@ -3,6 +3,7 @@ import imgPassengerCircle from "../../assets/icons/svg/passenger-circle.svg";
3
3
  import imgPlaceCircle from "../../assets/icons/svg/place-circle.svg";
4
4
  import { AmapMarker } from "../../components/AmapMarker";
5
5
  import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView";
6
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
6
7
  import { useMapSupplier } from "../../hooks/useMapSupplier";
7
8
  import type { AmapOverlay, GmapOverlay, MapRegisterOverlayProps } from "../../hooks/useOverlay";
8
9
  import { createElement, defineSetup } from "../../types/helper";
@@ -11,13 +12,14 @@ import { vec2lnglat } from "../../utils/transform";
11
12
 
12
13
  import * as css from "./PassengerCircle.css";
13
14
 
14
- interface PassengerCircleProps<T> extends MapRegisterOverlayProps<T> {
15
+ interface PassengerCircleProps<T> extends MapRegisterOverlayProps<T>, MapLogProps {
15
16
  position: [number, number];
16
17
  size?: "small" | "large";
17
18
  }
18
19
  export const APassengerCircle = defineSetup(function APassengerCircle(
19
20
  props: PassengerCircleProps<AmapOverlay>
20
21
  ) {
22
+ useMapLog(props, "APassengerCircle");
21
23
  const contentRef = computed(() => {
22
24
  const { size = "large" } = props;
23
25
  const src = size === "large" ? imgPassengerCircle : imgPlaceCircle;
@@ -40,6 +42,7 @@ export const APassengerCircle = defineSetup(function APassengerCircle(
40
42
  export const GPassengerCircle = defineSetup(function GPassengerCircle(
41
43
  props: PassengerCircleProps<GmapOverlay>
42
44
  ) {
45
+ useMapLog(props, "GPassengerCircle");
43
46
  const contentRef = computed(() => {
44
47
  const { size = "large" } = props;
45
48
  const src = size === "large" ? imgPassengerCircle : imgPlaceCircle;
@@ -1,13 +1,15 @@
1
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
1
2
  import { defineSetup } from "../../types/helper";
2
3
  import type { Place } from "../../types/interface";
3
4
  import { place2point } from "../../utils/transform";
4
5
  import { PlaceCircle } from "../PlaceCircle";
5
6
 
6
- export interface PickupPointsProps {
7
+ export interface PickupPointsProps extends MapLogProps {
7
8
  places: Place[];
8
9
  onClick?: (value: Place) => any;
9
10
  }
10
11
  export const PickupPoints = defineSetup(function PickupPoints(props: PickupPointsProps, { emit }) {
12
+ useMapLog(props, "PickupPoints");
11
13
  return () => (
12
14
  <div>
13
15
  {props.places.map((place) => (
@@ -1,5 +1,6 @@
1
1
  import type { SetMap } from "../../hooks/useHeycarMap";
2
2
  import { GmapLoaderProps, Status, useMapLoader, UseMapLoaderProps } from "../../hooks/useMapLoader";
3
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
3
4
  import { MapSupplierPayolad, provideMapSupplier, useMapSupplier } from "../../hooks/useMapSupplier";
4
5
  import { defineLagecySetup } from "../../types/helper";
5
6
  import { language2vectorMapForeign, vec2lnglat } from "../../utils/transform";
@@ -25,7 +26,8 @@ export const MapProvider = defineLagecySetup(function MapProvider(
25
26
 
26
27
  export interface HeycarMapProps
27
28
  extends Pick<GmapLoaderProps, "fallback" | "loading">,
28
- Pick<AmapProps, "center" | "zoom"> {
29
+ Pick<AmapProps, "center" | "zoom">,
30
+ MapLogProps {
29
31
  mapRef?: SetMap<AMap.Map> | SetMap<google.maps.Map>;
30
32
  onDragEnd?: (value: [number, number]) => any;
31
33
  }
@@ -33,6 +35,7 @@ export const HeycarMap = defineLagecySetup(function HeycarMap(
33
35
  props: HeycarMapProps,
34
36
  { slots, emit }
35
37
  ) {
38
+ useMapLog(props, "HeycarMap");
36
39
  const payload = useMapSupplier();
37
40
  const gmapDebouncedEmit: GmapProps["onDragEnd"] = ({ target }) => {
38
41
  const { lng, lat } = target.getCenter() as google.maps.LatLng;