@heycar/heycars-map 0.2.8 → 0.2.10

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 (72) hide show
  1. package/dist/Demo/Demo.d.ts +2 -0
  2. package/dist/Demo/DemoBusinessQuoting.d.ts +1 -0
  3. package/dist/Demo/DemoBusinessRecomendPlace.d.ts +1 -0
  4. package/dist/Demo/DemoBusinessTaxiEnd.d.ts +4 -0
  5. package/dist/Demo/DemoBusinessTaxiService.d.ts +1 -0
  6. package/dist/api/contants.d.ts +2 -0
  7. package/dist/business-components/AddressBox/AddressBox.d.ts +2 -1
  8. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +5 -3
  9. package/dist/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +7 -0
  10. package/dist/business-components/BusinessTaxiEndMap/index.d.ts +1 -0
  11. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +7 -0
  12. package/dist/business-components/PassengerCircle/PassengerCircle.d.ts +2 -1
  13. package/dist/business-components/PickupPoints/PickupPoints.d.ts +2 -1
  14. package/dist/components/MapProvider/MapProvider.d.ts +2 -1
  15. package/dist/hooks/useMapAutoComplete.d.ts +3 -3
  16. package/dist/hooks/useMapLog.d.ts +4 -0
  17. package/dist/hooks/useMapPlace.d.ts +3 -3
  18. package/dist/hooks/useMapRecomendPlace.d.ts +10 -7
  19. package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +1 -1
  20. package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +2 -2
  21. package/dist/hooks-business/useLagecyMapRecomendPlace.d.ts +2 -2
  22. package/dist/index.cjs +52 -52
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1015 -938
  25. package/dist/types/interface.d.ts +1 -1
  26. package/dist/utils/helper.d.ts +2 -0
  27. package/package.json +1 -1
  28. package/src/App.tsx +21 -7
  29. package/src/{components/Demo → Demo/CityBound}/SearchDemo.tsx +2 -2
  30. package/src/{components/Demo → Demo}/Demo.tsx +13 -13
  31. package/src/Demo/DemoBusinessQuoting.tsx +18 -0
  32. package/src/Demo/DemoBusinessRecomendPlace.tsx +96 -0
  33. package/src/Demo/DemoBusinessTaxiEnd.tsx +38 -0
  34. package/src/{components/Demo → Demo}/DemoBusinessTaxiService.tsx +6 -26
  35. package/src/api/contants.ts +3 -0
  36. package/src/business-components/AddressBox/AddressBox.tsx +4 -1
  37. package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +55 -41
  38. package/src/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.tsx +43 -0
  39. package/src/business-components/BusinessTaxiEndMap/index.ts +1 -0
  40. package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +5 -2
  41. package/src/business-components/PassengerCircle/PassengerCircle.tsx +4 -1
  42. package/src/business-components/PickupPoints/PickupPoints.tsx +3 -1
  43. package/src/components/MapProvider/MapProvider.tsx +4 -1
  44. package/src/hooks/useMapGeometry.ts +4 -4
  45. package/src/hooks/useMapLog.ts +12 -0
  46. package/src/hooks/useMapPlace.ts +8 -3
  47. package/src/hooks/useMapRecomendPlace.ts +34 -3
  48. package/src/index.ts +1 -0
  49. package/src/types/amap/geocoder.d.ts +2 -0
  50. package/src/types/interface.ts +1 -1
  51. package/src/utils/helper.ts +5 -0
  52. package/todo.md +6 -0
  53. package/dist/components/Demo/BusinessDemo.d.ts +0 -2
  54. package/dist/components/Demo/Demo.d.ts +0 -2
  55. package/dist/components/Demo/DemoBusinessQuoting.d.ts +0 -1
  56. package/dist/components/Demo/DemoBusinessTaxiService.d.ts +0 -2
  57. package/dist/components/Demo/Hello.d.ts +0 -17
  58. package/dist/components/Demo/HeycarDemo.d.ts +0 -3
  59. package/dist/components/Demo/index.d.ts +0 -1
  60. package/src/components/Demo/BusinessDemo.tsx +0 -117
  61. package/src/components/Demo/DemoBusinessQuoting.tsx +0 -38
  62. package/src/components/Demo/Hello.tsx +0 -15
  63. package/src/components/Demo/HeycarDemo.tsx +0 -104
  64. package/src/components/Demo/TemplateDemo.vue +0 -11
  65. package/src/components/Demo/index.ts +0 -1
  66. /package/dist/{components/Demo → Demo/CityBound}/SearchDemo.d.ts +0 -0
  67. /package/dist/{components/Demo → Demo/CityBound}/country.d.ts +0 -0
  68. /package/dist/{components/Demo → Demo/CityBound}/searchResult.d.ts +0 -0
  69. /package/dist/{components/Demo → Demo}/Demo.css.d.ts +0 -0
  70. /package/src/{components/Demo → Demo/CityBound}/country.ts +0 -0
  71. /package/src/{components/Demo → Demo/CityBound}/searchResult.ts +0 -0
  72. /package/src/{components/Demo → Demo}/Demo.css.ts +0 -0
