@heycar/heycars-map 0.2.12 → 0.3.1

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 (34) hide show
  1. package/dist/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.d.ts +8 -0
  2. package/dist/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +8 -2
  3. package/dist/business-components/AddressBox/AddressBox.d.ts +5 -7
  4. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +3 -1
  5. package/dist/components/Gmap/Gmap.css.d.ts +1 -0
  6. package/dist/hooks/useMapAutoComplete.d.ts +5 -1
  7. package/dist/hooks/useMapLog.d.ts +2 -1
  8. package/dist/hooks/useMapPlace.d.ts +3 -0
  9. package/dist/hooks/useMapRecomendPlace.d.ts +6 -0
  10. package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +3 -1
  11. package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +2 -0
  12. package/dist/hooks-business/useLagecyMapRecomendPlace.d.ts +2 -0
  13. package/dist/index.cjs +48 -48
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1026 -975
  16. package/dist/style.css +1 -1
  17. package/dist/types/interface.d.ts +1 -0
  18. package/package.json +1 -1
  19. package/src/Demo/DemoBusinessRecomendPlace.tsx +5 -3
  20. package/src/Demo/sample.json +793 -0
  21. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.ts +66 -0
  22. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.tsx +34 -3
  23. package/src/business-components/AddressBox/AddressBox.tsx +2 -4
  24. package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +5 -4
  25. package/src/components/Amap/Amap.css.ts +3 -1
  26. package/src/components/Gmap/Gmap.css.ts +5 -0
  27. package/src/components/Gmap/Gmap.ts +3 -1
  28. package/src/hooks/useMapAutoComplete.ts +3 -1
  29. package/src/hooks/useMapLog.ts +14 -2
  30. package/src/hooks/useMapPlace.ts +6 -2
  31. package/src/hooks-business/useBusinessMapAutoComplete.ts +3 -2
  32. package/src/index.ts +1 -0
  33. package/src/types/interface.ts +1 -0
  34. package/todo.md +5 -9
@@ -0,0 +1,66 @@
1
+ import { style } from "@vanilla-extract/css";
2
+
3
+ export const absoluteAddressBoxLayout = style({
4
+ position: "absolute",
5
+ bottom: "50%",
6
+ left: 0,
7
+ right: 0,
8
+ marginLeft: "auto",
9
+ marginRight: "auto",
10
+ display: "flex",
11
+ flexDirection: "column",
12
+ alignItems: "center",
13
+ zIndex: 1,
14
+ });
15
+
16
+ export const absoluteAddressBox = style({
17
+ padding: "2.67vw 4.27vw",
18
+ background: "linear-gradient(90deg, #79AFFF 0%, #5C8DFF 32%, #507FFF 75%, #4471FF 100%)",
19
+ borderRadius: "3.2vw",
20
+ display: "flex",
21
+ alignItems: "center",
22
+ });
23
+
24
+ export const boxTextLayout = style({
25
+ paddingRight: "2.67vw",
26
+ maxWidth: "41.33vw",
27
+ });
28
+
29
+ export const boxTitle = style({
30
+ display: "-webkit-box",
31
+ fontSize: "3.47vw",
32
+ fontFamily: "PingFangSC-Semibold, PingFang SC",
33
+ fontWeight: 600,
34
+ color: "#FFFFFF",
35
+ lineHeight: "4.8vw",
36
+ WebkitLineClamp: 2,
37
+ WebkitBoxOrient: "vertical",
38
+ overflow: "hidden",
39
+ });
40
+
41
+ export const boxDescription = style({
42
+ marginTop: "0.53vw",
43
+ fontSize: "2.93vw",
44
+ fontFamily: "PingFangSC-Regular, PingFang SC",
45
+ fontWeight: 400,
46
+ color: "#FFFFFF",
47
+ lineHeight: "4.27vw",
48
+ opacity: 0.8,
49
+ });
50
+
51
+ export const arrowRight = style({
52
+ width: "1.758vw",
53
+ height: "2.93vw",
54
+ });
55
+
56
+ export const straightLine = style({
57
+ width: "0.8vw",
58
+ height: "4vw",
59
+ background: "#4C80FF",
60
+ borderRadius: "0vw 0vw 26.67vw 26.67vw",
61
+ });
62
+
63
+ export const locatorIcon = style({
64
+ width: "6.9355vw",
65
+ height: "10.67vw",
66
+ });
@@ -1,8 +1,39 @@
1
+ import imgAddressLocator from "../../assets/icons/svg/address-locator.svg";
2
+ import imgArrowRight from "../../assets/icons/svg/arrow-right.svg";
3
+ import type { MapLogProps } from "../../hooks/useMapLog";
1
4
  import { defineSetup } from "../../types/helper";
