@heycar/heycars-map 0.2.6 → 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.
Files changed (36) hide show
  1. package/dist/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +2 -0
  2. package/dist/business-components/AbsoluteAddressBox/index.d.ts +1 -0
  3. package/dist/business-components/AddressBox/AddressBox.d.ts +1 -2
  4. package/dist/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +2 -3
  5. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +24 -0
  6. package/dist/business-components/BusinessRecomendPlaceMap/index.d.ts +1 -0
  7. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +2 -3
  8. package/dist/business-components/FitView/FitView.d.ts +3 -1
  9. package/dist/hooks/useGeoLocation.d.ts +1 -0
  10. package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +27 -0
  11. package/dist/hooks-business/{useBusinessMapRecomendPlace.d.ts → useLagecyMapRecomendPlace.d.ts} +2 -2
  12. package/dist/index.cjs +50 -50
  13. package/dist/index.d.ts +4 -1
  14. package/dist/index.js +1564 -1403
  15. package/dist/style.css +1 -1
  16. package/dist/types/interface.d.ts +2 -1
  17. package/package.json +1 -1
  18. package/src/App.tsx +3 -3
  19. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.tsx +8 -0
  20. package/src/business-components/AbsoluteAddressBox/index.ts +1 -0
  21. package/src/business-components/AddressBox/AddressBox.tsx +1 -1
  22. package/src/business-components/BusinessQuotingMap/BusinessQuotingMap.tsx +4 -4
  23. package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +157 -0
  24. package/src/business-components/BusinessRecomendPlaceMap/index.ts +1 -0
  25. package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +115 -101
  26. package/src/business-components/FitView/FitView.tsx +10 -2
  27. package/src/business-components/PlaceCircle/PlaceCircle.tsx +15 -19
  28. package/src/components/Demo/DemoBusinessQuoting.tsx +1 -2
  29. package/src/components/Demo/DemoBusinessTaxiService.tsx +0 -1
  30. package/src/components/Demo/HeycarDemo.tsx +21 -98
  31. package/src/hooks/useGeoLocation.ts +3 -1
  32. package/src/hooks/useMapFitView.ts +18 -16
  33. package/src/hooks-business/useBusinessRecomendPlaceMap.ts +45 -0
  34. package/src/hooks-business/{useBusinessMapRecomendPlace.ts → useLagecyMapRecomendPlace.ts} +3 -2
  35. package/src/index.ts +4 -1
  36. package/src/types/interface.ts +12 -1
@@ -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
- useBusinessMapRecomendPlace,
6
- UseBusinessMapRecomendPlaceProps,
7
- } from "../../hooks-business/useBusinessMapRecomendPlace";
8
- import { useHeycarMap } from "../../hooks/useHeycarMap";
9
- import { useMapFitView } from "../../hooks/useMapFitView";
10
- import { useMapGeometry } from "../../hooks/useMapGeometry";
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 { mapRef, setMap } = useHeycarMap();
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
- isDragging,
84
- geoLoading,
85
- geoPosition,
79
+ panTo,
86
80
  setCenterPlaceByRecomand,
87
- setCenterByPlace,
88
- } = useBusinessMapRecomendPlace({
89
- geoDefaultPosition: [0, 0],
90
- mapRef,
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
- distance:{" "}
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
- <HeycarMap
92
+ <BusinessRecomendPlaceMap
121
93
  class={css.demo}
122
- fallback={() => <div>error</div>}
123
- loading={() => <div>loading</div>}
124
- center={centerPoint.value}
125
- zoom={centerPoint.value[0] === 0 ? 3 : 13}
126
- mapRef={setMap}
127
- >
128
- {/* <StartEndPoint
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
@@ -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);
@@ -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 UseBusinessMapRecomendPlaceProps
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 useBusinessMapRecomendPlace = (props: UseBusinessMapRecomendPlaceProps) => {
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,5 +1,7 @@
1
1
  import "./style.css";
2
2
  export { AddressBox } from "./business-components/AddressBox";
3
+ export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
4
+ export { BusinessRecomendPlaceMap } from "./business-components/BusinessRecomendPlaceMap";
3
5
  export { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap";
4
6
  export { DrivingLine } from "./business-components/DrivingLine";
5
7
  export { DrivingRoute } from "./business-components/DrivingRoute";
@@ -13,7 +15,8 @@ export { WalkingRoute } from "./business-components/WalkingRoute";
13
15
  export { WaveCircle } from "./business-components/WaveCircle";
14
16
  export * from "./components/MapProvider";
15
17
  export * from "./hooks-business/useBusinessMapAutoComplete";
16
- export * from "./hooks-business/useBusinessMapRecomendPlace";
18
+ export * from "./hooks-business/useBusinessQuotingMap";
19
+ export * from "./hooks-business/useBusinessRecomendPlaceMap";
17
20
  export * from "./hooks-business/useBusinessTaxiServiceMap";
18
21
  export { useDrivingRoute } from "./hooks/useDrivingRoute";
19
22
  export { useGeoLocation } from "./hooks/useGeoLocation";
@@ -28,6 +28,7 @@ export type City = {
28
28
  export interface RegisterOverlay<T> {
29
29
  add: (overlay: T) => void;
30
30
  remove: (overlay: T) => void;
31
+ setFitView: () => void;
31
32
  }
32
33
 
33
34
  export interface Route {
@@ -46,4 +47,14 @@ export type DriverStatus =
46
47
  | "driverArrived"
47
48
  | "inService"
48
49
  | "canceled"
49
- | "endService";
50
+ | "endService"
51
+ | "completed"
52
+ | "canceling"
53
+ | "banlanceRefund"
54
+ | "waitBanlanceRefund"
55
+ | "rechargePayed"
56
+ | "waitRechargePay"
57
+ | "payed"
58
+ | "waitpay"
59
+ | "refund"
60
+ | "confirmed";