@heycar/heycars-map 0.2.5 → 0.2.7
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 +12 -0
- package/dist/business-components/BusinessQuotingMap/index.d.ts +1 -0
- package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +4 -3
- package/dist/business-components/FitView/FitView.d.ts +3 -1
- 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 +3 -1
- package/dist/index.js +1460 -1276
- package/dist/style.css +1 -1
- package/dist/types/interface.d.ts +2 -0
- package/package.json +1 -1
- package/src/App.tsx +4 -3
- 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 +159 -89
- package/src/business-components/FitView/FitView.tsx +10 -2
- package/src/business-components/PassengerCircle/PassengerCircle.tsx +26 -8
- package/src/business-components/TaxiCar/TaxiCar.tsx +18 -6
- package/src/components/Demo/DemoBusinessQuoting.tsx +38 -0
- package/src/components/Demo/DemoBusinessTaxiService.tsx +5 -1
- package/src/hooks/useGeoLocation.ts +3 -3
- package/src/hooks/useMap.ts +15 -1
- package/src/hooks/useMapFitView.ts +18 -16
- 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 +3 -1
- package/src/types/interface.ts +2 -0
- package/dist/hooks-business/useBusinessMapFitView.d.ts +0 -2291
- package/src/hooks-business/useBusinessMapFitView.ts +0 -6
|
@@ -0,0 +1,38 @@
|
|
|
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, 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
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
});
|
|
@@ -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,8 @@ export const TaxiCarServicePage = defineSetup(function TaxiCarServicePage() {
|
|
|
43
45
|
}
|
|
44
46
|
getDriverPosition={getDriverPosition}
|
|
45
47
|
interval={5000}
|
|
48
|
+
mapRef={setMap}
|
|
49
|
+
registerOverlay={registerFitVeiw}
|
|
46
50
|
/>
|
|
47
51
|
);
|
|
48
52
|
});
|
|
@@ -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
|
+
};
|
|
@@ -27,14 +27,6 @@ export const useAmapFitView = (props: UseMapFitViewProps<AMap.Map>) => {
|
|
|
27
27
|
const { mapRef, autoFitTimeout } = props;
|
|
28
28
|
const overlayGroup: Set<AmapOverlay> = new Set();
|
|
29
29
|
let timer: number | undefined = undefined;
|
|
30
|
-
const registerFitVeiw: RegisterOverlay<AmapOverlay> = {
|
|
31
|
-
add: (overlay: AmapOverlay) => {
|
|
32
|
-
overlayGroup.add(overlay);
|
|
33
|
-
},
|
|
34
|
-
remove: (overlay: AmapOverlay) => {
|
|
35
|
-
overlayGroup.delete(overlay);
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
30
|
const setFitView = () => {
|
|
39
31
|
const map = mapRef.value;
|
|
40
32
|
if (!map) return;
|
|
@@ -43,6 +35,15 @@ export const useAmapFitView = (props: UseMapFitViewProps<AMap.Map>) => {
|
|
|
43
35
|
console.log([...overlayGroup]);
|
|
44
36
|
map.setFitView([...overlayGroup], false, [top * vw, bottom * vw, left * vw, right * vw]);
|
|
45
37
|
};
|
|
38
|
+
const registerFitVeiw: RegisterOverlay<AmapOverlay> = {
|
|
39
|
+
add: (overlay: AmapOverlay) => {
|
|
40
|
+
overlayGroup.add(overlay);
|
|
41
|
+
},
|
|
42
|
+
remove: (overlay: AmapOverlay) => {
|
|
43
|
+
overlayGroup.delete(overlay);
|
|
44
|
+
},
|
|
45
|
+
setFitView,
|
|
46
|
+
};
|
|
46
47
|
const handleMoveEndOrZomEnd = () => {
|
|
47
48
|
if (!autoFitTimeout) return;
|
|
48
49
|
if (timer) clearTimeout(timer);
|
|
@@ -82,14 +83,6 @@ export const useGmapFitView = (props: UseMapFitViewProps<google.maps.Map>) => {
|
|
|
82
83
|
const { executeMapApi } = useMapEventSource();
|
|
83
84
|
const overlayGroup = new SimpleGmapOverLayerGroup();
|
|
84
85
|
let timer: number | undefined = undefined;
|
|
85
|
-
const registerFitVeiw: RegisterOverlay<GmapOverlay> = {
|
|
86
|
-
add: (overlay: GmapOverlay) => {
|
|
87
|
-
overlayGroup.add(overlay);
|
|
88
|
-
},
|
|
89
|
-
remove: (overlay: GmapOverlay) => {
|
|
90
|
-
overlayGroup.delete(overlay);
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
86
|
const setFitView = () => {
|
|
94
87
|
const map = mapRef.value;
|
|
95
88
|
if (!map) return;
|
|
@@ -104,6 +97,15 @@ export const useGmapFitView = (props: UseMapFitViewProps<google.maps.Map>) => {
|
|
|
104
97
|
})
|
|
105
98
|
);
|
|
106
99
|
};
|
|
100
|
+
const registerFitVeiw: RegisterOverlay<GmapOverlay> = {
|
|
101
|
+
add: (overlay: GmapOverlay) => {
|
|
102
|
+
overlayGroup.add(overlay);
|
|
103
|
+
},
|
|
104
|
+
remove: (overlay: GmapOverlay) => {
|
|
105
|
+
overlayGroup.delete(overlay);
|
|
106
|
+
},
|
|
107
|
+
setFitView,
|
|
108
|
+
};
|
|
107
109
|
const handleMoveEnd = (name: string) => {
|
|
108
110
|
const eventSource = getMapEvnetSource();
|
|
109
111
|
console.log("handleMoveEndOrZomEnd name, eventSource = ", name, eventSource);
|
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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
export { AddressBox } from "./business-components/AddressBox";
|
|
3
|
+
export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
|
|
3
4
|
export { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap";
|
|
4
5
|
export { DrivingLine } from "./business-components/DrivingLine";
|
|
5
6
|
export { DrivingRoute } from "./business-components/DrivingRoute";
|
|
@@ -13,8 +14,9 @@ export { WalkingRoute } from "./business-components/WalkingRoute";
|
|
|
13
14
|
export { WaveCircle } from "./business-components/WaveCircle";
|
|
14
15
|
export * from "./components/MapProvider";
|
|
15
16
|
export * from "./hooks-business/useBusinessMapAutoComplete";
|
|
16
|
-
export * from "./hooks-business/useBusinessMapFitView";
|
|
17
17
|
export * from "./hooks-business/useBusinessMapRecomendPlace";
|
|
18
|
+
export * from "./hooks-business/useBusinessQuotingMap";
|
|
19
|
+
export * from "./hooks-business/useBusinessTaxiServiceMap";
|
|
18
20
|
export { useDrivingRoute } from "./hooks/useDrivingRoute";
|
|
19
21
|
export { useGeoLocation } from "./hooks/useGeoLocation";
|
|
20
22
|
export { useHeycarMap } from "./hooks/useHeycarMap";
|
package/src/types/interface.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type Place = {
|
|
|
7
7
|
lat: number;
|
|
8
8
|
name: string;
|
|
9
9
|
cityName?: string;
|
|
10
|
+
cityId?: string;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export interface AutoCompletePlace extends Place {
|
|
@@ -27,6 +28,7 @@ export type City = {
|
|
|
27
28
|
export interface RegisterOverlay<T> {
|
|
28
29
|
add: (overlay: T) => void;
|
|
29
30
|
remove: (overlay: T) => void;
|
|
31
|
+
setFitView: () => void;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export interface Route {
|