@heycar/heycars-map 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +22 -0
- package/dist/business-components/BusinessTaxiServiceMap/index.d.ts +1 -0
- package/dist/business-components/DrivingRoute/DrivingRoute.d.ts +2 -0
- package/dist/business-components/FitView/FitView.d.ts +9 -0
- package/dist/business-components/FitView/index.d.ts +1 -0
- package/dist/business-components/PickupPoints/PickupPoints.d.ts +2 -1
- package/dist/business-components/PlaceCircle/PlaceCircle.d.ts +5 -3
- package/dist/business-components/WalkingRoute/WalkingRoute.d.ts +0 -1
- package/dist/components/AmapMarker/AmapMarker.d.ts +5 -2
- package/dist/components/Demo/DemoBusinessTaxiService.d.ts +2 -0
- package/dist/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.d.ts +5 -2
- package/dist/hooks/useGeoLocation.d.ts +4 -0
- package/dist/hooks/useMapFitView.d.ts +6 -2296
- package/dist/hooks-business/useBusinessMapFitView.d.ts +2228 -2234
- package/dist/hooks-business/useBusinessMapRecomendPlace.d.ts +4 -1
- package/dist/index.cjs +52 -52
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2072 -1698
- package/dist/types/interface.d.ts +1 -0
- package/dist/utils/compare.d.ts +1 -1
- package/package.json +1 -1
- package/src/App.tsx +1 -0
- package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +285 -0
- package/src/business-components/BusinessTaxiServiceMap/index.ts +1 -0
- package/src/business-components/DrivingRoute/DrivingRoute.tsx +2 -0
- package/src/business-components/FitView/FitView.tsx +14 -0
- package/src/business-components/FitView/index.ts +1 -0
- package/src/business-components/PickupPoints/PickupPoints.tsx +8 -2
- package/src/business-components/PlaceCircle/PlaceCircle.tsx +32 -8
- package/src/business-components/WalkingRoute/WalkingRoute.tsx +0 -1
- package/src/components/AmapMarker/AmapMarker.ts +10 -3
- package/src/components/Demo/DemoBusinessTaxiService.tsx +48 -0
- package/src/components/Demo/HeycarDemo.tsx +18 -8
- package/src/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.ts +15 -4
- package/src/hooks/useDrivingRoute.ts +0 -2
- package/src/hooks/useGeoLocation.ts +5 -1
- package/src/hooks/useMapFitView.ts +8 -1
- package/src/hooks/useWalkingRoute.ts +15 -9
- package/src/hooks-business/useBusinessMapRecomendPlace.ts +23 -0
- package/src/index.ts +1 -0
- package/src/types/interface.ts +12 -0
- package/src/utils/compare.ts +4 -1
- package/todo.md +7 -0
|
@@ -2,11 +2,13 @@ import { ref, watch } from "vue-demi";
|
|
|
2
2
|
import type { Point } from "../types/interface";
|
|
3
3
|
|
|
4
4
|
export interface UseGeoLocationProps {
|
|
5
|
+
geoDefaultPosition?: Point;
|
|
5
6
|
onChange?: (value: { position: Point; coordinate: GeolocationCoordinates }) => any;
|
|
6
7
|
onLoad?: (value: { position: Point; coordinate: GeolocationCoordinates }) => any;
|
|
8
|
+
onLoadDefault?: (value: { position: Point }) => any;
|
|
7
9
|
}
|
|
8
10
|
export const useGeoLocation = (props?: UseGeoLocationProps) => {
|
|
9
|
-
const { onChange, onLoad } = props ?? {};
|
|
11
|
+
const { onChange, onLoad, onLoadDefault } = props ?? {};
|
|
10
12
|
const loading = ref(false);
|
|
11
13
|
const readyRef = ref(false);
|
|
12
14
|
const errorRef = ref<GeolocationPositionError>();
|
|
@@ -40,6 +42,8 @@ export const useGeoLocation = (props?: UseGeoLocationProps) => {
|
|
|
40
42
|
(error) => {
|
|
41
43
|
loading.value = false;
|
|
42
44
|
errorRef.value = error;
|
|
45
|
+
const position = props?.geoDefaultPosition;
|
|
46
|
+
if (position) onLoadDefault?.({ position });
|
|
43
47
|
console.log("errorRef = ", errorRef);
|
|
44
48
|
},
|
|
45
49
|
// todo 要不要 timeout
|
|
@@ -13,6 +13,11 @@ type UseAmapFitViewPropsForListeners = {
|
|
|
13
13
|
// onZoomEnd?: MapEventHandler<AMap.Map>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
export interface UseMapFitViewOutput<L> {
|
|
17
|
+
setFitView: () => void;
|
|
18
|
+
registerFitVeiw: RegisterOverlay<L>;
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
export interface UseMapFitViewProps<M = AMap.Map | google.maps.Map> {
|
|
17
22
|
mapRef: MapShallowRef<M>;
|
|
18
23
|
padding?: [number, number, number, number];
|
|
@@ -119,7 +124,9 @@ export const useGmapFitView = (props: UseMapFitViewProps<google.maps.Map>) => {
|
|
|
119
124
|
return { registerFitVeiw, setFitView };
|
|
120
125
|
};
|
|
121
126
|
|
|
122
|
-
export const useMapFitView = (
|
|
127
|
+
export const useMapFitView = (
|
|
128
|
+
props: UseMapFitViewProps
|
|
129
|
+
): UseMapFitViewOutput<AmapOverlay> | UseMapFitViewOutput<GmapOverlay> => {
|
|
123
130
|
const { supplier } = useMapSupplier();
|
|
124
131
|
return supplier === "gmap"
|
|
125
132
|
? useGmapFitView(props as UseMapFitViewProps<google.maps.Map>)
|
|
@@ -19,11 +19,15 @@ export const useAWalkingRoute = (props: UseWalkingRouteProps) => {
|
|
|
19
19
|
case "complete": {
|
|
20
20
|
let path: Point[] = [];
|
|
21
21
|
const walkingResult = result as AMap.WalkingResult;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
debugger;
|
|
23
|
+
if (!walkingResult.routes) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const firstRoute = walkingResult.routes[0];
|
|
27
|
+
console.log("firstRoute = ", firstRoute);
|
|
28
|
+
for (const step of firstRoute.steps) {
|
|
29
|
+
const stepPath = step.path.map<Point>(({ lng, lat }) => [lng, lat]);
|
|
30
|
+
path = path.concat(stepPath);
|
|
27
31
|
}
|
|
28
32
|
pathRef.value = path;
|
|
29
33
|
return;
|
|
@@ -56,10 +60,12 @@ export const useGWalkingRoute = (props: UseWalkingRouteProps) => {
|
|
|
56
60
|
switch (status) {
|
|
57
61
|
case google.maps.DirectionsStatus.OK: {
|
|
58
62
|
let path: Point[] = [];
|
|
59
|
-
result
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const firstRoute = result!.routes[0];
|
|
64
|
+
const stepPath = firstRoute.overview_path.map<Point>((item) => [
|
|
65
|
+
item.lng(),
|
|
66
|
+
item.lat(),
|
|
67
|
+
]);
|
|
68
|
+
path = path.concat(stepPath);
|
|
63
69
|
pathRef.value = path;
|
|
64
70
|
return;
|
|
65
71
|
}
|
|
@@ -13,9 +13,11 @@ export interface UseBusinessMapRecomendPlaceProps
|
|
|
13
13
|
extends Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace"> {
|
|
14
14
|
mapRef: MapShallowRef;
|
|
15
15
|
defaultCenterPoint?: Point;
|
|
16
|
+
geoDefaultPosition?: Point;
|
|
16
17
|
recomendPlaceGeoLimit: number;
|
|
17
18
|
recomendPlaceDragLimit: number;
|
|
18
19
|
onLoadGeoLocation?: UseGeoLocationProps["onLoad"];
|
|
20
|
+
onLoadDefaultGeoLocation?: UseGeoLocationProps["onLoadDefault"];
|
|
19
21
|
onChangeByDrag?: UseMapDragProps["onChange"];
|
|
20
22
|
onChangeGeoLocation?: UseGeoLocationProps["onChange"];
|
|
21
23
|
onChangePlace?: UseMapPlaceProps["onChange"];
|
|
@@ -24,11 +26,13 @@ export interface UseBusinessMapRecomendPlaceProps
|
|
|
24
26
|
export const useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlaceProps) => {
|
|
25
27
|
const {
|
|
26
28
|
mapRef,
|
|
29
|
+
geoDefaultPosition,
|
|
27
30
|
getRecomendPlace,
|
|
28
31
|
defaultCenterPoint,
|
|
29
32
|
recomendPlaceDragLimit,
|
|
30
33
|
recomendPlaceGeoLimit,
|
|
31
34
|
onLoadGeoLocation,
|
|
35
|
+
onLoadDefaultGeoLocation,
|
|
32
36
|
onChangeByDrag,
|
|
33
37
|
onChangeGeoLocation,
|
|
34
38
|
onChangePlace,
|
|
@@ -49,6 +53,11 @@ export const useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlacePr
|
|
|
49
53
|
centerPlace.lat = point[1];
|
|
50
54
|
updatePlace();
|
|
51
55
|
};
|
|
56
|
+
const setCenterByPlace = (place: Place) => {
|
|
57
|
+
centerSource.source = "api";
|
|
58
|
+
centerPlace.lng = place.lng;
|
|
59
|
+
centerPlace.lat = place.lat;
|
|
60
|
+
};
|
|
52
61
|
if (defaultCenterPoint) {
|
|
53
62
|
// default 主入口
|
|
54
63
|
readyPromise.then(() => {
|
|
@@ -57,6 +66,7 @@ export const useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlacePr
|
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
68
|
const { geoLoading, geoError, geoPosition, geoCoordinate, geoReady } = useGeoLocation({
|
|
69
|
+
geoDefaultPosition,
|
|
60
70
|
onLoad: async (value) => {
|
|
61
71
|
// geo 主入口
|
|
62
72
|
// 如果设置了默认位置,就不在拿 gps 作为默认位置
|
|
@@ -69,6 +79,18 @@ export const useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlacePr
|
|
|
69
79
|
}
|
|
70
80
|
onLoadGeoLocation?.(value);
|
|
71
81
|
},
|
|
82
|
+
onLoadDefault: async (value) => {
|
|
83
|
+
// geo default position 主入口
|
|
84
|
+
// 如果设置了默认位置,就不在拿 gps 作为默认位置
|
|
85
|
+
if (!defaultCenterPoint) {
|
|
86
|
+
await readyPromise;
|
|
87
|
+
centerSource.source = "geo";
|
|
88
|
+
centerPlace.lng = value.position[0];
|
|
89
|
+
centerPlace.lat = value.position[1];
|
|
90
|
+
updatePlace();
|
|
91
|
+
}
|
|
92
|
+
onLoadDefaultGeoLocation?.(value);
|
|
93
|
+
},
|
|
72
94
|
onChange: onChangeGeoLocation,
|
|
73
95
|
});
|
|
74
96
|
const { isDragging } = useMapDrag({
|
|
@@ -123,5 +145,6 @@ export const useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlacePr
|
|
|
123
145
|
centerPoint,
|
|
124
146
|
placeCandidates,
|
|
125
147
|
setCenterPlaceByRecomand,
|
|
148
|
+
setCenterByPlace,
|
|
126
149
|
};
|
|
127
150
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
export { AddressBox } from "./business-components/AddressBox";
|
|
3
|
+
export { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap";
|
|
3
4
|
export { DrivingLine } from "./business-components/DrivingLine";
|
|
4
5
|
export { DrivingRoute } from "./business-components/DrivingRoute";
|
|
5
6
|
export { PassengerCircle } from "./business-components/PassengerCircle";
|
package/src/types/interface.ts
CHANGED
|
@@ -34,3 +34,15 @@ export interface Route {
|
|
|
34
34
|
distance: number;
|
|
35
35
|
duration: number;
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
export type DriverStatus =
|
|
39
|
+
| "dispatching"
|
|
40
|
+
| "book-dispatching"
|
|
41
|
+
| "dispatched"
|
|
42
|
+
| "driverStartService"
|
|
43
|
+
| "book-driverStartService"
|
|
44
|
+
| "book-dispatched"
|
|
45
|
+
| "driverArrived"
|
|
46
|
+
| "inService"
|
|
47
|
+
| "canceled"
|
|
48
|
+
| "endService";
|
package/src/utils/compare.ts
CHANGED
|
@@ -162,7 +162,10 @@ export function watchPostEffectForAMapEvent<
|
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
export function watchPostEffectForGMapEvent<
|
|
165
|
+
export function watchPostEffectForGMapEvent<
|
|
166
|
+
T extends google.maps.MVCObject | google.maps.marker.AdvancedMarkerView,
|
|
167
|
+
P
|
|
168
|
+
>(
|
|
166
169
|
targetRef: ShallowRef<T | undefined> | Ref<T | undefined> | undefined,
|
|
167
170
|
props: P,
|
|
168
171
|
emit: EmitFn<EmitByProps<P>>,
|
package/todo.md
CHANGED
|
@@ -16,3 +16,10 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
|
|
|
16
16
|
5. home 页面用户 出发点与终点小于 200 米,需要提示,需要导出接口
|
|
17
17
|
6. walkingRoute 显示报错
|
|
18
18
|
7. 需要一个手段让 fitview 初始化起作用
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
1. locator 的气泡也要支持点击
|
|
23
|
+
2. locator 气泡长度限制
|
|
24
|
+
3. locator 拖动次数多了会不更新
|
|
25
|
+
4. 郝瑞 searh Place 接口搜索次数多了会不更新
|