@@ -4,18 +4,18 @@ import { Status } from "./useMapLoader";
4
4
  import { useMapSupplier } from "./useMapSupplier";
5
5
 
6
6
  export const useAmapGeometry = () => {
7
- const { status } = useMapSupplier();
7
+ const payload = useMapSupplier();
8
8
  const apiMapDistance = (from: Point, to: Point) => {
9
- if (status !== Status.SUCCESS) return undefined;
9
+ if (payload.status !== Status.SUCCESS) return undefined;
10
10
  return AMap.GeometryUtil.distance(from, to);
11
11
  };
12
12
  return { apiMapDistance };
13
13
  };
14
14
 
15
15
  export const useGmapGeometry = () => {
16
- const { status } = useMapSupplier();
16
+ const payload = useMapSupplier();
17
17
  const apiMapDistance = (from: Point, to: Point) => {
18
- if (status !== Status.SUCCESS) return undefined;
18
+ if (payload.status !== Status.SUCCESS) return undefined;
19
19
  return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
20
20
  };
21
21
  return { apiMapDistance };
@@ -0,0 +1,12 @@
1
+ import { watchEffect } from "vue-demi";
2
+
3
+ export interface MapLogProps {
4
+ log?: boolean;
5
+ }
6
+
7
+ export const useMapLog = <P extends MapLogProps>(props: P, name: string) => {
8
+ watchEffect(() => {
9
+ if (!props.log) return;
10
+ console.log(`log ${name} props = `, { ...props });
11
+ });
12
+ };
@@ -33,11 +33,13 @@ export const useAmapPlace = (props: UseMapPlaceProps) => {
33
33
  const cityName = addressComponent.city
34
34
  ? addressComponent.city
35
35
  : addressComponent.province;
36
+ const countryName = addressComponent.country;
36
37
  place.name = name;
37
38
  place.lng = lng;
38
39
  place.lat = lat;
39
40
  place.cityName = cityName;
40
- onChange?.({ lng, lat, name, cityName });
41
+ place.countryName = countryName;
42
+ onChange?.({ lng, lat, name, cityName, countryName });
41
43
  return;
42
44
  }
43
45
 
@@ -68,10 +70,13 @@ export const useGmapPlace = (props: UseMapPlaceProps) => {
68
70
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
69
71
  const name = results[0].formatted_address;
70
72
  const cityName = geocoderResult2cityName(results[0]);
71
- place.name = name;
73
+ const countryName = results.slice(-1)[0].address_components[0].long_name;
72
74
  place.lng = lng;
73
75
  place.lat = lat;
74
- onChange?.({ lng, lat, name, cityName });
76
+ place.name = name;
77
+ place.cityName = cityName;
78
+ place.countryName = countryName;
79
+ onChange?.({ lng, lat, name, cityName, countryName });
75
80
  }
76
81
  );
77
82
  return { place, updatePlace };
@@ -33,12 +33,14 @@ export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
33
33
  pointRef: Ref<Point>;
34
34
  context?: C;
35
35
  getLimit: (context?: C) => number;
