@heycar/heycars-map 0.2.9 → 0.2.11

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 (55) hide show
  1. package/dist/Demo/DemoBusinessTaxiEnd.d.ts +4 -1
  2. package/dist/Demo/DemoBusinessTaxiService.d.ts +2054 -1
  3. package/dist/api/contants.d.ts +2 -0
  4. package/dist/business-components/AddressBox/AddressBox.d.ts +2 -1
  5. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -1
  6. package/dist/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
  7. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +3 -2
  8. package/dist/business-components/DrivingLine/DrivingLine.d.ts +2 -1
  9. package/dist/business-components/DrivingRoute/DrivingRoute.d.ts +2 -1
  10. package/dist/business-components/PassengerCircle/PassengerCircle.d.ts +2 -1
  11. package/dist/business-components/PickupPoints/PickupPoints.d.ts +2 -1
  12. package/dist/business-components/PlaceCircle/PlaceCircle.d.ts +2 -1
  13. package/dist/business-components/StartEndPoint/StartEndPoint.d.ts +2 -1
  14. package/dist/business-components/TaxiCar/TaxiCar.d.ts +2 -1
  15. package/dist/business-components/WalkingLine/WalkingLine.d.ts +2 -1
  16. package/dist/business-components/WalkingRoute/WalkingRoute.d.ts +2 -1
  17. package/dist/business-components/WaveCircle/WaveCircle.d.ts +2 -1
  18. package/dist/components/MapProvider/MapProvider.d.ts +2 -1
  19. package/dist/hooks/useMapAutoComplete.d.ts +3 -3
  20. package/dist/hooks/useMapLog.d.ts +4 -0
  21. package/dist/hooks/useMapPlace.d.ts +3 -3
  22. package/dist/hooks/useMapRecomendPlace.d.ts +6 -6
  23. package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +1 -1
  24. package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +2 -2
  25. package/dist/hooks-business/useLagecyMapRecomendPlace.d.ts +2 -2
  26. package/dist/index.cjs +56 -56
  27. package/dist/index.js +1431 -1356
  28. package/dist/types/interface.d.ts +1 -1
  29. package/dist/utils/helper.d.ts +2 -0
  30. package/package.json +2 -2
  31. package/src/App.tsx +3 -3
  32. package/src/Demo/DemoBusinessRecomendPlace.tsx +42 -12
  33. package/src/Demo/DemoBusinessTaxiEnd.tsx +34 -9
  34. package/src/Demo/DemoBusinessTaxiService.tsx +53 -27
  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 +8 -3
  38. package/src/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.tsx +21 -11
  39. package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +109 -28
  40. package/src/business-components/DrivingLine/DrivingLine.tsx +4 -1
  41. package/src/business-components/DrivingRoute/DrivingRoute.tsx +4 -1
  42. package/src/business-components/PassengerCircle/PassengerCircle.tsx +4 -1
  43. package/src/business-components/PickupPoints/PickupPoints.tsx +3 -1
  44. package/src/business-components/PlaceCircle/PlaceCircle.tsx +4 -1
  45. package/src/business-components/StartEndPoint/StartEndPoint.tsx +9 -6
  46. package/src/business-components/TaxiCar/TaxiCar.tsx +4 -1
  47. package/src/business-components/WalkingLine/WalkingLine.tsx +4 -1
  48. package/src/business-components/WalkingRoute/WalkingRoute.tsx +4 -1
  49. package/src/business-components/WaveCircle/WaveCircle.tsx +4 -1
  50. package/src/components/MapProvider/MapProvider.tsx +4 -1
  51. package/src/hooks/useMapLog.ts +12 -0
  52. package/src/hooks/useMapPlace.ts +8 -3
  53. package/src/types/amap/geocoder.d.ts +2 -0
  54. package/src/types/interface.ts +1 -1
  55. package/src/utils/helper.ts +5 -0
@@ -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
  export interface AutoCompletePlace extends Place {
13
13
  placeId?: string;
@@ -0,0 +1,2 @@
1
+ import type { Place } from "../types/interface";
2
+ export declare const isPlace: (place: Partial<Place>) => place is Place;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
@@ -91,4 +91,4 @@
91
91
  "engines": {
92
92
  "node": ">=16.0.0"
93
93
  }
94
- }
94
+ }
package/src/App.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineComponent } from "vue-demi";
2
2
  import { MapProvider } from "./components/MapProvider";
