@heycar/heycars-map 0.2.7 → 0.2.9

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 (66) 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 +1 -0
  5. package/dist/Demo/DemoBusinessTaxiService.d.ts +1 -0
  6. package/dist/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +2 -0
  7. package/dist/business-components/AbsoluteAddressBox/index.d.ts +1 -0
  8. package/dist/business-components/AddressBox/AddressBox.d.ts +1 -2
  9. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +25 -0
  10. package/dist/business-components/BusinessRecomendPlaceMap/index.d.ts +1 -0
  11. package/dist/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +6 -0
  12. package/dist/business-components/BusinessTaxiEndMap/index.d.ts +1 -0
  13. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +6 -0
  14. package/dist/hooks/useGeoLocation.d.ts +1 -0
  15. package/dist/hooks/useMapRecomendPlace.d.ts +4 -1
  16. package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +27 -0
  17. package/dist/hooks-business/{useBusinessMapRecomendPlace.d.ts → useLagecyMapRecomendPlace.d.ts} +2 -2
  18. package/dist/index.cjs +52 -52
  19. package/dist/index.d.ts +3 -1
  20. package/dist/index.js +1039 -907
  21. package/dist/types/interface.d.ts +1 -1
  22. package/package.json +1 -1
  23. package/src/App.tsx +21 -7
  24. package/src/{components/Demo → Demo/CityBound}/SearchDemo.tsx +2 -2
  25. package/src/{components/Demo → Demo}/Demo.tsx +13 -13
  26. package/src/Demo/DemoBusinessQuoting.tsx +18 -0
  27. package/src/Demo/DemoBusinessRecomendPlace.tsx +66 -0
  28. package/src/Demo/DemoBusinessTaxiEnd.tsx +13 -0
  29. package/src/{components/Demo → Demo}/DemoBusinessTaxiService.tsx +6 -26
  30. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.tsx +8 -0
  31. package/src/business-components/AbsoluteAddressBox/index.ts +1 -0
  32. package/src/business-components/AddressBox/AddressBox.tsx +1 -1
  33. package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +166 -0
  34. package/src/business-components/BusinessRecomendPlaceMap/index.ts +1 -0
  35. package/src/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.tsx +33 -0
  36. package/src/business-components/BusinessTaxiEndMap/index.ts +1 -0
  37. package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +22 -5
  38. package/src/business-components/PlaceCircle/PlaceCircle.tsx +15 -19
  39. package/src/hooks/useGeoLocation.ts +3 -1
  40. package/src/hooks/useMapGeometry.ts +4 -4
  41. package/src/hooks/useMapRecomendPlace.ts +34 -3
  42. package/src/hooks-business/useBusinessRecomendPlaceMap.ts +45 -0
  43. package/src/hooks-business/{useBusinessMapRecomendPlace.ts → useLagecyMapRecomendPlace.ts} +3 -2
  44. package/src/index.ts +3 -1
  45. package/src/types/interface.ts +11 -1
  46. package/todo.md +6 -0
  47. package/dist/components/Demo/BusinessDemo.d.ts +0 -2
  48. package/dist/components/Demo/Demo.d.ts +0 -2
  49. package/dist/components/Demo/DemoBusinessQuoting.d.ts +0 -1
  50. package/dist/components/Demo/DemoBusinessTaxiService.d.ts +0 -2
  51. package/dist/components/Demo/Hello.d.ts +0 -17
  52. package/dist/components/Demo/HeycarDemo.d.ts +0 -3
  53. package/dist/components/Demo/index.d.ts +0 -1
  54. package/src/components/Demo/BusinessDemo.tsx +0 -117
  55. package/src/components/Demo/DemoBusinessQuoting.tsx +0 -38
  56. package/src/components/Demo/Hello.tsx +0 -15
  57. package/src/components/Demo/HeycarDemo.tsx +0 -181
  58. package/src/components/Demo/TemplateDemo.vue +0 -11
  59. package/src/components/Demo/index.ts +0 -1
  60. /package/dist/{components/Demo → Demo/CityBound}/SearchDemo.d.ts +0 -0
  61. /package/dist/{components/Demo → Demo/CityBound}/country.d.ts +0 -0
  62. /package/dist/{components/Demo → Demo/CityBound}/searchResult.d.ts +0 -0
  63. /package/dist/{components/Demo → Demo}/Demo.css.d.ts +0 -0
  64. /package/src/{components/Demo → Demo/CityBound}/country.ts +0 -0
  65. /package/src/{components/Demo → Demo/CityBound}/searchResult.ts +0 -0
  66. /package/src/{components/Demo → Demo}/Demo.css.ts +0 -0