2
- import type { AddressBoxProps } from "../AddressBox";
5
+ import * as css from "./AbsoluteAddressBox.css";
3
6
 
4
- export const AbsoluteAddressBox = defineSetup((props: AddressBoxProps) => {
7
+ export interface AbsoluteAddressBoxProps extends MapLogProps {
8
+ type: "box" | "locator";
9
+ title: string;
10
+ description?: string;
11
+ onClick?: () => any;
12
+ }
13
+ export const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox(
14
+ props: AbsoluteAddressBoxProps,
15
+ { emit }
16
+ ) {
17
+ const handleClick = () => emit("click");
5
18
  return () => {
6
- return <div></div>;
19
+ const { type, title, description } = props;
20
+ if (type === "locator")
21
+ return (
22
+ <div class={css.absoluteAddressBoxLayout}>
23
+ <img class={css.locatorIcon} src={imgAddressLocator} />
24
+ </div>
25
+ );
26
+ return (
27
+ <div class={css.absoluteAddressBoxLayout}>
28
+ <div class={css.absoluteAddressBox} onClick={handleClick}>
29
+ <div class={css.boxTextLayout}>
30
+ <div class={css.boxTitle}>{title}</div>
31
+ {description && <div class={css.boxDescription}>{description}</div>}
32
+ </div>
33
+ <img class={css.arrowRight} src={imgArrowRight} />
34
+ </div>
35
+ <i class={css.straightLine} />
36
+ </div>
37
+ );
7
38
  };
8
39
  });
@@ -9,14 +9,12 @@ import { createElement, defineSetup } from "../../types/helper";
9
9
  import type { Point } from "../../types/interface";
10
10
  import { createDom } from "../../utils/dom";
11
11
  import { vec2lnglat } from "../../utils/transform";
12
+ import type { AbsoluteAddressBoxProps } from "../AbsoluteAddressBox";
12
13
  import { AAddressLocator, GAddressLocator } from "../AddressLocator";
13
14
  import * as css from "./AddressBox.css";
14
15
 
15
- export interface AddressBoxProps extends MapLogProps {
16
- type: "box" | "locator";
16
+ export interface AddressBoxProps extends MapLogProps, AbsoluteAddressBoxProps {
17
17
  position: Point;
18
- title: string;
19
- description?: string;
20
18
  }
21
19
  export const AAddressBox = defineSetup(function AAddressBox(props: AddressBoxProps) {
22
20
  useMapLog(props, "AAddressBox");
@@ -10,7 +10,7 @@ import { useMapRecomendPlace, UseMapRecomendPlaceProps } from "../../hooks/useMa
10
10
  import { useMapSupplier } from "../../hooks/useMapSupplier";
11
11
  import { defineLagecySetup } from "../../types/helper";
12
12
  import type { Place, Point } from "../../types/interface";
13
- import { AddressBox } from "../AddressBox";
13
+ import { AbsoluteAddressBox, AbsoluteAddressBoxProps } from "../AbsoluteAddressBox";
14
14
  import { PassengerCircle } from "../PassengerCircle";
15
15
  import { PickupPoints } from "../PickupPoints";
16
16
 
@@ -35,12 +35,13 @@ export interface BusinessRecomendPlaceMapProps
35
35
  onChangePlace?: UseMapPlaceProps["onChange"];
36
36
  onChangeRecomandPlace?: UseMapRecomendPlaceProps["onChange"];
37
37
  onGeoError?: UseGeoLocationProps["onError"];
38
+ onClickLocator?: AbsoluteAddressBoxProps["onClick"];
38
39
  }
39
40
  export const BusinessRecomendPlaceMap = defineLagecySetup(
40
41
  (props: BusinessRecomendPlaceMapProps, { emit }) => {
41
42
  useMapLog(props, "BusinessRecomendPlaceMap");
42
43
  const { geoDefaultPosition, getRecomendPlace, mapContext } = props;
43
- const { mapRef, setMap, panTo } = useHeycarMap();
44
+ const { mapRef, setMap } = useHeycarMap();
44
45
  const { readyPromise } = useMapSupplier();
45
46
  const centerPlace = reactive<Place>({
46
47
  lng: geoDefaultPosition?.[0] ?? 0,
@@ -151,12 +152,12 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
151
152
  <HeycarMap center={centerPoint.value} zoom={18} mapRef={setMap} log={props.log}>
152
153
  <PassengerCircle position={geoPosition.value} />
153
154
  <PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} log={props.log} />
154
- <AddressBox
155
- position={centerPoint.value}
155
+ <AbsoluteAddressBox
156
156
  title={availableRef.value ? centerPlace.name : props.unavailableTitle}
157
157
  description={description}
158
158
  type={isDragging.value ? "locator" : "box"}
159
159
  log={props.log}
160
+ onClick={() => emit("clickLocator")}
160
161
  />
161
162
  </HeycarMap>
162
163
  );
@@ -1,3 +1,5 @@
1
1
  import { style } from "@vanilla-extract/css";
2
2
 
3
- export const amap = style({});
3
+ export const amap = style({
4
+ position: "relative",
5
+ });
@@ -0,0 +1,5 @@
1
+ import { style } from "@vanilla-extract/css";
2
+
3
+ export const gmap = style({
4
+ position: "relative",
5
+ });
@@ -8,6 +8,8 @@ import {
8
8
  watchNoneImmediatePostEffectForDeepOption,
9
9
  watchPostEffectForGMapEvent,
10
10
  } from "../../utils/compare";
11
+ import * as css from "./Gmap.css";
12
+
11
13
  export interface GmapProps extends google.maps.MapOptions {
12
14
  mapRef?: SetMap<google.maps.Map>;
13
15
  onDragStart?: MapEventHandler<google.maps.Map>;
@@ -50,5 +52,5 @@ export const Gmap = defineSetup(function Gmap(props: GmapProps, { slots, emit })
50
52
  }
51
53
  );
52
54
  watchPostEffectForGMapEvent(mapRef, props, handleDrag, ["onDragStart", "onDragEnd"]);
53
- return () => h("div", { ref: elementRef }, slots.default?.());
55
+ return () => h("div", { ref: elementRef, class: css.gmap }, slots.default?.());
54
56
  });
@@ -1,15 +1,17 @@
1
1
  import { ref, watch } from "vue-demi";
2
2
  import type { AutoCompletePlace, City } from "../types/interface";
3
+ import { MapLogProps, useMapLogVariable } from "./useMapLog";
3
4
  import { useMapSupplier } from "./useMapSupplier";
4
5
  import { useUpdate } from "./useUdate";
5
6
 
6
- export interface UseMapAutoCompleteProps {
7
+ export interface UseMapAutoCompleteProps extends MapLogProps {
7
8
  city: City;
8
9
  }
9
10
 
10
11
  export const useAmapAutoComplete = (props: UseMapAutoCompleteProps) => {
11
12
  const { city } = props;
12
13
  const cityRef = ref(city);
14
+ useMapLogVariable(props, "useAmapAutoComplete", cityRef, "cityRef");
13
15
  const { readyPromise } = useMapSupplier();
14
16
  const keywordRef = ref("");
15
17
  const autoCompletePlacesRef = ref<AutoCompletePlace[]>([]);
@@ -4,9 +4,21 @@ export interface MapLogProps {
4
4
  log?: boolean;
5
5
  }
6
6
 
7
- export const useMapLog = <P extends MapLogProps>(props: P, name: string) => {
7
+ export const useMapLog = <P extends MapLogProps>(props: P, prefix: string) => {
8
8
  watchEffect(() => {
9
9
  if (!props.log) return;
10
- console.log(`log ${name} props = `, { ...props });
10
+ console.log(`log ${prefix} props = `, { ...props });
11
+ });
12
+ };
13
+
14
+ export const useMapLogVariable = <P extends MapLogProps>(
15
+ props: P,
16
+ prefix: string,
17
+ variable: any,
18
+ name: string
19
+ ) => {
20
+ watchEffect(() => {
21
+ if (!props.log) return;
22
+ console.log(`log ${prefix} ${name} = `, { ...variable });
11
23
  });
12
24
  };
@@ -34,12 +34,14 @@ export const useAmapPlace = (props: UseMapPlaceProps) => {
34
34
  ? addressComponent.city
35
35
  : addressComponent.province;
36
36
  const countryName = addressComponent.country;
37
+ const cityParentName = addressComponent.province;
37
38
  place.name = name;
38
39
  place.lng = lng;
39
40
  place.lat = lat;
40
41
  place.cityName = cityName;
42
+ place.cityParentName = cityParentName;
41
43
  place.countryName = countryName;
42
- onChange?.({ lng, lat, name, cityName, countryName });
44
+ onChange?.({ lng, lat, name, cityName, cityParentName, countryName });
43
45
  return;
44
46
  }
45
47
 
@@ -70,13 +72,15 @@ export const useGmapPlace = (props: UseMapPlaceProps) => {
70
72
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
71
73
  const name = results[0].formatted_address;
72
74
  const cityName = geocoderResult2cityName(results[0]);
75
+ const cityParentName = results.slice(-2)[0].address_components[0].long_name;
73
76
  const countryName = results.slice(-1)[0].address_components[0].long_name;
74
77
  place.lng = lng;
75
78
  place.lat = lat;
76
79
  place.name = name;
77
80
  place.cityName = cityName;
81
+ place.cityParentName = cityParentName;
78
82
  place.countryName = countryName;
79
- onChange?.({ lng, lat, name, cityName, countryName });
83
+ onChange?.({ lng, lat, name, cityName, cityParentName, countryName });
80
84
  }
81
85
  );
82
86
  return { place, updatePlace };
@@ -1,8 +1,9 @@
1
1
  import type { Ref } from "vue-demi";
2
2
  import { useMapAutoComplete } from "../hooks/useMapAutoComplete";
3
3
  import { useMapBoundCity } from "../hooks/useMapCityBound";
4
+ import type { MapLogProps } from "../hooks/useMapLog";
4
5
 
5
- export interface UseBusinessMapAutoCompleteProps {
6
+ export interface UseBusinessMapAutoCompleteProps extends MapLogProps {
6
7
  cityNameRef: Ref<string>;
7
8
  }
8
9
 
@@ -12,7 +13,7 @@ export const useBusinessMapAutoComplete = (props: UseBusinessMapAutoCompleteProp
12
13
  cityNameRef,
13
14
  onChange: (v) => setCity(v),
14
15
  });
15
- const { autoCompletePlaces, setKeyword, setCity } = useMapAutoComplete({ city });
16
+ const { autoCompletePlaces, setKeyword, setCity } = useMapAutoComplete({ city, log: props.log });
16
17
  const handleKeywordInput = (e: Event) => {
17
18
  const target = e.target as HTMLInputElement;
18
19
  setKeyword(target.value);
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "./style.css";
2
+ export { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox";
2
3
  export { AddressBox } from "./business-components/AddressBox";
3
4
  export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
4
5
  export { BusinessRecomendPlaceMap } from "./business-components/BusinessRecomendPlaceMap";
@@ -7,6 +7,7 @@ export type Place = {
7
7
  lat: number;
8
8
  name: string;
9
9
  cityName?: string;
10
+ cityParentName?: string;
10
11
  countryName?: string;
11
12
  };
12
13
 
package/todo.md CHANGED
@@ -2,20 +2,14 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
2
2
 
3
3
  2. Google 地址名称太长
4
4
  3. 中心点 drag 期间位置
5
- 4. place 需要包含 autocomplete 查询需要的信息
6
- 5. 高德地图加载期间出现大量的请求
7
- 6. google/高德 坐标系转化
8
- 7. click 事件
5
+ 4. 高德地图加载期间出现大量的请求
6
+ 5. google/高德 坐标系转化
9
7
 
10
8
  ---
11
9
 
12
- 1. 需要计算用户与上车点的预估时间 导出
13
- 2. 全程时间与距离导出
14
10
  3. 司机接单页起点名称怎么显示 ?
15
11
  4. passenger 超过 10 公里 fitview 不考虑怎么设计
16
- 5. home 页面用户 出发点与终点小于 200 米,需要提示,需要导出接口
17
- 6. walkingRoute 显示报错
18
- 7. 需要一个手段让 fitview 初始化起作用
12
+ 5. 需要一个手段让 fitview 初始化起作用
19
13
 
20
14
  ---
21
15
 
@@ -27,3 +21,5 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
27
21
  ---
28
22
 
29
23
  1. 定位失败的视觉稿文字提示
24
+ 2. 用户手动输入地址,然后跳回 home 页面, centerplace 的 name 不正确
25
+ 3. 用户地址搜索,先设置台湾,搜个结果,然后切换城市到新加坡,搜索到结果依然是台湾