3
- import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace";
3
+ import { DemoBusinessTaxiService } from "./Demo/DemoBusinessTaxiService";
4
4
 
5
5
  const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
6
6
  const gmapId = import.meta.env.VITE_GMAP_MAP_ID;
@@ -17,9 +17,9 @@ export const App = defineComponent({
17
17
  gmapKey={gmapApiKey}
18
18
  supplier={"amap"}
19
19
  >
20
- <DemoBusinessRecomendPlace />
20
+ {/* <DemoBusinessRecomendPlace /> */}
21
21
  {/* <DemoBusinessQuoting /> */}
22
- {/* <DemoBusinessTaxiService /> */}
22
+ <DemoBusinessTaxiService />
23
23
  {/* <DemoBusinessTaxiEnd /> */}
24
24
  </MapProvider>
25
25
  );
@@ -14,13 +14,19 @@ const SomeAutoComplete = defineSetup(function SomeAutoComplete(props: { cityName
14
14
  });
15
15
  (window as any).setCity = setCity;
16
16
  return () => {
17
- const list = autoCompletePlaces.value.map((place) => [
18
- <input onInput={handleKeywordInput} />,
17
+ const list = autoCompletePlaces.value.map((place) => (
19
18
  <div>
20
19
  {place.lng} | {place.lat} | {place.name} | {place.description}
21
- </div>,
22
- ]);
23
- return <div>{list}</div>;
20
+ </div>
21
+ ));
22
+ return (
23
+ <div>
24
+ <div>
25
+ <input onInput={handleKeywordInput} />
26
+ </div>
27
+ {list}
28
+ </div>
29
+ );
24
30
  };
25
31
  });
26
32
 