@@ -32,4 +32,4 @@ export interface Route {
32
32
  distance: number;
33
33
  duration: number;
34
34
  }
35
- export type DriverStatus = "dispatching" | "book-dispatching" | "dispatched" | "driverStartService" | "book-driverStartService" | "book-dispatched" | "driverArrived" | "inService" | "canceled" | "endService";
35
+ export type DriverStatus = "dispatching" | "book-dispatching" | "dispatched" | "driverStartService" | "book-driverStartService" | "book-dispatched" | "driverArrived" | "inService" | "canceled" | "endService" | "completed" | "canceling" | "banlanceRefund" | "waitBanlanceRefund" | "rechargePayed" | "waitRechargePay" | "payed" | "waitpay" | "refund" | "confirmed";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
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 { DemoBusinessTaxiService } from "./components/Demo/DemoBusinessTaxiService";
2
+ import { MapProvider } from "./components/MapProvider";
3
+ import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace";
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,66 @@
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
+ <input onInput={handleKeywordInput} />,
19
+ <div>
20
+ {place.lng} | {place.lat} | {place.name} | {place.description}
21
+ </div>,
22
+ ]);
23
+ return <div>{list}</div>;
24
+ };
25
+ });
26
+
27
+ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecomendPlace() {
28
+ const getRecomendPlace: BusinessRecomendPlaceMapProps["getRecomendPlace"] = async (
29
+ place,
30
+ context
31
+ ) => {
32
+ const { lat, lng } = place;
33
+ console.log("getRecomendPlace context?.source = ", context?.source);
34
+ return [
35
+ { lat: lat + 0.0001, lng: lng + 0.0001, name: "place name 1" },
36
+ { lat: lat + 0.002, lng: lng + 0.002, name: "place name 2" },
37
+ ];
38
+ };
39
+ const { centerPlace, placeCandidates, setCenterPlaceByRecomand, mapContext, apiMapDistance } =
40
+ useBusinessRecomendPlaceMap();
41
+ setTimeout(() => {
42
+ const distance = apiMapDistance([0, 0], [1, 1]);
43
+ console.log("distance = ", distance);
44
+ }, 2000);
45
+ (window as any).setCenterPlaceByRecomand = setCenterPlaceByRecomand;
46
+ return () => {
47
+ return (
48
+ <div>
49
+ placeCandidates: {placeCandidates} <br />
50
+ centerPlace: {centerPlace.lng} | {centerPlace.lat} | {centerPlace.name} |{" "}
51
+ {centerPlace.cityName} <br />
52
+ <SomeAutoComplete cityName="上海市"></SomeAutoComplete>
53
+ <BusinessRecomendPlaceMap
54
+ class={css.demo}
55
+ unavailableTitle={"当前区域暂未开通服务"}
56
+ noRecomendDescription={"附近无推荐上车地点"}
57
+ recomendDescription={"最佳上车地点"}
58
+ geoDefaultPosition={[121, 31]}
59
+ getRecomendPlace={getRecomendPlace}
60
+ mapContext={mapContext}
61
+ onGeoError={(e) => console.log("onGeoError e = ", e)}
62
+ />
63
+ </div>
64
+ );
65
+ };
66
+ });
@@ -0,0 +1,13 @@
1
+ import { BusinessTaxiEndMap } from "../business-components/BusinessTaxiEndMap";
2
+ import { defineSetup } from "../types/helper";
3
+ import * as css from "./Demo.css";
4
+
5
+ export const DemoBusinessTaxiEnd = defineSetup(function DemoBusinessTaxiEnd() {
6
+ return () => (
7
+ <BusinessTaxiEndMap
8
+ class={css.demo}
9
+ from={{ lng: 121.4, lat: 31.2, name: "from place name" }}
10
+ to={{ lng: 121.5, lat: 31.4, name: "to place name" }}
11
+ />
12
+ );
13
+ });
@@ -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,8 @@
1
+ import { defineSetup } from "../../types/helper";
2
+ import type { AddressBoxProps } from "../AddressBox";
3
+
4
+ export const AbsoluteAddressBox = defineSetup((props: AddressBoxProps) => {
5
+ return () => {
6
+ return <div></div>;
7
+ };
8
+ });
@@ -0,0 +1 @@
1
+ export * from "./AbsoluteAddressBox";
@@ -11,7 +11,7 @@ import { vec2lnglat } from "../../utils/transform";
11
11
  import { AAddressLocator, GAddressLocator } from "../AddressLocator";
