@heycar/heycars-map 0.2.5 → 0.2.6
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/README.md +1 -0
- package/dist/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +13 -0
- package/dist/business-components/BusinessQuotingMap/index.d.ts +1 -0
- package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +5 -3
- package/dist/business-components/PassengerCircle/PassengerCircle.d.ts +18309 -4
- package/dist/business-components/TaxiCar/TaxiCar.d.ts +18309 -4
- package/dist/components/Demo/DemoBusinessQuoting.d.ts +1 -0
- package/dist/hooks/useMap.d.ts +4 -0
- package/dist/hooks/useMapAutoComplete.d.ts +3 -0
- package/dist/hooks/useMapPlace.d.ts +3 -0
- package/dist/hooks/useMapRecomendPlace.d.ts +6 -0
- package/dist/hooks/useOverlay.d.ts +1 -0
- package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +1 -0
- package/dist/hooks-business/useBusinessMapRecomendPlace.d.ts +2 -0
- package/dist/hooks-business/useBusinessQuotingMap.d.ts +2049 -0
- package/dist/hooks-business/useBusinessTaxiServiceMap.d.ts +2049 -0
- package/dist/index.cjs +51 -51
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1423 -1329
- package/dist/types/interface.d.ts +1 -0
- package/package.json +1 -1
- package/src/App.tsx +3 -2
- package/src/business-components/BusinessQuotingMap/BusinessQuotingMap.tsx +49 -0
- package/src/business-components/BusinessQuotingMap/index.ts +1 -0
- package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +213 -140
- package/src/business-components/PassengerCircle/PassengerCircle.tsx +26 -8
- package/src/business-components/TaxiCar/TaxiCar.tsx +18 -6
- package/src/components/Demo/DemoBusinessQuoting.tsx +39 -0
- package/src/components/Demo/DemoBusinessTaxiService.tsx +6 -1
- package/src/hooks/useGeoLocation.ts +3 -3
- package/src/hooks/useMap.ts +15 -1
- package/src/hooks/useOverlay.ts +1 -0
- package/src/hooks/useWalkingRoute.ts +0 -1
- package/src/hooks-business/useBusinessMapRecomendPlace.ts +1 -0
- package/src/hooks-business/useBusinessQuotingMap.ts +11 -0
- package/src/hooks-business/useBusinessTaxiServiceMap.ts +12 -0
- package/src/index.ts +1 -1
- package/src/types/interface.ts +1 -0
- package/dist/hooks-business/useBusinessMapFitView.d.ts +0 -2291
- package/src/hooks-business/useBusinessMapFitView.ts +0 -6
|
@@ -3,17 +3,18 @@ import imgTaxicar from "../../assets/icons/svg/taxi-car.svg";
|
|
|
3
3
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
4
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView/GmapAdvancedMarkerView";
|
|
5
5
|
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
6
|
+
import type { AmapOverlay, GmapOverlay, MapRegisterOverlayProps } from "../../hooks/useOverlay";
|
|
6
7
|
import { createElement, defineSetup } from "../../types/helper";
|
|
7
8
|
import { createDom } from "../../utils/dom";
|
|
8
9
|
import { decodeAsterisk, vec2lnglat } from "../../utils/transform";
|
|
9
10
|
import * as css from "./TaxiCar.css";
|
|
10
11
|
|
|
11
|
-
export interface TaxiCarProps {
|
|
12
|
+
export interface TaxiCarProps<T> extends MapRegisterOverlayProps<T> {
|
|
12
13
|
position: [number, number];
|
|
13
14
|
angle?: number;
|
|
14
15
|
title?: string;
|
|
15
16
|
}
|
|
16
|
-
export const ATaxiCar = defineSetup(function ATaxiCar(props: TaxiCarProps) {
|
|
17
|
+
export const ATaxiCar = defineSetup(function ATaxiCar(props: TaxiCarProps<AmapOverlay>) {
|
|
17
18
|
const contentRef = computed(() => {
|
|
18
19
|
const titleRow = !props.title
|
|
19
20
|
? ""
|
|
@@ -34,11 +35,16 @@ export const ATaxiCar = defineSetup(function ATaxiCar(props: TaxiCarProps) {
|
|
|
34
35
|
`;
|
|
35
36
|
});
|
|
36
37
|
return () => (
|
|
37
|
-
<AmapMarker
|
|
38
|
+
<AmapMarker
|
|
39
|
+
position={props.position}
|
|
40
|
+
content={contentRef.value}
|
|
41
|
+
anchor={"bottom-center"}
|
|
42
|
+
registerOverlay={props.registerOverlay}
|
|
43
|
+
/>
|
|
38
44
|
);
|
|
39
45
|
});
|
|
40
46
|
|
|
41
|
-
export const GTaxiCar = defineSetup(function GTaxiCar(props: TaxiCarProps) {
|
|
47
|
+
export const GTaxiCar = defineSetup(function GTaxiCar(props: TaxiCarProps<GmapOverlay>) {
|
|
42
48
|
const contentRef = computed(() => {
|
|
43
49
|
const titleRow = !props.title
|
|
44
50
|
? ""
|
|
@@ -63,12 +69,18 @@ export const GTaxiCar = defineSetup(function GTaxiCar(props: TaxiCarProps) {
|
|
|
63
69
|
});
|
|
64
70
|
return () => {
|
|
65
71
|
return (
|
|
66
|
-
<GmapAdvancedMarkerView
|
|
72
|
+
<GmapAdvancedMarkerView
|
|
73
|
+
position={vec2lnglat(props.position)}
|
|
74
|
+
content={contentRef.value}
|
|
75
|
+
registerOverlay={props.registerOverlay}
|
|
76
|
+
/>
|
|
67
77
|
);
|
|
68
78
|
};
|
|
69
79
|
});
|
|
70
80
|
|
|
71
|
-
export const TaxiCar = defineSetup(function TaxiCar(
|
|
81
|
+
export const TaxiCar = defineSetup(function TaxiCar(
|
|
82
|
+
props: TaxiCarProps<AmapOverlay> | TaxiCarProps<GmapOverlay>
|
|
83
|
+
) {
|
|
72
84
|
const payload = useMapSupplier();
|
|
73
85
|
return () => {
|
|
74
86
|
return createElement(payload.supplier === "gmap" ? GTaxiCar : ATaxiCar, {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BusinessQuotingMap } from "../../business-components/BusinessQuotingMap";
|
|
2
|
+
import { useBusinessQuotingMap } from "../../hooks-business/useBusinessQuotingMap";
|
|
3
|
+
import { defineSetup } from "../../types/helper";
|
|
4
|
+
import { MapProvider } from "../MapProvider/MapProvider";
|
|
5
|
+
import * as css from "./Demo.css";
|
|
6
|
+
|
|
7
|
+
const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
|
|
8
|
+
const gmapId = import.meta.env.VITE_GMAP_MAP_ID;
|
|
9
|
+
const amapApiKey = import.meta.env.VITE_AMAP_API_KEY;
|
|
10
|
+
const amapApiSecret = import.meta.env.VITE_AMAP_API_SECRET;
|
|
11
|
+
|
|
12
|
+
export const DemoBusinessQuoting = defineSetup(function DemoBusinessTaxiService() {
|
|
13
|
+
return () => (
|
|
14
|
+
<MapProvider
|
|
15
|
+
amapKey={amapApiKey}
|
|
16
|
+
amapSecret={amapApiSecret}
|
|
17
|
+
gmapId={gmapId}
|
|
18
|
+
gmapKey={gmapApiKey}
|
|
19
|
+
supplier={"amap"}
|
|
20
|
+
>
|
|
21
|
+
<SomeQuotingPage />
|
|
22
|
+
</MapProvider>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const SomeQuotingPage = defineSetup(function SomeQuotingPage() {
|
|
27
|
+
const { setMap, setFitView, registerFitVeiw } = useBusinessQuotingMap();
|
|
28
|
+
return () => (
|
|
29
|
+
<BusinessQuotingMap
|
|
30
|
+
class={css.demo}
|
|
31
|
+
from={{ lng: 121.4, lat: 31.2, name: "from place name" }}
|
|
32
|
+
to={{ lng: 121.5, lat: 31.4, name: "to place name" }}
|
|
33
|
+
renderDescription={({ distance, duration }) => `全程 *${distance}公里* 约行驶 *${duration}*`}
|
|
34
|
+
mapRef={setMap}
|
|
35
|
+
registerOverlay={registerFitVeiw}
|
|
36
|
+
onMapMounted={setFitView}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BusinessTaxiServiceMap } from "../../business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap";
|
|
2
|
+
import { useBusinessTaxiServiceMap } from "../../hooks-business/useBusinessTaxiServiceMap";
|
|
2
3
|
import { defineSetup } from "../../types/helper";
|
|
3
4
|
import type { Point } from "../../types/interface";
|
|
4
5
|
import { MapProvider } from "../MapProvider/MapProvider";
|
|
@@ -24,13 +25,14 @@ export const DemoBusinessTaxiService = defineSetup(function DemoBusinessTaxiServ
|
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
export const TaxiCarServicePage = defineSetup(function TaxiCarServicePage() {
|
|
28
|
+
const { setMap, setFitView, registerFitVeiw } = useBusinessTaxiServiceMap();
|
|
27
29
|
const getDriverPosition = () => Promise.resolve([121.42, 31.25] as Point);
|
|
28
30
|
return () => (
|
|
29
31
|
<BusinessTaxiServiceMap
|
|
30
32
|
class={css.demo}
|
|
31
33
|
from={{ lng: 121.4, lat: 31.2, name: "from place name" }}
|
|
32
34
|
to={{ lng: 121.5, lat: 31.4, name: "to place name" }}
|
|
33
|
-
driverStatus="driverStartService"
|
|
35
|
+
driverStatus="book-driverStartService"
|
|
34
36
|
bookDispatchingTitle="2月14日 11:00 用车"
|
|
35
37
|
bookDispatchedTitle="司机位置将在临近出发时间展示"
|
|
36
38
|
dispatchingTitle="正在为您搜索附近司机"
|
|
@@ -43,6 +45,9 @@ export const TaxiCarServicePage = defineSetup(function TaxiCarServicePage() {
|
|
|
43
45
|
}
|
|
44
46
|
getDriverPosition={getDriverPosition}
|
|
45
47
|
interval={5000}
|
|
48
|
+
mapRef={setMap}
|
|
49
|
+
registerOverlay={registerFitVeiw}
|
|
50
|
+
onMapMounted={setFitView}
|
|
46
51
|
/>
|
|
47
52
|
);
|
|
48
53
|
});
|
|
@@ -8,7 +8,7 @@ export interface UseGeoLocationProps {
|
|
|
8
8
|
onLoadDefault?: (value: { position: Point }) => any;
|
|
9
9
|
}
|
|
10
10
|
export const useGeoLocation = (props?: UseGeoLocationProps) => {
|
|
11
|
-
const { onChange, onLoad, onLoadDefault } = props ?? {};
|
|
11
|
+
const { onChange, onLoad, onLoadDefault, geoDefaultPosition } = props ?? {};
|
|
12
12
|
const loading = ref(false);
|
|
13
13
|
const readyRef = ref(false);
|
|
14
14
|
const errorRef = ref<GeolocationPositionError>();
|
|
@@ -17,8 +17,8 @@ export const useGeoLocation = (props?: UseGeoLocationProps) => {
|
|
|
17
17
|
altitude: 0,
|
|
18
18
|
altitudeAccuracy: 0,
|
|
19
19
|
heading: 0,
|
|
20
|
-
latitude: 0,
|
|
21
|
-
longitude: 0,
|
|
20
|
+
latitude: geoDefaultPosition?.[1] ?? 0,
|
|
21
|
+
longitude: geoDefaultPosition?.[0] ?? 0,
|
|
22
22
|
speed: 0,
|
|
23
23
|
});
|
|
24
24
|
const positionRef = ref<Point>([coordinateRef.value.longitude, coordinateRef.value.latitude]);
|
package/src/hooks/useMap.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, provide, ShallowRef } from "vue-demi";
|
|
1
|
+
import { inject, provide, ShallowRef, watch } from "vue-demi";
|
|
2
2
|
import type { MapShallowRef } from "../types/interface";
|
|
3
3
|
import { useMapSupplier } from "./useMapSupplier";
|
|
4
4
|
|
|
@@ -27,3 +27,17 @@ export const provideMap = (mapRef: MapShallowRef) => {
|
|
|
27
27
|
? provideGmap(mapRef as MapShallowRef<google.maps.Map>)
|
|
28
28
|
: provideAmap(mapRef as MapShallowRef<AMap.Map>);
|
|
29
29
|
};
|
|
30
|
+
|
|
31
|
+
export interface MapMountedProps {
|
|
32
|
+
onMapMounted?: () => any;
|
|
33
|
+
}
|
|
34
|
+
export const onMapMounted = (callback: (...args: any) => any) => {
|
|
35
|
+
const mapRef = useMap();
|
|
36
|
+
watch(
|
|
37
|
+
() => mapRef.value,
|
|
38
|
+
(map) => {
|
|
39
|
+
if (!map) return;
|
|
40
|
+
Promise.resolve().then(callback);
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
};
|
package/src/hooks/useOverlay.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ShallowRef, watch } from "vue-demi";
|
|
2
2
|
import type { RegisterOverlay } from "../types/interface";
|
|
3
3
|
|
|
4
|
+
export type MROP = MapRegisterOverlayProps<AmapOverlay> | MapRegisterOverlayProps<GmapOverlay>;
|
|
4
5
|
export interface MapRegisterOverlayProps<T> {
|
|
5
6
|
registerOverlay?: RegisterOverlay<T>;
|
|
6
7
|
}
|
|
@@ -57,6 +57,7 @@ export const useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlacePr
|
|
|
57
57
|
centerSource.source = "api";
|
|
58
58
|
centerPlace.lng = place.lng;
|
|
59
59
|
centerPlace.lat = place.lat;
|
|
60
|
+
centerPlace.name = place.name;
|
|
60
61
|
};
|
|
61
62
|
if (defaultCenterPoint) {
|
|
62
63
|
// default 主入口
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useHeycarMap } from "../hooks/useHeycarMap";
|
|
2
|
+
import { useMapFitView } from "../hooks/useMapFitView";
|
|
3
|
+
|
|
4
|
+
export const useBusinessQuotingMap = () => {
|
|
5
|
+
const { setMap, mapRef } = useHeycarMap();
|
|
6
|
+
const { registerFitVeiw, setFitView } = useMapFitView({
|
|
7
|
+
mapRef,
|
|
8
|
+
padding: [25, 20, 15, 15],
|
|
9
|
+
});
|
|
10
|
+
return { setMap, registerFitVeiw, setFitView };
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useHeycarMap } from "../hooks/useHeycarMap";
|
|
2
|
+
import { useMapFitView } from "../hooks/useMapFitView";
|
|
3
|
+
|
|
4
|
+
export const useBusinessTaxiServiceMap = () => {
|
|
5
|
+
const { mapRef, setMap } = useHeycarMap();
|
|
6
|
+
const { registerFitVeiw, setFitView } = useMapFitView({
|
|
7
|
+
mapRef,
|
|
8
|
+
autoFitTimeout: 5000,
|
|
9
|
+
padding: [25, 20, 15, 15],
|
|
10
|
+
});
|
|
11
|
+
return { setMap, registerFitVeiw, setFitView };
|
|
12
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -13,8 +13,8 @@ export { WalkingRoute } from "./business-components/WalkingRoute";
|
|
|
13
13
|
export { WaveCircle } from "./business-components/WaveCircle";
|
|
14
14
|
export * from "./components/MapProvider";
|
|
15
15
|
export * from "./hooks-business/useBusinessMapAutoComplete";
|
|
16
|
-
export * from "./hooks-business/useBusinessMapFitView";
|
|
17
16
|
export * from "./hooks-business/useBusinessMapRecomendPlace";
|
|
17
|
+
export * from "./hooks-business/useBusinessTaxiServiceMap";
|
|
18
18
|
export { useDrivingRoute } from "./hooks/useDrivingRoute";
|
|
19
19
|
export { useGeoLocation } from "./hooks/useGeoLocation";
|
|
20
20
|
export { useHeycarMap } from "./hooks/useHeycarMap";
|