@heycar/heycars-map 0.2.7 → 0.2.8
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.
- package/dist/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +2 -0
- package/dist/business-components/AbsoluteAddressBox/index.d.ts +1 -0
- package/dist/business-components/AddressBox/AddressBox.d.ts +1 -2
- package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +24 -0
- package/dist/business-components/BusinessRecomendPlaceMap/index.d.ts +1 -0
- package/dist/hooks/useGeoLocation.d.ts +1 -0
- package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +27 -0
- package/dist/hooks-business/{useBusinessMapRecomendPlace.d.ts → useLagecyMapRecomendPlace.d.ts} +2 -2
- package/dist/index.cjs +52 -52
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1067 -996
- package/dist/types/interface.d.ts +1 -1
- package/package.json +1 -1
- package/src/App.tsx +3 -3
- package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.tsx +8 -0
- package/src/business-components/AbsoluteAddressBox/index.ts +1 -0
- package/src/business-components/AddressBox/AddressBox.tsx +1 -1
- package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +157 -0
- package/src/business-components/BusinessRecomendPlaceMap/index.ts +1 -0
- package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +20 -3
- package/src/business-components/PlaceCircle/PlaceCircle.tsx +15 -19
- package/src/components/Demo/HeycarDemo.tsx +21 -98
- package/src/hooks/useGeoLocation.ts +3 -1
- package/src/hooks-business/useBusinessRecomendPlaceMap.ts +45 -0
- package/src/hooks-business/{useBusinessMapRecomendPlace.ts → useLagecyMapRecomendPlace.ts} +3 -2
- package/src/index.ts +2 -1
- package/src/types/interface.ts +11 -1
|
@@ -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
package/src/App.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { defineComponent } from "vue-demi";
|
|
2
|
-
import {
|
|
2
|
+
import { HeycarDemo } from "./components/Demo/HeycarDemo";
|
|
3
3
|
|
|
4
4
|
export const App = defineComponent({
|
|
5
5
|
setup() {
|
|
6
6
|
// return () => <Hello class={"helloclass2"} qyc={2} style={{ color: "red" }} />;
|
|
7
7
|
// return () => <ABusinessDemo />;
|
|
8
8
|
// return () => <SearchDemo />;
|
|
9
|
-
return () => <DemoBusinessTaxiService />;
|
|
9
|
+
// return () => <DemoBusinessTaxiService />;
|
|
10
10
|
// return () => <DemoBusinessQuoting />;
|
|
11
|
-
|
|
11
|
+
return () => <HeycarDemo />;
|
|
12
12
|
},
|
|
13
13
|
});
|
|
@@ -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,157 @@
|
|
|
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
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
geoDefaultPosition?: Point;
|
|
27
|
+
mapContext: BusinessRecomendPlaceContext;
|
|
28
|
+
onLoadGeoLocation?: UseGeoLocationProps["onLoad"];
|
|
29
|
+
onLoadDefaultGeoLocation?: UseGeoLocationProps["onLoadDefault"];
|
|
30
|
+
onChangeByDrag?: UseMapDragProps["onChange"];
|
|
31
|
+
onChangeGeoLocation?: UseGeoLocationProps["onChange"];
|
|
32
|
+
onChangePlace?: UseMapPlaceProps["onChange"];
|
|
33
|
+
onChangeRecomandPlace?: UseMapRecomendPlaceProps["onChange"];
|
|
34
|
+
onGeoError?: UseGeoLocationProps["onError"];
|
|
35
|
+
}
|
|
36
|
+
export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
37
|
+
(props: BusinessRecomendPlaceMapProps, { emit }) => {
|
|
38
|
+
const { geoDefaultPosition, getRecomendPlace, mapContext } = props;
|
|
39
|
+
const { mapRef, setMap, panTo } = useHeycarMap();
|
|
40
|
+
const { readyPromise } = useMapSupplier();
|
|
41
|
+
const centerPlace = reactive<Place>({
|
|
42
|
+
lng: geoDefaultPosition?.[0] ?? 0,
|
|
43
|
+
lat: geoDefaultPosition?.[1] ?? 0,
|
|
44
|
+
name: "",
|
|
45
|
+
cityName: undefined,
|
|
46
|
+
});
|
|
47
|
+
const centerPoint = computed<Point>(() => [centerPlace.lng, centerPlace.lat]);
|
|
48
|
+
const centerSource: CenterPlaceSource = { source: "geo" };
|
|
49
|
+
const setCenterPlaceByRecomand = (point: Point) => {
|
|
50
|
+
centerSource.source = "api";
|
|
51
|
+
centerPlace.lng = point[0];
|
|
52
|
+
centerPlace.lat = point[1];
|
|
53
|
+
updatePlace();
|
|
54
|
+
};
|
|
55
|
+
mapContext.setCenterPlaceByRecomand = setCenterPlaceByRecomand;
|
|
56
|
+
mapContext.panTo = panTo;
|
|
57
|
+
const setCenterByPlace = (place: Place) => {
|
|
58
|
+
centerSource.source = "api";
|
|
59
|
+
centerPlace.lng = place.lng;
|
|
60
|
+
centerPlace.lat = place.lat;
|
|
61
|
+
centerPlace.name = place.name;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const { geoPosition } = useGeoLocation({
|
|
65
|
+
geoDefaultPosition,
|
|
66
|
+
onLoad: async (value) => {
|
|
67
|
+
// geo 主入口
|
|
68
|
+
await readyPromise;
|
|
69
|
+
centerSource.source = "geo";
|
|
70
|
+
centerPlace.lng = value.position[0];
|
|
71
|
+
centerPlace.lat = value.position[1];
|
|
72
|
+
updatePlace();
|
|
73
|
+
emit("loadGeoLocation", value);
|
|
74
|
+
},
|
|
75
|
+
onLoadDefault: async (value) => {
|
|
76
|
+
// geo default position 主入口
|
|
77
|
+
await readyPromise;
|
|
78
|
+
centerSource.source = "geo";
|
|
79
|
+
centerPlace.lng = value.position[0];
|
|
80
|
+
centerPlace.lat = value.position[1];
|
|
81
|
+
updatePlace();
|
|
82
|
+
emit("loadDefaultGeoLocation", value);
|
|
83
|
+
},
|
|
84
|
+
onChange: (v) => emit("changeGeoLocation", v),
|
|
85
|
+
onError: (e) => emit("geoError", e),
|
|
86
|
+
});
|
|
87
|
+
const { isDragging } = useMapDrag({
|
|
88
|
+
mapRef,
|
|
89
|
+
onChange: (point) => {
|
|
90
|
+
centerSource.source = "drag";
|
|
91
|
+
centerPlace.lng = point[0];
|
|
92
|
+
centerPlace.lat = point[1];
|
|
93
|
+
updatePlace();
|
|
94
|
+
emit("changeByDrag", point);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
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
|
+
});
|
|
128
|
+
watchEffect(() => {
|
|
129
|
+
mapContext.onChangeCenterPlace({ ...centerPlace });
|
|
130
|
+
});
|
|
131
|
+
watchEffect(() => {
|
|
132
|
+
mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
|
|
133
|
+
});
|
|
134
|
+
return () => {
|
|
135
|
+
return (
|
|
136
|
+
<HeycarMap center={centerPoint.value} zoom={18} mapRef={setMap}>
|
|
137
|
+
<PassengerCircle position={geoPosition.value} />
|
|
138
|
+
<PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} />
|
|
139
|
+
<AddressBox
|
|
140
|
+
position={centerPoint.value}
|
|
141
|
+
title={props.title}
|
|
142
|
+
description={props.description}
|
|
143
|
+
type={isDragging ? "locator" : "box"}
|
|
144
|
+
/>
|
|
145
|
+
</HeycarMap>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
).props([
|
|
150
|
+
"description",
|
|
151
|
+
"fallback",
|
|
152
|
+
"geoDefaultPosition",
|
|
153
|
+
"getRecomendPlace",
|
|
154
|
+
"loading",
|
|
155
|
+
"mapContext",
|
|
156
|
+
"title",
|
|
157
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./BusinessRecomendPlaceMap";
|
|
@@ -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
|
-
) :
|
|
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,
|
|
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 =
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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 =
|
|
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
|
-
})
|
|
95
|
+
});
|
|
100
96
|
|
|
101
97
|
export const PlaceCircle = defineSetup(function PlaceCircle(props: PlaceCircleProps, { emit }) {
|
|
102
98
|
const payload = useMapSupplier();
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { computed } from "vue-demi";
|
|
2
|
-
import { PickupPoints } from "../../business-components/PickupPoints";
|
|
3
|
-
import { useBusinessMapAutoComplete } from "../../hooks-business/useBusinessMapAutoComplete";
|
|
4
2
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "../../
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
3
|
+
BusinessRecomendPlaceMap,
|
|
4
|
+
BusinessRecomendPlaceMapProps,
|
|
5
|
+
} from "../../business-components/BusinessRecomendPlaceMap";
|
|
6
|
+
import { useBusinessMapAutoComplete } from "../../hooks-business/useBusinessMapAutoComplete";
|
|
7
|
+
import { useBusinessRecomendPlaceMap } from "../../hooks-business/useBusinessRecomendPlaceMap";
|
|
8
|
+
|
|
11
9
|
import { defineSetup } from "../../types/helper";
|
|
12
10
|
import { HeycarMap, MapProvider } from "../MapProvider/MapProvider";
|
|
13
11
|
import * as css from "./Demo.css";
|
|
@@ -64,8 +62,7 @@ const SomeAutoComplete = defineSetup(function SomeAutoComplete(props: { cityName
|
|
|
64
62
|
});
|
|
65
63
|
|
|
66
64
|
export const SomeHomePage = defineSetup(function SomeHomePage() {
|
|
67
|
-
const
|
|
68
|
-
const getRecomendPlace: UseBusinessMapRecomendPlaceProps["getRecomendPlace"] = async (
|
|
65
|
+
const getRecomendPlace: BusinessRecomendPlaceMapProps["getRecomendPlace"] = async (
|
|
69
66
|
place,
|
|
70
67
|
context
|
|
71
68
|
) => {
|
|
@@ -78,103 +75,29 @@ export const SomeHomePage = defineSetup(function SomeHomePage() {
|
|
|
78
75
|
};
|
|
79
76
|
const {
|
|
80
77
|
centerPlace,
|
|
81
|
-
centerPoint,
|
|
82
78
|
placeCandidates,
|
|
83
|
-
|
|
84
|
-
geoLoading,
|
|
85
|
-
geoPosition,
|
|
79
|
+
panTo,
|
|
86
80
|
setCenterPlaceByRecomand,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
recomendPlaceGeoLimit: 300,
|
|
92
|
-
recomendPlaceDragLimit: 30,
|
|
93
|
-
getRecomendPlace,
|
|
94
|
-
onChangeGeoLocation: (v) => console.log("onChangeGeoLocation: ", v),
|
|
95
|
-
onChangePlace: (v) => console.log("onChangePlace: ", v),
|
|
96
|
-
onChangeRecomandPlace: (v) => console.log("onChangeRecomandPlace: ", v),
|
|
97
|
-
});
|
|
98
|
-
const { registerFitVeiw, setFitView } = useMapFitView({
|
|
99
|
-
mapRef,
|
|
100
|
-
padding: [15, 15, 5, 15],
|
|
101
|
-
autoFitTimeout: 5000,
|
|
102
|
-
});
|
|
103
|
-
const { apiMapDistance } = useMapGeometry();
|
|
81
|
+
mapContext,
|
|
82
|
+
apiMapDistance,
|
|
83
|
+
} = useBusinessRecomendPlaceMap();
|
|
84
|
+
|
|
104
85
|
(window as any).setCenterPlaceByRecomand = setCenterPlaceByRecomand;
|
|
105
|
-
(window as any).setFitView = setFitView;
|
|
106
86
|
return () => {
|
|
107
87
|
return (
|
|
108
88
|
<div>
|
|
109
|
-
|
|
110
|
-
{apiMapDistance(centerPoint.value, [
|
|
111
|
-
centerPoint.value[0] + 0.01,
|
|
112
|
-
centerPoint.value[1] + 0.01,
|
|
113
|
-
])}{" "}
|
|
114
|
-
<br />
|
|
115
|
-
geoLoading: {`${geoLoading.value}`} <br />
|
|
116
|
-
isDragging: {`${isDragging.value}`} <br />
|
|
117
|
-
geoPosition: {geoPosition.value[0]} | {geoPosition.value[1]} <br />
|
|
89
|
+
placeCandidates: {placeCandidates} <br />
|
|
118
90
|
centerPlace: {centerPlace.lng} | {centerPlace.lat} | {centerPlace.name} |{" "}
|
|
119
91
|
{centerPlace.cityName} <br />
|
|
120
|
-
<
|
|
92
|
+
<BusinessRecomendPlaceMap
|
|
121
93
|
class={css.demo}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
registerOverlay={registerFitVeiw}
|
|
130
|
-
position={[121.4897065, 31.0842552]}
|
|
131
|
-
title={"start point"}
|
|
132
|
-
type="start"
|
|
133
|
-
/> */}
|
|
134
|
-
{/* <StartEndPoint
|
|
135
|
-
registerOverlay={registerFitVeiw}
|
|
136
|
-
position={[centerPoint.value[0] + 0.01, centerPoint.value[1] + 0.01]}
|
|
137
|
-
title={"end point"}
|
|
138
|
-
type="end"
|
|
139
|
-
/> */}
|
|
140
|
-
<PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} />
|
|
141
|
-
{/* <AddressBox
|
|
142
|
-
type="box"
|
|
143
|
-
position={centerPoint.value}
|
|
144
|
-
title={"Martyrs Lawn"}
|
|
145
|
-
description={"您将在此处上车"}
|
|
146
|
-
/> */}
|
|
147
|
-
{/* <TaxiCar position={[121, 31]} angle={0} /> */}
|
|
148
|
-
{/* <PickupPoints
|
|
149
|
-
positions={[
|
|
150
|
-
[-1, -1],
|
|
151
|
-
[-2, -2],
|
|
152
|
-
]}
|
|
153
|
-
labels={["place name 1", "place name 2"]}
|
|
154
|
-
/> */}
|
|
155
|
-
{/* <DrivingRoute
|
|
156
|
-
from={[121, 31]}
|
|
157
|
-
to={[121.6, 31.3]}
|
|
158
|
-
render={({ path, angle }) => [
|
|
159
|
-
<DrivingLine path={path} />,
|
|
160
|
-
<TaxiCar position={[121, 31]} angle={angle} />,
|
|
161
|
-
]}
|
|
162
|
-
/> */}
|
|
163
|
-
{/* <PassengerCircle position={centerPoint.value} size="small" /> */}
|
|
164
|
-
{/* <PlaceCircle
|
|
165
|
-
position={centerPoint.value}
|
|
166
|
-
label={"some place"}
|
|
167
|
-
hideIcon
|
|
168
|
-
onClick={() => {
|
|
169
|
-
debugger;
|
|
170
|
-
}}
|
|
171
|
-
/> */}
|
|
172
|
-
{/* <WalkingRoute
|
|
173
|
-
from={centerPoint.value}
|
|
174
|
-
to={[centerPoint.value[0] + 0.01, centerPoint.value[1] + 0.01]}
|
|
175
|
-
render={({ path }) => <WalkingLine path={path} />}
|
|
176
|
-
/> */}
|
|
177
|
-
</HeycarMap>
|
|
94
|
+
title={centerPlace.name}
|
|
95
|
+
description={"some description"}
|
|
96
|
+
geoDefaultPosition={[121, 31]}
|
|
97
|
+
getRecomendPlace={getRecomendPlace}
|
|
98
|
+
mapContext={mapContext}
|
|
99
|
+
onGeoError={(e) => console.log("onGeoError e = ", e)}
|
|
100
|
+
/>
|
|
178
101
|
</div>
|
|
179
102
|
);
|
|
180
103
|
};
|
|
@@ -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
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { reactive, ref } from "vue-demi";
|
|
2
|
+
import { useMapGeometry } from "../hooks/useMapGeometry";
|
|
3
|
+
import type { Place, Point } from "../types/interface";
|
|
4
|
+
|
|
5
|
+
export interface BusinessRecomendPlaceContext {
|
|
6
|
+
panTo: (value: Point) => void;
|
|
7
|
+
setCenterPlaceByRecomand: (value: Point) => void;
|
|
8
|
+
onChangeCenterPlace: (value: Place) => void;
|
|
9
|
+
onChangeRecomendPlaces: (value: Place[]) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useBusinessRecomendPlaceMap = () => {
|
|
13
|
+
const centerPlace = reactive<Place>({
|
|
14
|
+
lng: 0,
|
|
15
|
+
lat: 0,
|
|
16
|
+
name: "",
|
|
17
|
+
cityName: undefined,
|
|
18
|
+
});
|
|
19
|
+
const placeCandidates = ref<Place[]>([]);
|
|
20
|
+
const { apiMapDistance } = useMapGeometry();
|
|
21
|
+
const panTo = (value: Point) => mapContext.panTo(value);
|
|
22
|
+
const setCenterPlaceByRecomand = (value: Point) => mapContext.setCenterPlaceByRecomand(value);
|
|
23
|
+
const mapContext: BusinessRecomendPlaceContext = {
|
|
24
|
+
panTo: () => {
|
|
25
|
+
throw new Error("MyError: panTo used before assigned");
|
|
26
|
+
},
|
|
27
|
+
setCenterPlaceByRecomand: () => {
|
|
28
|
+
throw new Error("MyError: setCenterPlaceByRecomand used before assigned");
|
|
29
|
+
},
|
|
30
|
+
onChangeCenterPlace: (place: Place) => {
|
|
31
|
+
Object.assign(centerPlace, { ...place });
|
|
32
|
+
},
|
|
33
|
+
onChangeRecomendPlaces: (places: Place[]) => {
|
|
34
|
+
placeCandidates.value = [...places];
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
mapContext,
|
|
39
|
+
centerPlace,
|
|
40
|
+
placeCandidates,
|
|
41
|
+
panTo,
|
|
42
|
+
setCenterPlaceByRecomand,
|
|
43
|
+
apiMapDistance,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -9,7 +9,7 @@ import type { MapShallowRef, Place, Point } from "../types/interface";
|
|
|
9
9
|
interface CenterPlaceSource {
|
|
10
10
|
source: "default" | "geo" | "drag" | "recomend" | "api";
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface UseLagecyMapRecomendPlace
|
|
13
13
|
extends Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace"> {
|
|
14
14
|
mapRef: MapShallowRef;
|
|
15
15
|
defaultCenterPoint?: Point;
|
|
@@ -23,7 +23,7 @@ export interface UseBusinessMapRecomendPlaceProps
|
|
|
23
23
|
onChangePlace?: UseMapPlaceProps["onChange"];
|
|
24
24
|
onChangeRecomandPlace?: UseMapRecomendPlaceProps["onChange"];
|
|
25
25
|
}
|
|
26
|
-
export const
|
|
26
|
+
export const useLagecyMapRecomendPlace = (props: UseLagecyMapRecomendPlace) => {
|
|
27
27
|
const {
|
|
28
28
|
mapRef,
|
|
29
29
|
geoDefaultPosition,
|
|
@@ -135,6 +135,7 @@ export const useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlacePr
|
|
|
135
135
|
onChangeRecomandPlace?.(place);
|
|
136
136
|
},
|
|
137
137
|
});
|
|
138
|
+
|
|
138
139
|
return {
|
|
139
140
|
isDragging,
|
|
140
141
|
geoLoading,
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
export { AddressBox } from "./business-components/AddressBox";
|
|
3
3
|
export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
|
|
4
|
+
export { BusinessRecomendPlaceMap } from "./business-components/BusinessRecomendPlaceMap";
|
|
4
5
|
export { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap";
|
|
5
6
|
export { DrivingLine } from "./business-components/DrivingLine";
|
|
6
7
|
export { DrivingRoute } from "./business-components/DrivingRoute";
|
|
@@ -14,8 +15,8 @@ export { WalkingRoute } from "./business-components/WalkingRoute";
|
|
|
14
15
|
export { WaveCircle } from "./business-components/WaveCircle";
|
|
15
16
|
export * from "./components/MapProvider";
|
|
16
17
|
export * from "./hooks-business/useBusinessMapAutoComplete";
|
|
17
|
-
export * from "./hooks-business/useBusinessMapRecomendPlace";
|
|
18
18
|
export * from "./hooks-business/useBusinessQuotingMap";
|
|
19
|
+
export * from "./hooks-business/useBusinessRecomendPlaceMap";
|
|
19
20
|
export * from "./hooks-business/useBusinessTaxiServiceMap";
|
|
20
21
|
export { useDrivingRoute } from "./hooks/useDrivingRoute";
|
|
21
22
|
export { useGeoLocation } from "./hooks/useGeoLocation";
|
package/src/types/interface.ts
CHANGED
|
@@ -47,4 +47,14 @@ export type DriverStatus =
|
|
|
47
47
|
| "driverArrived"
|
|
48
48
|
| "inService"
|
|
49
49
|
| "canceled"
|
|
50
|
-
| "endService"
|
|
50
|
+
| "endService"
|
|
51
|
+
| "completed"
|
|
52
|
+
| "canceling"
|
|
53
|
+
| "banlanceRefund"
|
|
54
|
+
| "waitBanlanceRefund"
|
|
55
|
+
| "rechargePayed"
|
|
56
|
+
| "waitRechargePay"
|
|
57
|
+
| "payed"
|
|
58
|
+
| "waitpay"
|
|
59
|
+
| "refund"
|
|
60
|
+
| "confirmed";
|