12
12
  import * as css from "./AddressBox.css";
13
13
 
14
- interface AddressBoxProps {
14
+ export interface AddressBoxProps {
15
15
  type: "box" | "locator";
16
16
  position: Point;
17
17
  title: string;
@@ -0,0 +1,166 @@
1
+ import { computed, reactive, watchEffect } from "vue";
2
+ import { HeycarMap, HeycarMapProps } from "../../components/MapProvider";
3
+ import type { BusinessRecomendPlaceContext } from "../../hooks-business/useBusinessRecomendPlaceMap";
4
+ import { useGeoLocation, UseGeoLocationProps } from "../../hooks/useGeoLocation";
5
+ import { useHeycarMap } from "../../hooks/useHeycarMap";
6
+ import { useMapDrag, UseMapDragProps } from "../../hooks/useMapDrag";
7
+ import type { UseMapPlaceProps } from "../../hooks/useMapPlace";
8
+ import { useMapRecomendPlace, UseMapRecomendPlaceProps } from "../../hooks/useMapRecomendPlace";
9
+ import { useMapSupplier } from "../../hooks/useMapSupplier";
10
+ import { defineLagecySetup } from "../../types/helper";
11
+ import type { Place, Point } from "../../types/interface";
12
+ import { AddressBox } from "../AddressBox";
13
+ import { PassengerCircle } from "../PassengerCircle";
14
+ import { PickupPoints } from "../PickupPoints";
15
+
16
+ const RECOMMEND_PLACE_LIMIT = 30;
17
+
18
+ export interface CenterPlaceSource {
19
+ source: "default" | "geo" | "drag" | "recomend" | "api";
20
+ }
21
+ export interface BusinessRecomendPlaceMapProps
22
+ extends Omit<HeycarMapProps, "center" | "zoom" | "mapRef">,
23
+ Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace"> {
24
+ unavailableTitle: string;
25
+ recomendDescription: string;
26
+ noRecomendDescription: string;
27
+ geoDefaultPosition?: Point;
28
+ mapContext: BusinessRecomendPlaceContext;
29
+ onLoadGeoLocation?: UseGeoLocationProps["onLoad"];
30
+ onLoadDefaultGeoLocation?: UseGeoLocationProps["onLoadDefault"];
31
+ onChangeByDrag?: UseMapDragProps["onChange"];
32
+ onChangeGeoLocation?: UseGeoLocationProps["onChange"];
33
+ onChangePlace?: UseMapPlaceProps["onChange"];
34
+ onChangeRecomandPlace?: UseMapRecomendPlaceProps["onChange"];
35
+ onGeoError?: UseGeoLocationProps["onError"];
36
+ }
37
+ export const BusinessRecomendPlaceMap = defineLagecySetup(
38
+ (props: BusinessRecomendPlaceMapProps, { emit }) => {
39
+ const { geoDefaultPosition, getRecomendPlace, mapContext } = props;
40
+ const { mapRef, setMap, panTo } = useHeycarMap();
41
+ const { readyPromise } = useMapSupplier();
42
+ const centerPlace = reactive<Place>({
43
+ lng: geoDefaultPosition?.[0] ?? 0,
44
+ lat: geoDefaultPosition?.[1] ?? 0,
45
+ name: "",
46
+ cityName: undefined,
47
+ });
48
+ const centerPoint = computed<Point>(() => [centerPlace.lng, centerPlace.lat]);
49
+ const centerSource: CenterPlaceSource = { source: "geo" };
50
+ const setCenterPlaceByRecomand = (point: Point) => {
51
+ centerSource.source = "api";
52
+ centerPlace.lng = point[0];
53
+ centerPlace.lat = point[1];
54
+ updatePlace();
55
+ };
56
+ mapContext.setCenterPlaceByRecomand = setCenterPlaceByRecomand;
57
+ mapContext.panTo = panTo;
58
+ const setCenterByPlace = (place: Place) => {
59
+ centerSource.source = "api";
60
+ centerPlace.lng = place.lng;
61
+ centerPlace.lat = place.lat;
62
+ centerPlace.name = place.name;
63
+ };
64
+
65
+ const { geoPosition } = useGeoLocation({
66
+ geoDefaultPosition,
67
+ onLoad: async (value) => {
68
+ // geo 主入口
69
+ await readyPromise;
70
+ centerSource.source = "geo";
71
+ centerPlace.lng = value.position[0];
72
+ centerPlace.lat = value.position[1];
73
+ updatePlace();
74
+ emit("loadGeoLocation", value);
75
+ },
76
+ onLoadDefault: async (value) => {
77
+ // geo default position 主入口
78
+ await readyPromise;
79
+ centerSource.source = "geo";
80
+ centerPlace.lng = value.position[0];
81
+ centerPlace.lat = value.position[1];
82
+ updatePlace();
83
+ emit("loadDefaultGeoLocation", value);
84
+ },
85
+ onChange: (v) => emit("changeGeoLocation", v),
86
+ onError: (e) => emit("geoError", e),
87
+ });
88
+ const { isDragging } = useMapDrag({
89
+ mapRef,
90
+ onChange: (point) => {
91
+ centerSource.source = "drag";
92
+ centerPlace.lng = point[0];
93
+ centerPlace.lat = point[1];
94
+ updatePlace();
95
+ emit("changeByDrag", point);
96
+ },
97
+ });
98
+ const { updatePlace, updateRecomandPlace, placeCandidates, availableRef } = useMapRecomendPlace(
99
+ {
100
+ pointRef: centerPoint,
101
+ context: centerSource,
102
+ getRecomendPlace,
103
+ getLimit: (context) => {
104
+ const source = context?.source;
105
+ switch (source) {
106
+ case "drag":
107
+ case "api":
108
+ return RECOMMEND_PLACE_LIMIT;
109
+ case "geo":
110
+ case "default":
111
+ return Infinity;
112
+ default:
113
+ throw new Error(`MyError: should not call getLimit on source: ${source}`);
114
+ }
115
+ },
116
+ onChangePlace: (place) => {
117
+ Object.assign(centerPlace, { ...place });
118
+ if (centerSource.source !== "recomend") {
119
+ updateRecomandPlace();
120
+ }
121
+ emit("changePlace", place);
122
+ },
123
+ onChange: (place) => {
124
+ centerSource.source = "recomend";
125
+ Object.assign(centerPlace, { ...place });
126
+ updatePlace();
127
+ emit("changeRecomandPlace", place);
128
+ },
129
+ }
130
+ );
131
+ watchEffect(() => {
132
+ mapContext.onChangeCenterPlace({ ...centerPlace });
133
+ });
134
+ watchEffect(() => {
135
+ mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
136
+ });
137
+ return () => {
138
+ const description = !availableRef.value
139
+ ? undefined
140
+ : placeCandidates.value.length > 0
141
+ ? props.recomendDescription
142
+ : props.noRecomendDescription;
143
+ return (
144
+ <HeycarMap center={centerPoint.value} zoom={18} mapRef={setMap}>
145
+ <PassengerCircle position={geoPosition.value} />
146
+ <PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} />
147
+ <AddressBox
148
+ position={centerPoint.value}
149
+ title={availableRef.value ? centerPlace.name : props.unavailableTitle}
150
+ description={description}
151
+ type={isDragging.value ? "locator" : "box"}
152
+ />
153
+ </HeycarMap>
154
+ );
155
+ };
156
+ }
157
+ ).props([
158
+ "unavailableTitle",
159
+ "recomendDescription",
160
+ "noRecomendDescription",
161
+ "fallback",
162
+ "geoDefaultPosition",
163
+ "getRecomendPlace",
164
+ "loading",
165
+ "mapContext",
166
+ ]);
@@ -0,0 +1 @@
1
+ export * from "./BusinessRecomendPlaceMap";
@@ -0,0 +1,33 @@
1
+ import { HeycarMap } from "../../components/MapProvider";
2
+ import { useHeycarMap } from "../../hooks/useHeycarMap";
3
+ import { useMapFitView } from "../../hooks/useMapFitView";
4
+ import { defineSetup } from "../../types/helper";
5
+ import type { Place } from "../../types/interface";
6
+ import { place2point } from "../../utils/transform";
7
+ import { SectionEndService } from "../BusinessTaxiServiceMap";
8
+
9
+ export interface BusinessTaxiEndMapProps {
10
+ from: Place;
11
+ to: Place;
12
+ }
13
+ export const BusinessTaxiEndMap = defineSetup((props: BusinessTaxiEndMapProps) => {
14
+ const { mapRef, setMap } = useHeycarMap();
15
+ const { registerFitVeiw, setFitView } = useMapFitView({
16
+ mapRef,
17
+ autoFitTimeout: 5000,
18
+ padding: [25, 20, 15, 15],
19
+ });
20
+ return () => {
21
+ const { from, to } = props;
22
+ return (
23
+ <HeycarMap center={place2point(from)} zoom={13} mapRef={setMap}>
24
+ <SectionEndService
25
+ from={from}
26
+ to={to}
27
+ registerOverlay={registerFitVeiw}
28
+ onMapMounted={setFitView}
29
+ />
30
+ </HeycarMap>
31
+ );
32
+ };
33
+ });
@@ -0,0 +1 @@
1
+ export * from "./BusinessTaxiEndMap";
@@ -198,12 +198,12 @@ const SectionCanceled = defineSetup((props: SectionCanceledProps, { emit }) => {
198
198
  };
199
199
  });
