@heycar/heycars-map 0.1.2 → 0.1.4

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 (52) hide show
  1. package/README.md +122 -11
  2. package/dist/api/geometry.d.ts +1 -2
  3. package/dist/business-components/DrivingLine/DrivingLine.d.ts +1 -0
  4. package/dist/business-components/DrivingRoute/DrivingRoute.d.ts +13 -0
  5. package/dist/business-components/DrivingRoute/index.d.ts +1 -0
  6. package/dist/business-components/PickupPoints/PickupPoints.d.ts +5 -0
  7. package/dist/business-components/PickupPoints/index.d.ts +1 -0
  8. package/dist/business-components/PlaceCircle/PlaceCircle.css.d.ts +28 -3
  9. package/dist/business-components/PlaceCircle/PlaceCircle.d.ts +2 -2
  10. package/dist/components/Amap/Amap.d.ts +9 -6
  11. package/dist/components/Demo/HeycarDemo.d.ts +1 -1
  12. package/dist/components/Gmap/Gmap.d.ts +7 -5
  13. package/dist/components/MapProvider/MapProvider.d.ts +6 -2
  14. package/dist/hooks/useDrivingRoute.d.ts +9 -0
  15. package/dist/hooks/useHeycarMap.d.ts +1601 -0
  16. package/dist/hooks/useMapAngle.d.ts +10 -0
  17. package/dist/hooks/useMapDrag.d.ts +33 -0
  18. package/dist/index.cjs +56 -56
  19. package/dist/index.d.ts +6 -2
  20. package/dist/index.js +1133 -838
  21. package/dist/style.css +1 -1
  22. package/dist/types/helper.d.ts +5 -2
  23. package/dist/types/interface.d.ts +3 -0
  24. package/dist/types/mapHelper.d.ts +3 -0
  25. package/dist/utils/transform.d.ts +2 -0
  26. package/package.json +1 -1
  27. package/src/api/geometry.ts +2 -1
  28. package/src/business-components/DrivingLine/DrivingLine.tsx +15 -7
  29. package/src/business-components/DrivingRoute/DrivingRoute.tsx +48 -0
  30. package/src/business-components/DrivingRoute/index.ts +1 -0
  31. package/src/business-components/PickupPoints/PickupPoints.tsx +16 -0
  32. package/src/business-components/PickupPoints/index.ts +1 -0
  33. package/src/business-components/PlaceCircle/PlaceCircle.css.ts +39 -8
  34. package/src/business-components/PlaceCircle/PlaceCircle.tsx +22 -7
  35. package/src/business-components/TaxiCar/TaxiCar.tsx +3 -2
  36. package/src/components/Amap/Amap.ts +23 -5
  37. package/src/components/AmapLoader/AmapLoader.ts +1 -1
  38. package/src/components/Demo/HeycarDemo.tsx +38 -17
  39. package/src/components/Gmap/Gmap.ts +14 -7
  40. package/src/components/MapProvider/MapProvider.tsx +30 -17
  41. package/src/hooks/useDrivingRoute.ts +73 -0
  42. package/src/hooks/useHeycarMap.ts +28 -0
  43. package/src/hooks/useMapAngle.ts +43 -0
  44. package/src/hooks/useMapDrag.ts +81 -0
  45. package/src/index.ts +6 -2
  46. package/src/types/amap/driving.d.ts +2 -0
  47. package/src/types/helper.ts +38 -8
  48. package/src/types/interface.ts +3 -0
  49. package/src/types/mapHelper.ts +1 -0
  50. package/src/utils/transform.ts +10 -0
  51. package/dist/hooks/useMapCenter.d.ts +0 -30
  52. package/src/hooks/useMapCenter.ts +0 -70
package/README.md CHANGED
@@ -1,18 +1,129 @@
1
- # Vue 3 + TypeScript + Vite
1
+ ### 说明
2
2
 
3
- This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
3
+ 时间关系,先写个简要文档,之后会补一个全面的文档。
4
4
 
5
- ## Recommended IDE Setup
5
+ ### 特性
6
6
 