36
- getRecomendPlace: (place: Place, context?: C) => Promise<Place[]>;
36
+ // 如果返回 undefined, 表示当前位置无服务可提供
37
+ getRecomendPlace: (place: Place, context?: C) => Promise<Place[] | undefined>;
37
38
  onChangePlace?: UseMapPlaceProps["onChange"];
38
39
  onChange?: (place: Place) => any;
39
40
  }
40
41
  export const useAmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
41
42
  const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace } = props;
43
+ const availableRef = ref(true);
42
44
  const placeCandidatesRef = ref<Place[]>([]);
43
45
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
44
46
  const { readyPromise } = useMapSupplier();
@@ -49,19 +51,34 @@ export const useAmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
49
51
  async () => {
50
52
  await readyPromise;
51
53
  const placeCandidates = await getRecomendPlace({ ...place }, context);
54
+ if (placeCandidates === undefined) {
55
+ availableRef.value = false;
56
+ placeCandidatesRef.value = [];
57
+ Object.assign(recomendPlace, { ...place });
58
+ onChange?.({ ...place });
59
+ return;
60
+ }
52
61
  const { shortestPlace, shortestDistance } = findAmapNearestPlace(place, placeCandidates);
53
62
  const limit = getLimit(context);
54
63
  const resultPlace = shortestDistance > limit ? place : shortestPlace;
64
+ availableRef.value = true;
55
65
  placeCandidatesRef.value = placeCandidates;
56
66
  Object.assign(recomendPlace, { ...resultPlace });
57
67
  onChange?.({ ...resultPlace });
58
68
  }
59
69
  );
60
- return { recomendPlace, placeCandidates: placeCandidatesRef, updateRecomandPlace, updatePlace };
70
+ return {
71
+ recomendPlace,
72
+ placeCandidates: placeCandidatesRef,
73
+ availableRef,
74
+ updateRecomandPlace,
75
+ updatePlace,
76
+ };
61
77
  };
62
78
 
63
79
  export const useGmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
64
80
  const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace } = props;
81
+ const availableRef = ref(true);
65
82
  const placeCandidatesRef = ref<Place[]>([]);
66
83
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
67
84
  const { readyPromise } = useMapSupplier();
@@ -72,15 +89,29 @@ export const useGmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
72
89
  async () => {
73
90
  await readyPromise;
74
91
  const placeCandidates = await getRecomendPlace({ ...place }, context);
92
+ if (placeCandidates === undefined) {
93
+ availableRef.value = false;
94
+ placeCandidatesRef.value = [];
95
+ Object.assign(recomendPlace, { ...place });
96
+ onChange?.({ ...place });
97
+ return;
98
+ }
75
99
  const { shortestPlace, shortestDistance } = findGmapNearestPlace(place, placeCandidates);
76
100
  const limit = getLimit(context);
77
101
  const resultPlace = shortestDistance > limit ? place : shortestPlace;
102
+ availableRef.value = true;
78
103
  placeCandidatesRef.value = placeCandidates;
79
104
  Object.assign(recomendPlace, { ...resultPlace });
80
105
  onChange?.({ ...resultPlace });
81
106
  }
82
107
  );
83
- return { recomendPlace, placeCandidates: placeCandidatesRef, updateRecomandPlace, updatePlace };
108
+ return {
109
+ recomendPlace,
110
+ placeCandidates: placeCandidatesRef,
111
+ availableRef,
112
+ updateRecomandPlace,
113
+ updatePlace,
114
+ };
84
115
  };
85
116
 
86
117
  export const useMapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ import "./style.css";
2
2
  export { AddressBox } from "./business-components/AddressBox";
3
3
  export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
4
4
  export { BusinessRecomendPlaceMap } from "./business-components/BusinessRecomendPlaceMap";