@@ -31,6 +37,33 @@ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecome
31
37
  ) => {
32
38
  const { lat, lng } = place;
33
39
  console.log("getRecomendPlace context?.source = ", context?.source);
40
+ return [
41
+ {
42
+ address: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
43
+ distance: 68,
44
+ lat: 1.2961134,
45
+ lng: 103.7722912,
46
+ name: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
47
+ reqFrom: "Recent",
48
+ },
49
+ {
50
+ address: "10 Architecture Drive, Singapore",
51
+ distance: 71,
52
+ lat: 1.2969847,
53
+ lng: 103.7714507,
54
+ name: "Centre for English Language Communication (CELC)",
55
+ reqFrom: "public",
56
+ },
57
+ {
58
+ address: "10 Kent Ridge Crescent, #01-02 Block AS8",
59
+ distance: 75,
60
+ lat: 1.295979,
61
+ lng: 103.7720608,
62
+ name: "The Coffee Roaster Cafe @ NUS",
63
+ reqFrom: "public",
64
+ },
65
+ ];
66
+
34
67
  return [
35
68
  { lat: lat + 0.0001, lng: lng + 0.0001, name: "place name 1" },
36
69
  { lat: lat + 0.002, lng: lng + 0.002, name: "place name 2" },
@@ -38,24 +71,21 @@ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecome
38
71
  };
39
72
  const { centerPlace, placeCandidates, setCenterPlaceByRecomand, mapContext, apiMapDistance } =
40
73
  useBusinessRecomendPlaceMap();
41
- setTimeout(() => {
42
- const distance = apiMapDistance([0, 0], [1, 1]);
43
- console.log("distance = ", distance);
44
- }, 2000);
45
74
  (window as any).setCenterPlaceByRecomand = setCenterPlaceByRecomand;
46
75
  return () => {
47
76
  return (
48
77
  <div>
49
78
  placeCandidates: {placeCandidates} <br />
50
79
  centerPlace: {centerPlace.lng} | {centerPlace.lat} | {centerPlace.name} |{" "}
51
- {centerPlace.cityName} <br />
52
- <SomeAutoComplete cityName="上海市"></SomeAutoComplete>
80
+ {centerPlace.cityName} | {centerPlace.countryName} <br />
81
+ <SomeAutoComplete cityName="Taiwan"></SomeAutoComplete>
53
82
  <BusinessRecomendPlaceMap
83
+ log
54
84
  class={css.demo}
55
85
  unavailableTitle={"当前区域暂未开通服务"}
56
86
  noRecomendDescription={"附近无推荐上车地点"}
57
87
  recomendDescription={"最佳上车地点"}
58
- geoDefaultPosition={[121, 31]}
88
+ geoDefaultPosition={[103.771994, 1.296648]}
59
89
  getRecomendPlace={getRecomendPlace}
60
90
  mapContext={mapContext}
61
91
  onGeoError={(e) => console.log("onGeoError e = ", e)}
@@ -1,13 +1,38 @@
1
+ import { defineComponent } from "vue";
1
2
  import { BusinessTaxiEndMap } from "../business-components/BusinessTaxiEndMap";
2
- import { defineSetup } from "../types/helper";
3
3
  import * as css from "./Demo.css";
4
4
 
5
- export const DemoBusinessTaxiEnd = defineSetup(function DemoBusinessTaxiEnd() {
6
- return () => (
7
- <BusinessTaxiEndMap
8
- class={css.demo}
9
- from={{ lng: 121.4, lat: 31.2, name: "from place name" }}
10
- to={{ lng: 121.5, lat: 31.4, name: "to place name" }}
11
- />
12
- );
5
+ export const DemoBusinessTaxiEnd = defineComponent({
6
+ name: "DemoBusinessTaxiEnd",
7
+ data() {
8
+ return {
9
+ from: {},
10
+ to: {},
11
+ };
12
+ },
13
+ created() {
14
+ setTimeout(() => {
15
+ this.from = {
16
+ lng: 103.7719939,
17
+ lat: 1.296648,
18
+ name: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
19
+ };
20
+ this.to = {
21
+ lng: 103.781421,
22
+ lat: 1.283855,
23
+ name: "虎豹别墅 (Haw Par Villa)",
24
+ };
25
+ }, 2000);
26
+ },
27
+ render() {
28
+ const { from, to } = this;
29
+ return (
30
+ <div>
31
+ <div>
32
+ {JSON.stringify(from)} | {JSON.stringify(to)}
33
+ </div>
34
+ <BusinessTaxiEndMap class={css.demo} from={from} to={to} log />
35
+ </div>
36
+ );
37
+ },
13
38
  });
@@ -1,32 +1,58 @@
1
+ import { defineComponent } from "vue";
1
2
  import { BusinessTaxiServiceMap } from "../business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap";
2
3
  import { useBusinessTaxiServiceMap } from "../hooks-business/useBusinessTaxiServiceMap";
3
- import { defineSetup } from "../types/helper";
4
- import type { Point } from "../types/interface";
4
+ import type { Place, Point } from "../types/interface";
5
+ import { isPlace } from "../utils/helper";
5
6
  import * as css from "./Demo.css";
6
7
 
7
- export const DemoBusinessTaxiService = defineSetup(function DemoBusinessTaxiService() {
8
- const { setMap, registerFitVeiw } = useBusinessTaxiServiceMap();
9
- const getDriverPosition = () => Promise.resolve([121.42, 31.25] as Point);
10
- return () => (
11
- <BusinessTaxiServiceMap
12
- class={css.demo}
13
- from={{ lng: 121.4, lat: 31.2, name: "from place name" }}
14
- to={{ lng: 121.5, lat: 31.4, name: "to place name" }}
15
- driverStatus="completed"
16
- bookDispatchingTitle="2月14日 11:00 用车"
17
- bookDispatchedTitle="司机位置将在临近出发时间展示"
18
- dispatchingTitle="正在为您搜索附近司机"
19
- driverArrivedTitle="司机已等待 00:35"
20
- renderStartSerivceTitle={({ distance, duration }) =>
21
- `距你*${distance}*公里, *${duration}*分钟`
22
- }
23
- renderInServiceTitle={({ distance, duration }) =>
24
- `距离终点${distance}公里, 预计${duration}分钟`
25
- }
26
- getDriverPosition={getDriverPosition}
27
- interval={5000}
28
- mapRef={setMap}
29
- registerOverlay={registerFitVeiw}
30
- />
31
- );
8
+ export const DemoBusinessTaxiService = defineComponent({
9
+ setup() {
10
+ const { setMap, registerFitVeiw } = useBusinessTaxiServiceMap();
11
+ return { setMap, registerFitVeiw };
12
+ },
13
+ data() {
14
+ return {
15
+ from: {} as Partial<Place>,
16
+ to: {} as Partial<Place>,
17
+ };
18
+ },
19
+ created() {
20
+ setTimeout(() => {
21
+ this.from = { lng: 121.4, lat: 31.2, name: "from place name" };
22
+ this.to = { lng: 121.5, lat: 31.4, name: "to place name" };
23
+ }, 1000);
24
+ },
25
+ methods: {
26
+ getDriverPosition() {
27
+ return Promise.resolve([121.42, 31.25] as Point);
28
+ },
29
+ },
30
+ render() {
31
+ const { setMap, getDriverPosition, registerFitVeiw, from, to } = this;
32
+ const isReady = isPlace(from) && isPlace(to);
33
+ if (!isReady) return null;
34
+ return (
35
+ <BusinessTaxiServiceMap
36
+ class={css.demo}
37
+ from={from}
38
+ to={to}
39
+ driverStatus="completed"
40
+ bookDispatchingTitle="2月14日 11:00 用车"
41
+ bookDispatchedTitle="司机位置将在临近出发时间展示"
42
+ dispatchingTitle="正在为您搜索附近司机"
43
+ driverArrivedTitle="司机已等待 00:35"
44
+ renderStartSerivceTitle={({ distance, duration }) =>
45
+ `距你*${distance}*公里, *${duration}*分钟`
46
+ }
47
+ renderInServiceTitle={({ distance, duration }) =>
48
+ `距离终点${distance}公里, 预计${duration}分钟`
49
+ }
50
+ getDriverPosition={getDriverPosition}
51
+ interval={5000}
52
+ mapRef={setMap}
53
+ registerOverlay={registerFitVeiw}
54
+ log
55
+ />
56
+ );
57
+ },
32
58
  });
@@ -0,0 +1,3 @@
1
+ import type { Point } from "../types/interface";
2
+
3
+ export const BEIJIN_POINT: Point = [116.2317, 39.5427];
@@ -3,6 +3,7 @@ import imgArrowRight from "../../assets/icons/svg/arrow-right.svg";
3
3
  import imgPlaceCircle from "../../assets/icons/svg/place-circle.svg";
4
4
  import { AmapMarker } from "../../components/AmapMarker";
5
5
  import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView/GmapAdvancedMarkerView";
6
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
6
7
  import { useMapSupplier } from "../../hooks/useMapSupplier";
7
8
  import { createElement, defineSetup } from "../../types/helper";
8
9
  import type { Point } from "../../types/interface";
@@ -11,13 +12,14 @@ import { vec2lnglat } from "../../utils/transform";
11
12
  import { AAddressLocator, GAddressLocator } from "../AddressLocator";
12
13
  import * as css from "./AddressBox.css";
13
14
 
14
- export interface AddressBoxProps {
15
+ export interface AddressBoxProps extends MapLogProps {
15
16
  type: "box" | "locator";
16
17
  position: Point;
17
18
  title: string;
18
19
  description?: string;
19
20
  }
20
21
  export const AAddressBox = defineSetup(function AAddressBox(props: AddressBoxProps) {
22
+ useMapLog(props, "AAddressBox");
21
23
  const contentRef = computed(
22
24
  () => `
23
25
  <div class="${css.addressBoxLayout}">
@@ -42,6 +44,7 @@ export const AAddressBox = defineSetup(function AAddressBox(props: AddressBoxPro
42
44
  });
43
45
 
44
46
  export const GAddressBox = defineSetup(function GAddressBox(props: AddressBoxProps) {
47
+ useMapLog(props, "GAddressBox");
45
48
  const contentRef = computed(() =>
46
49
  createDom(
47
50
  "div",
@@ -4,6 +4,7 @@ import type { BusinessRecomendPlaceContext } from "../../hooks-business/useBusin
4
4
  import { useGeoLocation, UseGeoLocationProps } from "../../hooks/useGeoLocation";
5
5
  import { useHeycarMap } from "../../hooks/useHeycarMap";
6
6
  import { useMapDrag, UseMapDragProps } from "../../hooks/useMapDrag";
7
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
7
8
  import type { UseMapPlaceProps } from "../../hooks/useMapPlace";
8
9
  import { useMapRecomendPlace, UseMapRecomendPlaceProps } from "../../hooks/useMapRecomendPlace";
9
10
  import { useMapSupplier } from "../../hooks/useMapSupplier";
@@ -20,7 +21,8 @@ export interface CenterPlaceSource {
20
21
  }
21
22
  export interface BusinessRecomendPlaceMapProps
22
23
  extends Omit<HeycarMapProps, "center" | "zoom" | "mapRef">,
23
- Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace"> {
24
+ Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace">,
25
+ MapLogProps {
24
26
  unavailableTitle: string;
25
27
  recomendDescription: string;
26
28
  noRecomendDescription: string;
@@ -36,6 +38,7 @@ export interface BusinessRecomendPlaceMapProps
36
38
  }
37
39
  export const BusinessRecomendPlaceMap = defineLagecySetup(
38
40
  (props: BusinessRecomendPlaceMapProps, { emit }) => {
41
+ useMapLog(props, "BusinessRecomendPlaceMap");
39
42
  const { geoDefaultPosition, getRecomendPlace, mapContext } = props;
40
43
  const { mapRef, setMap, panTo } = useHeycarMap();
41
44
  const { readyPromise } = useMapSupplier();
@@ -141,20 +144,22 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
141
144
  ? props.recomendDescription
142
145
  : props.noRecomendDescription;
143
146
  return (
144
- <HeycarMap center={centerPoint.value} zoom={18} mapRef={setMap}>
147
+ <HeycarMap center={centerPoint.value} zoom={18} mapRef={setMap} log={props.log}>
145
148
  <PassengerCircle position={geoPosition.value} />
146
- <PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} />
149
+ <PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} log={props.log} />
147
150
  <AddressBox
148
151
  position={centerPoint.value}
149
152
  title={availableRef.value ? centerPlace.name : props.unavailableTitle}
150
153
  description={description}
151
154
  type={isDragging.value ? "locator" : "box"}
155
+ log={props.log}
152
156
  />
153
157
  </HeycarMap>
154
158
  );
155
159
  };
156
160
  }
157
161
  ).props([
162
+ "log",
158
163
  "unavailableTitle",
159
164
  "recomendDescription",
160
165
  "noRecomendDescription",
@@ -1,16 +1,20 @@
1
+ import { BEIJIN_POINT } from "../../api/contants";
1
2
  import { HeycarMap } from "../../components/MapProvider";
2
3
  import { useHeycarMap } from "../../hooks/useHeycarMap";
3
4
  import { useMapFitView } from "../../hooks/useMapFitView";
5
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
4
6
  import { defineSetup } from "../../types/helper";
5
- import type { Place } from "../../types/interface";
7
+ import type { Place, Point } from "../../types/interface";
8
+ import { isPlace } from "../../utils/helper";
6
9
  import { place2point } from "../../utils/transform";
7
10
  import { SectionEndService } from "../BusinessTaxiServiceMap";
8
11
 
9
- export interface BusinessTaxiEndMapProps {
10
- from: Place;
11
- to: Place;
12
+ export interface BusinessTaxiEndMapProps extends MapLogProps {
13
+ from: Partial<Place>;
14
+ to: Partial<Place>;
12
15
  }
13
16
  export const BusinessTaxiEndMap = defineSetup((props: BusinessTaxiEndMapProps) => {
17
+ useMapLog(props, "BusinessTaxiEndMap");
14
18
  const { mapRef, setMap } = useHeycarMap();
15
19
  const { registerFitVeiw, setFitView } = useMapFitView({
16
20
  mapRef,
@@ -19,14 +23,20 @@ export const BusinessTaxiEndMap = defineSetup((props: BusinessTaxiEndMapProps) =
19
23
  });
20
24
  return () => {
21
25
  const { from, to } = props;
26
+ const isReady = isPlace(from) && isPlace(to);
27
+ const center = isReady ? place2point(from) : ([...BEIJIN_POINT] as Point);
28
+ const zoom = isReady ? 13 : 3;
22
29
  return (
23
- <HeycarMap center={place2point(from)} zoom={13} mapRef={setMap}>
24
- <SectionEndService
25
- from={from}
26
- to={to}
27
- registerOverlay={registerFitVeiw}
28
- onMapMounted={setFitView}
29
- />
30
+ <HeycarMap center={center} zoom={zoom} mapRef={setMap} log={props.log}>
31
+ {isReady && (
32
+ <SectionEndService
33
+ from={from}
34
+ to={to}
35
+ registerOverlay={registerFitVeiw}
36
+ onMapMounted={setFitView}
37
+ log={props.log}
38
+ />
39
+ )}
30
40
  </HeycarMap>
31
41
  );
32
42
  };