@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
@@ -2,16 +2,18 @@ import { computed } from "vue-demi";
2
2
  import imgWaveCircle from "../../assets/icons/svg/wave-circle.svg";
3
3
  import { AmapMarker } from "../../components/AmapMarker";
4
4
  import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView";
5
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
5
6
  import { useMapSupplier } from "../../hooks/useMapSupplier";
6
7
  import { createElement, defineSetup } from "../../types/helper";
7
8
  import { createDom } from "../../utils/dom";
8
9
  import { vec2lnglat } from "../../utils/transform";
9
10
  import * as css from "./WaveCircle.css";
10
11
 
11
- export interface WaveCircleProps {
12
+ export interface WaveCircleProps extends MapLogProps {
12
13
  position: [number, number];
13
14
  }
14
15
  export const AWaveCircle = defineSetup(function AWaveCircle(props: WaveCircleProps) {
16
+ useMapLog(props, "AWaveCircle");
15
17
  const contentRef = computed(() => `<img src="${imgWaveCircle}" class="${css.waveCircle}">`);
16
18
  const contentAnotherRef = computed(
17
19
  () => `<img src="${imgWaveCircle}" class="${css.waveCircle} ${css.secondCircle}">`
@@ -29,6 +31,7 @@ export const AWaveCircle = defineSetup(function AWaveCircle(props: WaveCirclePro
29
31
  });
30
32
 
31
33
  export const GWaveCircle = defineSetup(function AWaveCircle(props: WaveCircleProps) {
34
+ useMapLog(props, "GWaveCircle");
32
35
  const contentRef = computed(() =>
33
36
  createDom("img", { class: css.waveCircle, src: imgWaveCircle })
34
37
  );
@@ -1,5 +1,6 @@
1
1
  import type { SetMap } from "../../hooks/useHeycarMap";
2
2
  import { GmapLoaderProps, Status, useMapLoader, UseMapLoaderProps } from "../../hooks/useMapLoader";
3
+ import { MapLogProps, useMapLog } from "../../hooks/useMapLog";
3
4
  import { MapSupplierPayolad, provideMapSupplier, useMapSupplier } from "../../hooks/useMapSupplier";
4
5
  import { defineLagecySetup } from "../../types/helper";
5
6
  import { language2vectorMapForeign, vec2lnglat } from "../../utils/transform";
@@ -25,7 +26,8 @@ export const MapProvider = defineLagecySetup(function MapProvider(
25
26
 
26
27
  export interface HeycarMapProps
27
28
  extends Pick<GmapLoaderProps, "fallback" | "loading">,
28
- Pick<AmapProps, "center" | "zoom"> {
29
+ Pick<AmapProps, "center" | "zoom">,
30
+ MapLogProps {
29
31
  mapRef?: SetMap<AMap.Map> | SetMap<google.maps.Map>;
30
32
  onDragEnd?: (value: [number, number]) => any;
31
33
  }
@@ -33,6 +35,7 @@ export const HeycarMap = defineLagecySetup(function HeycarMap(
33
35
  props: HeycarMapProps,
34
36
  { slots, emit }
35
37
  ) {
38
+ useMapLog(props, "HeycarMap");
36
39
  const payload = useMapSupplier();
37
40
  const gmapDebouncedEmit: GmapProps["onDragEnd"] = ({ target }) => {
38
41
  const { lng, lat } = target.getCenter() as google.maps.LatLng;
@@ -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 };
@@ -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
+ };