7
- - [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
7
+ - 集成 高德 谷歌 两个地图
8
+ - 支持 vue 2.7 和 vue 3
9
+ - 统一的接口,不需要写两套
8
10
 
9
- ## Type Support For `.vue` Imports in TS
11
+ ### 安装
10
12
 
11
- TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
13
+ ```bash
14
+ # 安装依赖包
15
+ npm install @heycar/heycars-map --save
12
16
 
13
- If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
17
+ ```
14
18
 
15
- 1. Disable the built-in TypeScript Extension
16
- 1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
17
- 2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
18
- 2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
19
+ ### 使用
20
+
21
+ #### 入口文件添加 `MapProvider`
22
+
23
+ - 对于 jsx/tsx 文件的例子
24
+
25
+ ```jsx
26
+ <MapProvider
27
+ // 高德地图 api key
28
+ amapKey={amapApiKey}
29
+ // 高德地图 secret
30
+ amapSecret={amapApiSecret}
31
+ // 谷歌地图 id
32
+ gmapId={gmapId}
33
+ // 谷歌地图 api key
34
+ gmapKey={gmapApiKey}
35
+ // 使用哪个地图供应商,目前两个供应商: amap 高德 / gmap 谷歌
36
+ supplier={"amap"}
37
+ >
38
+ ...
39
+ </MapProvider>
40
+ ```
41
+
42
+ - 对于 vue 文件的例子
43
+
44
+ ```vue
45
+ <MapProvider
46
+ :gmap-id="gmapId"
47
+ :gmap-key="gmapApiKey"
48
+ :amap-key="amapApiKey"
49
+ :amap-secret="amapApiSecret"
50
+ supplier="amap"
51
+ >
52
+ ...
53
+ </MapProvider>
54
+ ```
55
+
56
+ #### 在需要用到地图的地方添加 `HeycarMap`
57
+
58
+ - 对于 jsx/tsx 文件的例子
59
+
60
+ ```jsx
61
+ <HeycarMap
62
+ class="any class name"
63
+ // 地图加载失败要显示的内容
64
+ fallback={() => <div>error</div>}
65
+ // 地图还没有加载完成时要显示的内容
66
+ loading={() => <div>loading</div>}
67
+ // 地图中心点
68
+ center={[0, 0]}
69
+ // 地图放缩
70
+ zoom={3}
71
+ >
72
+ ...
73
+ </HeycarMap>
74
+ ```
75
+
76
+ - 对于 vue 文件的例子
77
+
78
+ ```vue
79
+ <HeycarMap :center="[0, 0]" class="any class name" :zoom="3">
80
+ <template #fallback>error</template>
81
+ <template #loading>loading</template>
82
+ ...
83
+ </HeycarMap>
84
+ ```
85
+
86
+ #### 在地图里可以使用的组件
87
+
88
+ 目前有下列组件可以使用
89
+
90
+ - `AddressBox`
91
+ - `AddressLocator`
92
+ - `DrivingLine`
93
+ - `PassengerCircle`
94
+ - `PlaceCircle`
95
+ - `StartEndPoint`
96
+ - `TaxiCar`
97
+ - `WalkingLine`
98
+ - `WaveCircle`
99
+ - `DrivingRoute`
100
+
101
+ 目前有下列组件可以使用下列 hooks
102
+
103
+ - `useHeycarMap`
104
+ - `useMapDrag`
105
+ - `useMapAngle`
106
+ - `useDrivingRoute`
107
+
108
+ #### 在地图里使用 `AddressBox` ,需要放在 `HeycarMap` 内部
109
+
110
+ ```jsx
111
+ <HeycarMap center={[0, 0]} zoom={3}>
112
+ ...
113
+ <AddressBox position={[0, 0]} title={"Martyrs Lawn"} description={"您将在此处上车"} />
114
+ ...
115
+ </HeycarMap>
116
+ ```
117
+
118
+ - 对于 vue 文件的例子
119
+
120
+ ```vue
121
+ <HeycarMap :center="[0, 0]" class="any class name" :zoom="3">
122
+ <template #fallback>error</template>
123
+ <template #loading>loading</template>
124
+ ...
125
+ <AddressBox title="Martyrs Lawn" :position="[0, 0]" description="您将在此处上车" >
126
+ </AddressBox>
127
+ ...
128
+ </HeycarMap>
129
+ ```
@@ -1,7 +1,7 @@
1
+ import type { Point } from "../types/interface";
1
2
  export interface ApiMapMeta {
2
3
  isGoogle: boolean;
3
4
  }
4
- type Point = [number, number];
5
5
  export interface DistanceOfLineProps extends ApiMapMeta {
6
6
  path: Point[];
7
7
  }
@@ -17,4 +17,3 @@ export interface IsPointInLineProps extends ApiMapMeta {
17
17
  tolerance: number;
18
18
  }
19
19
  export declare function apiIsPointInLine(props: IsPointInLineProps): boolean;
20
- export {};
@@ -1,4 +1,5 @@
1
1
  export interface DrivingLineProps {
2
+ done?: boolean;
2
3
  path: [number, number][];
3
4
  }
4
5
  export declare const ADrivingLine: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<DrivingLineProps>, 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<DrivingLineProps, Required<DrivingLineProps>>, never, DrivingLineProps, {}>;
@@ -0,0 +1,13 @@
1
+ import type { Ref, ShallowRef } from "vue-demi";
2
+ import { UseDrivingRouteProps } from "../../hooks/useDrivingRoute";
3
+ import { VNodeChild } from "../../types/helper";
4
+ import type { Point } from "../../types/interface";
5
+ export interface DrivingRouteProps extends UseDrivingRouteProps {
6
+ render?: (props: {
7
+ pathRef: ShallowRef<Point[]>;
8
+ angleRef: Ref<number | undefined>;
9
+ }) => VNodeChild;
10
+ }
11
+ export declare const ADrivingRoute: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<DrivingRouteProps>, 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<DrivingRouteProps, Required<DrivingRouteProps>>, never, DrivingRouteProps, {}>;
12
+ export declare const GDrivingRoute: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<DrivingRouteProps>, 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<DrivingRouteProps, Required<DrivingRouteProps>>, never, DrivingRouteProps, {}>;
13
+ export declare const DrivingRoute: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<DrivingRouteProps>, 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<DrivingRouteProps, Required<DrivingRouteProps>>, never, DrivingRouteProps, {}>;
@@ -0,0 +1 @@
1
+ export * from "./DrivingRoute";
@@ -0,0 +1,5 @@
1
+ export interface PickupPointsProps {
2
+ positions: [number, number][];
3
+ labels: string[];
4
+ }
5
+ export declare const PickupPoints: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<PickupPointsProps>, 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<PickupPointsProps, Required<PickupPointsProps>>, never, PickupPointsProps, {}>;
@@ -0,0 +1 @@
1
+ export * from "./PickupPoints";
@@ -1,5 +1,30 @@
1
- export declare const placeCircleLayout: string;
2
- export declare const amapPlaceIconLayout: string;
3
- export declare const gmapPlaceIconLayout: string;
1
+ export declare const placeCircleLayout: import("@vanilla-extract/recipes").RuntimeFn<{
2
+ textAlign: {
3
+ left: {
4
+ flexDirection: "row-reverse";
5
+ };
6
+ right: {};
7
+ };
8
+ }>;
9
+ export declare const amapPlaceIconLayout: import("@vanilla-extract/recipes").RuntimeFn<{
10
+ textAlign: {
11
+ left: {
12
+ marginRight: "-2.265vw";
13
+ };
14
+ right: {
15
+ marginLeft: "-2.265vw";
16
+ };
17
+ };
18
+ }>;
19
+ export declare const gmapPlaceIconLayout: import("@vanilla-extract/recipes").RuntimeFn<{
20
+ textAlign: {
21
+ left: {
22
+ marginRight: "calc(50% - 2.265vw)";
23
+ };
24
+ right: {
25
+ marginLeft: "calc(50% - 2.265vw)";
26
+ };
27
+ };
28
+ }>;
4
29
  export declare const placeIcon: string;
5
30
  export declare const label: string;
@@ -1,8 +1,8 @@
1
- interface PlaceCircleProps {
1
+ export interface PlaceCircleProps {
2
2
  position: [number, number];
3
3
  label?: string;
4
+ textAlign?: "left" | "right";
4
5
  }
5
6
  export declare const APlaceCircle: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<PlaceCircleProps>, 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<PlaceCircleProps, Required<PlaceCircleProps>>, never, PlaceCircleProps, {}>;
6
7
  export declare const GPlaceCircle: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<PlaceCircleProps>, 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<PlaceCircleProps, Required<PlaceCircleProps>>, never, PlaceCircleProps, {}>;
7
8
  export declare const PlaceCircle: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<PlaceCircleProps>, 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<PlaceCircleProps, Required<PlaceCircleProps>>, never, PlaceCircleProps, {}>;
8
- export {};
@@ -1,7 +1,10 @@
1
- export interface AmapProps extends AMap.MapOptions {
2
- onMapMove?: (e: {
3
- type: "mapmove";
4
- target: AMap.Map;
5
- }) => void;
1
+ import type { SetMap } from "../../hooks/useHeycarMap";
2
+ import type { MapEventHandler } from "../../types/mapHelper";
3
+ import type { VectorMapForeign } from "../../utils/transform";
4
+ export interface AmapProps extends Omit<AMap.MapOptions, "vectorMapForeign"> {
5
+ vectorMapForeign?: VectorMapForeign;
6
+ mapRef?: SetMap<AMap.Map>;
7
+ onDragStart?: MapEventHandler<AMap.Map>;
8
+ onDragEnd?: MapEventHandler<AMap.Map>;
6
9
  }
7
- export declare const Amap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<AmapProps>, 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<AmapProps, Required<AmapProps>>, "mapMove", AmapProps, {}>;
10
+ export declare const Amap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<AmapProps>, 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<AmapProps, Required<AmapProps>>, "dragStart" | "dragEnd", AmapProps, {}>;
@@ -1,2 +1,2 @@
1
1
  export declare const HeycarDemo: 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 Hello: 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 SomePage: 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,7 +1,9 @@
1
1
  /// <reference types="google.maps" />
2
- export interface GampProps extends google.maps.MapOptions {
3
- onCenter_changed?: (e: {
4
- target: google.maps.Map;
5
- }) => void;
2
+ import type { SetMap } from "../../hooks/useHeycarMap";
3
+ import type { MapEventHandler } from "../../types/mapHelper";
4
+ export interface GmapProps extends google.maps.MapOptions {
5
+ mapRef?: SetMap<google.maps.Map>;
6
+ onDragStart?: MapEventHandler<google.maps.Map>;
7
+ onDragEnd?: MapEventHandler<google.maps.Map>;
6
8
  }
7
- export declare const Gmap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<GampProps>, 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<GampProps, Required<GampProps>>, "center_changed", GampProps, {}>;
9
+ export declare const Gmap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<GmapProps>, 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<GmapProps, Required<GmapProps>>, "dragStart" | "dragEnd", GmapProps, {}>;
@@ -1,9 +1,13 @@
1
+ /// <reference types="google.maps" />
2
+ import type { SetMap } from "../../hooks/useHeycarMap";
1
3
  import { AmapProps } from "../Amap";
2
4
  import { GmapLoaderProps } from "../GmapLoader";
3
5
  import { MapSupplierPayolad } from "./useMapSupplier";
4
6
  export type MapProviderProps = MapSupplierPayolad;
5
7
  export declare const MapProvider: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<MapSupplierPayolad>, 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<MapSupplierPayolad, Required<MapSupplierPayolad>>, never, MapSupplierPayolad, {}>;
6
8
  export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
7
- onChangeCenter?: (value: [number, number]) => any;
9
+ language?: "en" | "zh";
10
+ mapRef?: SetMap<AMap.Map> | SetMap<google.maps.Map>;
11
+ onDragEnd?: (value: [number, number]) => any;
8
12
  }
9
- export declare const HeycarMap: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<HeycarMapProps>, 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<HeycarMapProps, Required<HeycarMapProps>>, "changeCenter", HeycarMapProps, {}>;
13
+ export declare const HeycarMap: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<HeycarMapProps>, 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<HeycarMapProps, Required<HeycarMapProps>>, "dragEnd", HeycarMapProps, {}>;
@@ -0,0 +1,9 @@
1
+ import { ShallowRef } from "vue-demi";
2
+ import type { Point } from "../types/interface";
3
+ export interface UseDrivingRouteProps {
4
+ from: Point;
5
+ to: Point;
6
+ }
7
+ export declare const useADrivingRoute: (props: UseDrivingRouteProps) => ShallowRef<Point[]>;
8
+ export declare const useGDrivingRoute: (props: UseDrivingRouteProps) => ShallowRef<Point[]>;
9
+ export declare const useDrivingRoute: (props: UseDrivingRouteProps) => ShallowRef<Point[]>;