5
+ export { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap";
5
6
  export { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap";
6
7
  export { DrivingLine } from "./business-components/DrivingLine";
7
8
  export { DrivingRoute } from "./business-components/DrivingRoute";
@@ -165,6 +165,8 @@ declare global {
165
165
  }
166
166
 
167
167
  export interface AddressComponent {
168
+ // 国家名称,例如: 日本
169
+ country: string;
168
170
  // 坐标点所在省名称 例如:北京市
169
171
  province: string;
170
172
  // 坐标点所在城市名称 请注意:当城市是省直辖县时返回为空,以及城市为北京、上海、天津、重庆四个直辖市时,该字段返回为空;省直辖县列表
@@ -7,7 +7,7 @@ export type Place = {
7
7
  lat: number;
8
8
  name: string;
9
9
  cityName?: string;
10
- cityId?: string;
10
+ countryName?: string;
11
11
  };
12
12
 
13
13
  export interface AutoCompletePlace extends Place {
@@ -0,0 +1,5 @@
1
+ import type { Place } from "../types/interface";
2
+
3
+ export const isPlace = (place: Partial<Place>): place is Place => {
4
+ return place.lng !== undefined && place.lat !== undefined;
5
+ };
package/todo.md CHANGED
@@ -23,3 +23,9 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
23
23
  2. locator 气泡长度限制
24
24
  3. locator 拖动次数多了会不更新
25
25
  4. 郝瑞 searh Place 接口搜索次数多了会不更新
26
+
27
+ ---
28
+
29
+ 1. apiDistance 在 created 生命周期里调用的时候,即便设置了 5 秒延迟,运行到 api 内部的时候 status === 'loading'
30
+ 2. getRecomend 接口需要增加一个返回参数,表示当前地区是否可以提供服务
31
+ 3. 孙明 刚才传入 complted 状态,地图未显示
@@ -1,2 +0,0 @@
1
- export declare const ABusinessDemo: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
2
- export declare const GBusinessDemo: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
@@ -1,2 +0,0 @@
1
- export declare const DemoGmap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
2
- export declare const DemoAmap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
@@ -1 +0,0 @@
1
- export declare const DemoBusinessQuoting: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
@@ -1,2 +0,0 @@
1
- export declare const DemoBusinessTaxiService: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
2
- export declare const TaxiCarServicePage: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
@@ -1,17 +0,0 @@
1
- export declare const Hello: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<{
2
- className?: string | undefined;
3
- qyc: number;
4
- style: any;
5
- }>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<{
6
- className?: string | undefined;
7
- qyc: number;
8
- style: any;
9
- }, Required<{
10
- className?: string | undefined;
11
- qyc: number;
12
- style: any;
13
- }>>, never, {
14
- className?: string | undefined;
15
- qyc: number;
16
- style: any;
17
- }, {}>;
@@ -1,3 +0,0 @@
1
- export declare const HeycarDemo: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
2
- export declare const SomeOuterPage: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
3
- export declare const SomeHomePage: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, unknown, {}>;
@@ -1 +0,0 @@
1
- export * from "./Demo";
@@ -1,117 +0,0 @@
1
- import { APlaceCircle, GPlaceCircle } from "../../business-components/PlaceCircle";
2
- import { GWaveCircle } from "../../business-components/WaveCircle";
3
- import { defineSetup } from "../../types/helper";
4
- import { Amap } from "../Amap";
5
- import { AmapLoader } from "../AmapLoader";
6
- import { Gmap } from "../Gmap";
7
- import { GmapLoader } from "../GmapLoader";
8
- import * as css from "./Demo.css";
9
-
10
- const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
11
- const gmapId = import.meta.env.VITE_GMAP_MAP_ID;
12
- const amapApiKey = import.meta.env.VITE_AMAP_API_KEY;
13
- const amapApiSecret = import.meta.env.VITE_AMAP_API_SECRET;
14
-
15
- export const ABusinessDemo = defineSetup(function ABusinessDemo() {
16
- return () => (
17
- <AmapLoader
18
- apiKey={amapApiKey}
19
- apiSecret={amapApiSecret}
20
- loading={() => <div>loading</div>}
21
- fallback={() => <div>error</div>}
22
- plugins={["AMap.AutoComplete"]}
23
- >
24
- <Amap class={css.demo} center={[0, 0]} zoom={3}>
25
- {/* <APassengerCircle position={[0, 0]} /> */}
26
- {/* <AAddressBox position={[0, 0]} title={"Martyrs Lawn"} description={"您将在此处上车"} /> */}
27
- <APlaceCircle position={[0, 0]} label={"Kenkey Hut"} />
28
- {/* <AAddressLocator position={[0, 0]} /> */}
29
- {/* <AmapMarker position={[0, 0]} /> */}
30
- {/* <AStartEndPoint
31
- type="end"
32
- position={[0, 0]}
33
- title="2月14日 11:00 用车"
34
- description={"全程 *4.12公里* 约行驶 *22分钟*"}
35
- /> */}
36
- {/* <ATaxiCar position={[0, 0]} angle={90} title="距离终点 *4.2公里* 预计 *25分钟*" /> */}
37
- {/* <ADrivingLine
38
- path={[
39
- [-5, -5],
40
- [-4, -3],
41
- [-3, -4],
42
- [-2, -1],
43
- [-1, -2],
44
- [0, 1],
45
- [1, 0],
46
- [2, 2],
47
- ]}
48
- /> */}
49
- {/* <AWalkingLine
50
- path={[
51
- [-5, -5],
52
- [-4, -3],
53
- [-3, -4],
54
- [-2, -1],
55
- [-1, -2],
56
- [0, 1],
57
- [1, 0],
58
- [2, 2],
59
- ]}
60
- /> */}
61
- {/* <AWaveCircle position={[0, 0]} /> */}
62
- </Amap>
63
- </AmapLoader>
64
- );
65
- });
66
-
67
- export const GBusinessDemo = defineSetup(function GBusinessDemo() {
68
- return () => (
69
- <GmapLoader
70
- version="beta"
71
- apiKey={gmapApiKey}
72
- loading={() => <div>loading</div>}
73
- fallback={() => <div>error</div>}
74
- libraries={["places", "marker"]}
75
- >
76
- <Gmap class={css.demo} center={{ lat: 0, lng: 0 }} zoom={3} mapId={gmapId}>
77
- {/* {/* <GmapMarker position={{ lat: 0, lng: 0 }} /> */}
78
- {/* <GPassengerCircle position={[0, 0]} /> */}
79
- {/* <GAddressLocator position={[0, 0]} /> */}
80
- <GPlaceCircle position={[0, 0]} />
81
- {/* <GAddressBox position={[0, 0]} title={"当前区域暂未开通服务"} /> */}
82
- {/* <GStartEndPoint
83
- type="start"
84
- position={[0, 0]}
85
- title="Webster Dental Plaza"
86
- description={"全程 *4.12公里* 约行驶 *22分钟*"}
87
- /> */}
88
- {/* <GTaxiCar position={[0, 0]} /> */}
89
- {/* <GDrivingLine
90
- path={[
91
- [-5, -5],
92
- [-4, -3],
93
- [-3, -4],
94
- [-2, -1],
95
- [-1, -2],
96
- [0, 1],
97
- [1, 0],
98
- [2, 2],
99
- ]}
100
- /> */}
101
- {/* <GWalkingLine
102
- path={[
103
- [-5, -5],
104
- [-4, -3],
105
- [-3, -4],
106
- [-2, -1],
107
- [-1, -2],
108
- [0, 1],
109
- [1, 0],
110
- [2, 2],
111
- ]}
112
- /> */}
113
- <GWaveCircle position={[0, 0]} />
114
- </Gmap>
115
- </GmapLoader>
116
- );
117
- });
@@ -1,38 +0,0 @@
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,15 +0,0 @@
1
- import { defineSetup } from "../../types/helper";
2
-
3
- export const Hello = defineSetup(function Hello(props: {
4
- className?: string;
5
- qyc: number;
6
- style: any;
7
- }) {
8
- return () => (
9
- <section>
10
- <span class={props.className} style={props.style}>
11
- hello
12
- </span>
13
- </section>
14
- );
15
- });
@@ -1,104 +0,0 @@
1
- import { computed } from "vue-demi";
2
- import {
3
- BusinessRecomendPlaceMap,
4
- BusinessRecomendPlaceMapProps,
5
- } from "../../business-components/BusinessRecomendPlaceMap";
6
- import { useBusinessMapAutoComplete } from "../../hooks-business/useBusinessMapAutoComplete";
7
- import { useBusinessRecomendPlaceMap } from "../../hooks-business/useBusinessRecomendPlaceMap";
8
-
9
- import { defineSetup } from "../../types/helper";
10
- import { HeycarMap, MapProvider } from "../MapProvider/MapProvider";
11
- import * as css from "./Demo.css";
12
-
13
- const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
14
- const gmapId = import.meta.env.VITE_GMAP_MAP_ID;
15
- const amapApiKey = import.meta.env.VITE_AMAP_API_KEY;
16
- const amapApiSecret = import.meta.env.VITE_AMAP_API_SECRET;
17
-
18
- export const HeycarDemo = defineSetup(function HeycarDemo() {
19
- return () => (
20
- <MapProvider
21
- amapKey={amapApiKey}
22
- amapSecret={amapApiSecret}
23
- gmapId={gmapId}
24
- gmapKey={gmapApiKey}
25
- supplier={"amap"}
26
- >
27
- <SomeHomePage />
28
- </MapProvider>
29
- );
30
- });
31
-
32
- export const SomeOuterPage = defineSetup(function SomeOuterPage() {
33
- return () => {
34
- return (
35
- <div>
36
- <SomeAutoComplete cityName="上海市"></SomeAutoComplete>
37
- <HeycarMap
38
- class={css.demo}
39
- fallback={() => <div>error</div>}
40
- loading={() => <div>loading</div>}
41
- center={[121.5, 31]}
42
- zoom={13}
43
- ></HeycarMap>
44
- </div>
45
- );
46
- };
47
- });
48
- const SomeAutoComplete = defineSetup(function SomeAutoComplete(props: { cityName: string }) {
49
- const { autoCompletePlaces, setKeyword, setCity } = useBusinessMapAutoComplete({
50
- cityNameRef: computed(() => props.cityName),
51
- });
52
- (window as any).setKeyword = setKeyword;
53
- (window as any).setCity = setCity;
54
- return () => {
55
- const list = autoCompletePlaces.value.map((place) => (
56
- <div>
57
- {place.lng} | {place.lat} | {place.name} | {place.description}
58
- </div>
59
- ));
60
- return <div>{list}</div>;
61
- };
62
- });
63
-
64
- export const SomeHomePage = defineSetup(function SomeHomePage() {
65
- const getRecomendPlace: BusinessRecomendPlaceMapProps["getRecomendPlace"] = async (
66
- place,
67
- context
68
- ) => {
69
- const { lat, lng } = place;
70
- console.log("getRecomendPlace context?.source = ", context?.source);
71
- return [
72
- { lat: lat + 0.0001, lng: lng + 0.0001, name: "place name 1" },
73
- { lat: lat + 0.002, lng: lng + 0.002, name: "place name 2" },
74
- ];
75
- };
76
- const {
77
- centerPlace,
78
- placeCandidates,
79
- panTo,
80
- setCenterPlaceByRecomand,
81
- mapContext,
82
- apiMapDistance,
83
- } = useBusinessRecomendPlaceMap();
84
-
85
- (window as any).setCenterPlaceByRecomand = setCenterPlaceByRecomand;
86
- return () => {
87
- return (
88
- <div>
89
- placeCandidates: {placeCandidates} <br />
90
- centerPlace: {centerPlace.lng} | {centerPlace.lat} | {centerPlace.name} |{" "}
91
- {centerPlace.cityName} <br />
92
- <BusinessRecomendPlaceMap
93
- class={css.demo}
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
- />
101
- </div>
102
- );
103
- };
104
- });
@@ -1,11 +0,0 @@
1
- <script>
2
- import { defineComponent } from "vue";
3
- import { Hello } from "./Hello";
4
-
5
- export default defineComponent({
6
- components: { Hello },
7
- });
8
- </script>
9
- <template>
10
- <Hello class="hi3" qyc="3"></Hello>
11
- </template>
@@ -1 +0,0 @@
1
- export * from "./Demo";
File without changes
File without changes