200
200
 
201
- type SectionEndServiceProps = MROP &
201
+ export type SectionEndServiceProps = MROP &
202
202
  MapMountedProps & {
203
203
  from: Place;
204
204
  to: Place;
205
205
  };
206
- const SectionEndService = defineSetup((props: SectionEndServiceProps, { emit }) => {
206
+ export const SectionEndService = defineSetup((props: SectionEndServiceProps, { emit }) => {
207
207
  onMapMounted(() => emit("mapMounted"));
208
208
  return () => {
209
209
  const { from: fromPlace, to: toPlace, registerOverlay } = props;
@@ -323,16 +323,33 @@ export const BusinessTaxiServiceMap = defineLagecySetup((props: BusinessTaxiServ
323
323
  registerOverlay={registerOverlay}
324
324
  onMapMounted={setFitView}
325
325
  />
326
- ) : driverStatus === "canceled" ? (
326
+ ) : driverStatus === "canceled" || driverStatus === "canceling" ? (
327
327
  <SectionCanceled from={from} to={to} registerOverlay={registerOverlay} />
328
- ) : driverStatus === "endService" ? (
328
+ ) : driverStatus === "endService" ||
329
+ driverStatus === "completed" ||
330
+ driverStatus === "banlanceRefund" ||
331
+ driverStatus === "waitBanlanceRefund" ||
332
+ driverStatus === "rechargePayed" ||
333
+ driverStatus === "waitRechargePay" ||
334
+ driverStatus === "payed" ||
335
+ driverStatus === "waitpay" ||
336
+ driverStatus === "refund" ||
337
+ driverStatus === "confirmed" ? (
329
338
  <SectionEndService
330
339
  from={from}
331
340
  to={to}
332
341
  registerOverlay={registerOverlay}
333
342
  onMapMounted={setFitView}
334
343
  />
335
- ) : null}
344
+ ) : (
345
+ // 匹配不到就显示灰色路线
346
+ <SectionEndService
347
+ from={from}
348
+ to={to}
349
+ registerOverlay={registerOverlay}
350
+ onMapMounted={setFitView}
351
+ />
352
+ )}
336
353
  </HeycarMap>
337
354
  );
338
355
  };
@@ -7,7 +7,7 @@ import {
7
7
  } from "../../components/GmapAdvancedMarkerView";
8
8
  import { useMapSupplier } from "../../hooks/useMapSupplier";
9
9
  import { AnchorType } from "../../types/amap/marker";
10
- import { createElement, defineLagecySetup, defineSetup } from "../../types/helper";
10
+ import { createElement, defineSetup } from "../../types/helper";
11
11
  import type { Point } from "../../types/interface";
12
12
  import { createDom } from "../../utils/dom";
13
13
  import { vec2lnglat } from "../../utils/transform";
@@ -20,10 +20,7 @@ export interface PlaceCircleProps {
20
20
  hideIcon?: boolean;
21
21
  onClick?: (value: Point) => any;
22
22
  }
23
- export const APlaceCircle = defineLagecySetup(function APlaceCircle(
24
- props: PlaceCircleProps,
25
- { emit }
26
- ) {
23
+ export const APlaceCircle = defineSetup(function APlaceCircle(props: PlaceCircleProps, { emit }) {
27
24
  const textAlignRef = computed(() => props.textAlign ?? "right");
28
25
  const contentRef = computed(() => {
29
26
  const { hideIcon = false } = props;
@@ -46,20 +43,19 @@ export const APlaceCircle = defineLagecySetup(function APlaceCircle(
46
43
  console.log("on amap marker e = ", e);
47
44
  emit("click", props.position);
48
45
  };
49
- return () => (
50
- <AmapMarker
51
- position={props.position}
52
- content={props.label ? contentRef.value : contentWithoutLabelRef.value}
53
- anchor={textAlignRef.value === "left" ? AnchorType.middleRight : AnchorType.middleLeft}
54
- onClick={handleClick}
55
- />
56
- );
57
- }).props(["hideIcon", "label", "position", "textAlign"]);
46
+ return () => {
47
+ return (
48
+ <AmapMarker
49
+ position={props.position}
50
+ content={props.label ? contentRef.value : contentWithoutLabelRef.value}
51
+ anchor={textAlignRef.value === "left" ? AnchorType.middleRight : AnchorType.middleLeft}
52
+ onClick={handleClick}
53
+ />
54
+ );
55
+ };
56
+ });
58
57
 
59
- export const GPlaceCircle = defineLagecySetup(function GPlaceCircle(
60
- props: PlaceCircleProps,
61
- { emit }
62
- ) {
58
+ export const GPlaceCircle = defineSetup(function GPlaceCircle(props: PlaceCircleProps, { emit }) {
63
59
  const textAlignRef = computed(() => props.textAlign ?? "right");
64
60
  const contentRef = computed(() => {
65
61
  const { hideIcon = false } = props;
@@ -96,7 +92,7 @@ export const GPlaceCircle = defineLagecySetup(function GPlaceCircle(
96
92
  onClick={handleClick}
97
93
  />
98
94
  );
99
- }).props(["hideIcon", "label", "position", "textAlign"]);
95
+ });
100
96
 
101
97
  export const PlaceCircle = defineSetup(function PlaceCircle(props: PlaceCircleProps, { emit }) {
102
98
  const payload = useMapSupplier();
@@ -6,9 +6,10 @@ export interface UseGeoLocationProps {
6
6
  onChange?: (value: { position: Point; coordinate: GeolocationCoordinates }) => any;
7
7
  onLoad?: (value: { position: Point; coordinate: GeolocationCoordinates }) => any;
8
8
  onLoadDefault?: (value: { position: Point }) => any;
9
+ onError?: (error: GeolocationPositionError) => any;
9
10
  }
10
11
  export const useGeoLocation = (props?: UseGeoLocationProps) => {
11
- const { onChange, onLoad, onLoadDefault, geoDefaultPosition } = props ?? {};
12
+ const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props ?? {};
12
13
  const loading = ref(false);
13
14
  const readyRef = ref(false);
14
15
  const errorRef = ref<GeolocationPositionError>();
@@ -44,6 +45,7 @@ export const useGeoLocation = (props?: UseGeoLocationProps) => {
44
45
  errorRef.value = error;
45
46
  const position = props?.geoDefaultPosition;
46
47
  if (position) onLoadDefault?.({ position });
48
+ onError?.(error);
47
49
  console.log("errorRef = ", errorRef);
48
50
  },
49
51
  // todo 要不要 timeout
@@ -4,18 +4,18 @@ import { Status } from "./useMapLoader";
4
4
  import { useMapSupplier } from "./useMapSupplier";
5
5
 
6
6
  export const useAmapGeometry = () => {
7
- const { status } = useMapSupplier();
7
+ const payload = useMapSupplier();
8
8
  const apiMapDistance = (from: Point, to: Point) => {
9
- if (status !== Status.SUCCESS) return undefined;
9
+ if (payload.status !== Status.SUCCESS) return undefined;
10
10
  return AMap.GeometryUtil.distance(from, to);
11
11
  };
12
12
  return { apiMapDistance };
13
13
  };
14
14
 
15
15
  export const useGmapGeometry = () => {
16
- const { status } = useMapSupplier();
16
+ const payload = useMapSupplier();
17
17
  const apiMapDistance = (from: Point, to: Point) => {
18
- if (status !== Status.SUCCESS) return undefined;
18
+ if (payload.status !== Status.SUCCESS) return undefined;
19
19
  return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
20
20
  };
21
21
  return { apiMapDistance };