@heycar/heycars-map 0.3.7 → 0.3.9

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 (176) hide show
  1. package/dist/Demo/DemoBusinessRecomendPlace.d.ts +9 -0
  2. package/dist/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +1 -2
  3. package/dist/business-components/AddressBox/AddressBox.d.ts +1 -2
  4. package/dist/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +2 -0
  5. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -2
  6. package/dist/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +1 -2
  7. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +2 -8
  8. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.d.ts +46 -0
  9. package/dist/business-components/DrivingLine/DrivingLine.d.ts +1 -2
  10. package/dist/business-components/DrivingRoute/DrivingRoute.d.ts +1 -2
  11. package/dist/business-components/PassengerCircle/PassengerCircle.d.ts +1 -2
  12. package/dist/business-components/PickupPoints/PickupPoints.d.ts +1 -2
  13. package/dist/business-components/PlaceCircle/PlaceCircle.d.ts +1 -2
  14. package/dist/business-components/StartEndPoint/StartEndPoint.d.ts +1 -2
  15. package/dist/business-components/TaxiCar/TaxiCar.d.ts +1 -2
  16. package/dist/business-components/WalkingLine/WalkingLine.d.ts +1 -2
  17. package/dist/business-components/WalkingRoute/WalkingRoute.d.ts +1 -2
  18. package/dist/business-components/WaveCircle/WaveCircle.d.ts +1 -2
  19. package/dist/components/Gmap/Gmap.d.ts +0 -2
  20. package/dist/components/MapProvider/MapProvider.d.ts +1 -4
  21. package/dist/hooks/useMapAutoComplete.d.ts +1 -2
  22. package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +1 -2
  23. package/dist/index.cjs +54 -54
  24. package/dist/index.js +1867 -1959
  25. package/package.json +2 -3
  26. package/todo.md +27 -4
  27. package/dist/Demo/CityBound/SearchDemo.d.ts +0 -1
  28. package/dist/Demo/CityBound/country.d.ts +0 -5
  29. package/dist/Demo/CityBound/searchResult.d.ts +0 -8
  30. package/dist/hooks/useMapLog.d.ts +0 -5
  31. package/src/App.tsx +0 -27
  32. package/src/Demo/CityBound/SearchDemo.tsx +0 -142
  33. package/src/Demo/CityBound/country.ts +0 -4179
  34. package/src/Demo/CityBound/searchResult.ts +0 -21122
  35. package/src/Demo/Demo.css.ts +0 -6
  36. package/src/Demo/Demo.tsx +0 -97
  37. package/src/Demo/DemoBusinessQuoting.tsx +0 -18
  38. package/src/Demo/DemoBusinessRecomendPlace.tsx +0 -89
  39. package/src/Demo/DemoBusinessTaxiEnd.tsx +0 -38
  40. package/src/Demo/DemoBusinessTaxiService.tsx +0 -58
  41. package/src/Demo/sample.json +0 -793
  42. package/src/api/contants.ts +0 -3
  43. package/src/api/driving.ts +0 -87
  44. package/src/api/geocoder.ts +0 -88
  45. package/src/api/geometry.ts +0 -44
  46. package/src/api/place.ts +0 -105
  47. package/src/assets/icons/svg/address-locator.svg +0 -1
  48. package/src/assets/icons/svg/arrow-right.svg +0 -1
  49. package/src/assets/icons/svg/end-point.svg +0 -1
  50. package/src/assets/icons/svg/passenger-circle.svg +0 -1
  51. package/src/assets/icons/svg/place-circle.svg +0 -22
  52. package/src/assets/icons/svg/start-point.svg +0 -1
  53. package/src/assets/icons/svg/taxi-car.svg +0 -1
  54. package/src/assets/icons/svg/wave-circle.svg +0 -1
  55. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.ts +0 -68
  56. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.tsx +0 -50
  57. package/src/business-components/AbsoluteAddressBox/index.ts +0 -1
  58. package/src/business-components/AddressBox/AddressBox.css.ts +0 -55
  59. package/src/business-components/AddressBox/AddressBox.tsx +0 -76
  60. package/src/business-components/AddressBox/index.ts +0 -1
  61. package/src/business-components/AddressLocator/AddressLocator.css.ts +0 -7
  62. package/src/business-components/AddressLocator/AddressLocator.tsx +0 -40
  63. package/src/business-components/AddressLocator/index.ts +0 -1
  64. package/src/business-components/BusinessQuotingMap/BusinessQuotingMap.tsx +0 -49
  65. package/src/business-components/BusinessQuotingMap/index.ts +0 -1
  66. package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +0 -218
  67. package/src/business-components/BusinessRecomendPlaceMap/index.ts +0 -1
  68. package/src/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.tsx +0 -43
  69. package/src/business-components/BusinessTaxiEndMap/index.ts +0 -1
  70. package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +0 -453
  71. package/src/business-components/BusinessTaxiServiceMap/index.ts +0 -1
  72. package/src/business-components/DrivingLine/DrivingLine.css.ts +0 -10
  73. package/src/business-components/DrivingLine/DrivingLine.tsx +0 -135
  74. package/src/business-components/DrivingLine/index.ts +0 -1
  75. package/src/business-components/DrivingRoute/DrivingRoute.tsx +0 -52
  76. package/src/business-components/DrivingRoute/index.ts +0 -1
  77. package/src/business-components/FitView/FitView.tsx +0 -22
  78. package/src/business-components/FitView/index.ts +0 -1
  79. package/src/business-components/PassengerCircle/PassengerCircle.css.ts +0 -21
  80. package/src/business-components/PassengerCircle/PassengerCircle.tsx +0 -69
  81. package/src/business-components/PassengerCircle/index.ts +0 -1
  82. package/src/business-components/PickupPoints/PickupPoints.tsx +0 -38
  83. package/src/business-components/PickupPoints/index.ts +0 -1
  84. package/src/business-components/PlaceCircle/PlaceCircle.css.ts +0 -76
  85. package/src/business-components/PlaceCircle/PlaceCircle.tsx +0 -110
  86. package/src/business-components/PlaceCircle/index.ts +0 -1
  87. package/src/business-components/StartEndPoint/StartEndPoint.css.ts +0 -70
  88. package/src/business-components/StartEndPoint/StartEndPoint.tsx +0 -122
  89. package/src/business-components/StartEndPoint/index.ts +0 -1
  90. package/src/business-components/TaxiCar/TaxiCar.css.ts +0 -16
  91. package/src/business-components/TaxiCar/TaxiCar.tsx +0 -93
  92. package/src/business-components/TaxiCar/index.ts +0 -1
  93. package/src/business-components/WalkingLine/WalkingLine.tsx +0 -80
  94. package/src/business-components/WalkingLine/index.ts +0 -1
  95. package/src/business-components/WalkingRoute/WalkingRoute.tsx +0 -43
  96. package/src/business-components/WalkingRoute/index.ts +0 -1
  97. package/src/business-components/WaveCircle/WaveCircle.css.ts +0 -54
  98. package/src/business-components/WaveCircle/WaveCircle.tsx +0 -59
  99. package/src/business-components/WaveCircle/index.ts +0 -1
  100. package/src/components/Amap/Amap.css.ts +0 -5
  101. package/src/components/Amap/Amap.ts +0 -76
  102. package/src/components/Amap/index.ts +0 -1
  103. package/src/components/AmapInfoWindow/AmapInfoWindow.ts +0 -45
  104. package/src/components/AmapInfoWindow/index.ts +0 -1
  105. package/src/components/AmapLoader/AmapLoader.ts +0 -20
  106. package/src/components/AmapLoader/index.ts +0 -1
  107. package/src/components/AmapMarker/AmapMarker.ts +0 -48
  108. package/src/components/AmapMarker/index.ts +0 -1
  109. package/src/components/AmapPolygon/AmapPolygon.ts +0 -41
  110. package/src/components/AmapPolygon/index.ts +0 -1
  111. package/src/components/AmapPolyline/AmapPolyline.ts +0 -40
  112. package/src/components/AmapPolyline/index.ts +0 -1
  113. package/src/components/AmapText/AmapText.ts +0 -39
  114. package/src/components/AmapText/index.ts +0 -1
  115. package/src/components/Gmap/Gmap.css.ts +0 -10
  116. package/src/components/Gmap/Gmap.ts +0 -54
  117. package/src/components/Gmap/index.ts +0 -1
  118. package/src/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.ts +0 -63
  119. package/src/components/GmapAdvancedMarkerView/index.ts +0 -1
  120. package/src/components/GmapInfoWindow/GmapInfoWindow.ts +0 -38
  121. package/src/components/GmapInfoWindow/index.ts +0 -1
  122. package/src/components/GmapLoader/GmapLoader.ts +0 -21
  123. package/src/components/GmapLoader/index.ts +0 -1
  124. package/src/components/GmapMarker/GmapMarker.ts +0 -34
  125. package/src/components/GmapMarker/index.ts +0 -1
  126. package/src/components/GmapPolygon/GmapPolygon.ts +0 -29
  127. package/src/components/GmapPolygon/index.ts +0 -1
  128. package/src/components/GmapPolyline/GmapPolyline.ts +0 -29
  129. package/src/components/GmapPolyline/index.ts +0 -1
  130. package/src/components/MapProvider/MapProvider.tsx +0 -83
  131. package/src/components/MapProvider/index.ts +0 -1
  132. package/src/hooks/useDrivingRoute.ts +0 -106
  133. package/src/hooks/useGeoLocation.ts +0 -70
  134. package/src/hooks/useHeycarMap.ts +0 -28
  135. package/src/hooks/useMap.ts +0 -43
  136. package/src/hooks/useMapAngle.ts +0 -42
  137. package/src/hooks/useMapAutoComplete.ts +0 -130
  138. package/src/hooks/useMapCityBound.ts +0 -64
  139. package/src/hooks/useMapDrag.ts +0 -72
  140. package/src/hooks/useMapEventSource.ts +0 -20
  141. package/src/hooks/useMapFitView.ts +0 -135
  142. package/src/hooks/useMapGeometry.ts +0 -27
  143. package/src/hooks/useMapLngLatToVw.ts +0 -31
  144. package/src/hooks/useMapLoader.ts +0 -164
  145. package/src/hooks/useMapLog.ts +0 -24
  146. package/src/hooks/useMapPlace.ts +0 -138
  147. package/src/hooks/useMapRecomendPlace.ts +0 -150
  148. package/src/hooks/useMapSupplier.ts +0 -16
  149. package/src/hooks/useOverlay.ts +0 -23
  150. package/src/hooks/usePlacesLabelDirection.ts +0 -61
  151. package/src/hooks/useUdate.ts +0 -9
  152. package/src/hooks/useWaitTimer.ts +0 -25
  153. package/src/hooks/useWalkingRoute.ts +0 -87
  154. package/src/hooks-business/useBusinessMapAutoComplete.ts +0 -22
  155. package/src/hooks-business/useBusinessQuotingMap.ts +0 -11
  156. package/src/hooks-business/useBusinessRecomendPlaceMap.ts +0 -45
  157. package/src/hooks-business/useBusinessTaxiServiceMap.ts +0 -12
  158. package/src/index.ts +0 -33
  159. package/src/main.ts +0 -6
  160. package/src/style.css +0 -0
  161. package/src/types/amap/autocomplete.d.ts +0 -64
  162. package/src/types/amap/driving.d.ts +0 -170
  163. package/src/types/amap/geocoder.d.ts +0 -217
  164. package/src/types/amap/marker.ts +0 -11
  165. package/src/types/amap/place.d.ts +0 -114
  166. package/src/types/amap/plugin.d.ts +0 -27
  167. package/src/types/amap/walking.d.ts +0 -78
  168. package/src/types/global.d.ts +0 -10
  169. package/src/types/helper.ts +0 -172
  170. package/src/types/interface.ts +0 -62
  171. package/src/types/mapHelper.ts +0 -1
  172. package/src/utils/compare.ts +0 -189
  173. package/src/utils/dom.ts +0 -14
  174. package/src/utils/helper.ts +0 -5
  175. package/src/utils/transform.ts +0 -68
  176. package/src/vite-env.d.ts +0 -12
@@ -1,138 +0,0 @@
1
- import { reactive, ref, Ref, watch } from "vue-demi";
2
- import { LANGUAGE } from "../types/helper";
3
- import type { Place, Point } from "../types/interface";
4
- import { geocoderResult2cityName } from "../utils/transform";
5
- import { useMapSupplier } from "./useMapSupplier";
6
- import { useUpdate } from "./useUdate";
7
-
8
- export interface UseMapPlaceOnChangeCityProps {
9
- cityName?: string;
10
- cityParentName?: string;
11
- countryName?: string;
12
- }
13
- export interface UseMapPlaceProps {
14
- pointRef: Ref<Point>;
15
- onChange?: (value: Place) => any;
16
- onChangeCity?: (value: UseMapPlaceOnChangeCityProps) => any;
17
- }
18
- export const useAmapPlace = (props: UseMapPlaceProps) => {
19
- const { onChange, onChangeCity } = props;
20
- const defaultPoint: Point = [...props.pointRef.value];
21
- const pointRef = ref<Point>(defaultPoint);
22
- const { readyPromise } = useMapSupplier();
23
- const place = reactive<Place>({
24
- lng: pointRef.value[0],
25
- lat: pointRef.value[1],
26
- name: "",
27
- });
28
- const { idx: placeKey, update } = useUpdate();
29
- const updateCity = (value: Place) => {
30
- const geocoder = new AMap.Geocoder({ lang: LANGUAGE });
31
- const { lng, lat } = value;
32
- geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
33
- if (status !== "complete") return;
34
- const { addressComponent } = (result as AMap.ReGeocoderResult).regeocode;
35
- const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
36
- const cityParentName = addressComponent.province;
37
- onChangeCity?.({ cityName, cityParentName, countryName: "" });
38
- });
39
- };
40
- const updatePlace = (value: Point) => {
41
- pointRef.value = value;
42
- update();
43
- };
44
- const setPlace = (value: Place) => {
45
- place.lng = value.lng;
46
- place.lat = value.lat;
47
- place.name = value.name;
48
- };
49
- watch(
50
- () => placeKey.value,
51
- async () => {
52
- await readyPromise;
53
- const geocoder = new AMap.Geocoder({ lang: LANGUAGE });
54
- const [lng, lat] = pointRef.value;
55
- geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
56
- switch (status) {
57
- case "complete": {
58
- const { formattedAddress: name, addressComponent } = (result as AMap.ReGeocoderResult)
59
- .regeocode;
60
- const cityName = addressComponent.city
61
- ? addressComponent.city
62
- : addressComponent.province;
63
- const cityParentName = addressComponent.province;
64
- place.name = name;
65
- place.lng = lng;
66
- place.lat = lat;
67
- onChange?.({ lng, lat, name });
68
- onChangeCity?.({ cityName, cityParentName, countryName: "" });
69
- return;
70
- }
71
-
72
- case "no_data":
73
- place.name = "";
74
- onChange?.({ lng, lat, name: "" });
75
- return;
76
- case "error":
77
- throw result;
78
- }
79
- });
80
- }
81
- );
82
- return { place, updatePlace, setPlace, updateCity };
83
- };
84
-
85
- export const useGmapPlace = (props: UseMapPlaceProps) => {
86
- const { onChange, onChangeCity } = props;
87
- const defaultPoint: Point = [...props.pointRef.value];
88
- const pointRef = ref<Point>(defaultPoint);
89
- const { readyPromise } = useMapSupplier();
90
- const { idx: placeKey, update } = useUpdate();
91
- const place = reactive<Place>({
92
- lng: pointRef.value[0],
93
- lat: pointRef.value[1],
94
- name: "",
95
- });
96
- const updatePlace = (value: Point) => {
97
- pointRef.value = value;
98
- update();
99
- };
100
- const setPlace = (value: Place) => {
101
- place.lng = value.lng;
102
- place.lat = value.lat;
103
- place.name = value.name;
104
- };
105
- const updateCity = async (value: Place) => {
106
- const geocoder = new google.maps.Geocoder();
107
- const { lng, lat } = value;
108
- const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
109
- const cityName = geocoderResult2cityName(results[0]);
110
- const cityParentName = results.slice(-2)[0].address_components[0].long_name;
111
- const countryName = results.slice(-1)[0].address_components[0].long_name;
112
- onChangeCity?.({ cityName, cityParentName, countryName });
113
- };
114
- watch(
115
- () => placeKey.value,
116
- async () => {
117
- await readyPromise;
118
- const geocoder = new google.maps.Geocoder();
119
- const [lng, lat] = pointRef.value;
120
- const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
121
- const name = results[0].formatted_address;
122
- const cityName = geocoderResult2cityName(results[0]);
123
- const cityParentName = results.slice(-2)[0].address_components[0].long_name;
124
- const countryName = results.slice(-1)[0].address_components[0].long_name;
125
- place.lng = lng;
126
- place.lat = lat;
127
- place.name = name;
128
- onChange?.({ lng, lat, name });
129
- onChangeCity?.({ cityName, cityParentName, countryName });
130
- }
131
- );
132
- return { place, updatePlace, setPlace, updateCity };
133
- };
134
-
135
- export const useMapPlace = (props: UseMapPlaceProps) => {
136
- const { supplier } = useMapSupplier();
137
- return supplier === "gmap" ? useGmapPlace(props) : useAmapPlace(props);
138
- };
@@ -1,150 +0,0 @@
1
- import { computed, reactive, ref, Ref, watch } from "vue-demi";
2
- import type { Place, Point } from "../types/interface";
3
-
4
- import { isPointEqual, place2point } from "../utils/transform";
5
- import { useAmapPlace, useGmapPlace, UseMapPlaceProps } from "./useMapPlace";
6
- import { useMapSupplier } from "./useMapSupplier";
7
- import { useUpdate } from "./useUdate";
8
-
9
- const findAmapNearestPlace = (place: Place, candidates: Place[]) => {
10
- let shortestDistance = Infinity;
11
- let shortestPlace = place;
12
- for (const candidate of candidates) {
13
- const distance = AMap.GeometryUtil.distance(place2point(place), place2point(candidate));
14
- if (distance >= shortestDistance) continue;
15
- shortestPlace = candidate;
16
- shortestDistance = distance;
17
- }
18
- return { shortestPlace, shortestDistance };
19
- };
20
-
21
- const findGmapNearestPlace = (place: Place, candidates: Place[]) => {
22
- let shortestDistance = Infinity;
23
- let shortestPlace = place;
24
- for (const candidate of candidates) {
25
- const distance = google.maps.geometry.spherical.computeDistanceBetween(place, candidate);
26
- if (distance >= shortestDistance) continue;
27
- shortestPlace = candidate;
28
- shortestDistance = distance;
29
- }
30
- return { shortestPlace, shortestDistance };
31
- };
32
-
33
- export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
34
- pointRef: Ref<Point>;
35
- context?: C;
36
- getLimit: (context?: C) => number;
37
- // 如果返回 undefined, 表示当前位置无服务可提供
38
- getRecomendPlace: (place: Place, context?: C) => Promise<Place[] | undefined>;
39
- onChangeCity?: UseMapPlaceProps["onChangeCity"];
40
- onChangePlace?: UseMapPlaceProps["onChange"];
41
- onChange?: (place: Place) => any;
42
- }
43
- export const useAmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
44
- const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace, onChangeCity } =
45
- props;
46
- const availableRef = ref(true);
47
- const placeCandidatesRef = ref<Place[]>([]);
48
- const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
49
- const { readyPromise } = useMapSupplier();
50
- const { place, updatePlace, setPlace, updateCity } = useAmapPlace({
51
- pointRef,
52
- onChange: onChangePlace,
53
- onChangeCity,
54
- });
55
- const recomendPlace = reactive<Place>({ ...place });
56
- const isElectedRef = computed(() => {
57
- const point = pointRef.value;
58
- return placeCandidatesRef.value.some((candidate) =>
59
- isPointEqual(place2point(candidate), point)
60
- );
61
- });
62
- watch(
63
- () => recomendPlaceKey.value,
64
- async () => {
65
- await readyPromise;
66
- const placeCandidates = await getRecomendPlace({ ...place }, context);
67
- if (placeCandidates === undefined) {
68
- availableRef.value = false;
69
- placeCandidatesRef.value = [];
70
- Object.assign(recomendPlace, { ...place });
71
- onChange?.({ ...place });
72
- return;
73
- }
74
- const { shortestPlace, shortestDistance } = findAmapNearestPlace(place, placeCandidates);
75
- const limit = getLimit(context);
76
- const resultPlace = shortestDistance > limit ? place : shortestPlace;
77
- availableRef.value = true;
78
- placeCandidatesRef.value = placeCandidates;
79
- Object.assign(recomendPlace, { ...resultPlace });
80
- onChange?.({ ...resultPlace });
81
- }
82
- );
83
- return {
84
- recomendPlace,
85
- placeCandidates: placeCandidatesRef,
86
- availableRef,
87
- isElectedRef,
88
- updateRecomandPlace,
89
- updatePlace,
90
- setPlace,
91
- updateCity,
92
- };
93
- };
94
-
95
- export const useGmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
96
- const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace, onChangeCity } =
97
- props;
98
- const availableRef = ref(true);
99
- const placeCandidatesRef = ref<Place[]>([]);
100
- const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
101
- const { readyPromise } = useMapSupplier();
102
- const { place, updatePlace, setPlace, updateCity } = useGmapPlace({
103
- pointRef,
104
- onChange: onChangePlace,
105
- onChangeCity,
106
- });
107
- const recomendPlace = reactive<Place>({ ...place });
108
- const isElectedRef = computed(() => {
109
- const point = pointRef.value;
110
- return placeCandidatesRef.value.some((candidate) =>
111
- isPointEqual(place2point(candidate), point)
112
- );
113
- });
114
- watch(
115
- () => recomendPlaceKey.value,
116
- async () => {
117
- await readyPromise;
118
- const placeCandidates = await getRecomendPlace({ ...place }, context);
119
- if (placeCandidates === undefined) {
120
- availableRef.value = false;
121
- placeCandidatesRef.value = [];
122
- Object.assign(recomendPlace, { ...place });
123
- onChange?.({ ...place });
124
- return;
125
- }
126
- const { shortestPlace, shortestDistance } = findGmapNearestPlace(place, placeCandidates);
127
- const limit = getLimit(context);
128
- const resultPlace = shortestDistance > limit ? place : shortestPlace;
129
- availableRef.value = true;
130
- placeCandidatesRef.value = placeCandidates;
131
- Object.assign(recomendPlace, { ...resultPlace });
132
- onChange?.({ ...resultPlace });
133
- }
134
- );
135
- return {
136
- recomendPlace,
137
- placeCandidates: placeCandidatesRef,
138
- availableRef,
139
- isElectedRef,
140
- updateRecomandPlace,
141
- updatePlace,
142
- setPlace,
143
- updateCity,
144
- };
145
- };
146
-
147
- export const useMapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
148
- const { supplier } = useMapSupplier();
149
- return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
150
- };
@@ -1,16 +0,0 @@
1
- import { inject, provide } from "vue-demi";
2
- import type { Status, UseMapLoaderOutput, UseMapLoaderProps } from "./useMapLoader";
3
-
4
- export interface MapSupplierPayolad extends UseMapLoaderProps {
5
- gmapId: string;
6
- readyPromise: UseMapLoaderOutput["readyPromise"];
7
- status: Status;
8
- }
9
- const context = Symbol();
10
-
11
- export const useMapSupplier = () => {
12
- const payload = inject<MapSupplierPayolad>(context);
13
- if (!payload) throw new Error("MyError: useMapSupplier should be under MapProvider");
14
- return payload;
15
- };
16
- export const provideMapSupplier = (payload: MapSupplierPayolad) => provide(context, payload);
@@ -1,23 +0,0 @@
1
- import { ShallowRef, watch } from "vue-demi";
2
- import type { RegisterOverlay } from "../types/interface";
3
-
4
- export type MROP = MapRegisterOverlayProps<AmapOverlay> | MapRegisterOverlayProps<GmapOverlay>;
5
- export interface MapRegisterOverlayProps<T> {
6
- registerOverlay?: RegisterOverlay<T>;
7
- }
8
- export type AmapOverlay = Parameters<AMap.OverlayGroup["addOverlay"]>[0];
9
- export type GmapOverlay = google.maps.Marker | google.maps.marker.AdvancedMarkerView;
10
- export interface UseMapOverlayProps<T> extends MapRegisterOverlayProps<T> {
11
- overlayRef: ShallowRef<T | undefined>;
12
- }
13
- export const useMapOverlay = <T>(props: UseMapOverlayProps<T>) => {
14
- const { registerOverlay, overlayRef } = props;
15
- watch(
16
- () => overlayRef.value,
17
- (overlay, prevOverlay) => {
18
- if (!registerOverlay) return;
19
- if (prevOverlay) registerOverlay.remove(prevOverlay);
20
- if (overlay) registerOverlay.add(overlay);
21
- }
22
- );
23
- };
@@ -1,61 +0,0 @@
1
- import { ref } from "vue-demi";
2
- import type { Place, Point } from "../types/interface";
3
- import { watchEffectForDeepOption } from "../utils/compare";
4
- import { place2point } from "../utils/transform";
5
- import { useMapLngLatToVw } from "./useMapLngLatToVw";
6
-
7
- type LabelDirection = "left" | "right";
8
- const reverse = (direction: LabelDirection) => (direction === "left" ? "right" : "left");
9
-
10
- export interface UsePointsLabelDirectionProps {
11
- places: Place[];
12
- widthLimit: number;
13
- heightLimit: number;
14
- }
15
- export const usePointsLabelDirection = (props: UsePointsLabelDirectionProps) => {
16
- const { widthLimit, heightLimit } = props;
17
- const { apiMapLngLatToVw } = useMapLngLatToVw();
18
- const diffVw = (from: Point, to: Point) => {
19
- const vw = 100 / window.innerWidth;
20
- const [x1, y1] = apiMapLngLatToVw(from);
21
- const [x2, y2] = apiMapLngLatToVw(to);
22
- return [(x2 - x1) * vw, (y2 - y1) * vw];
23
- };
24
- const directionsRef = ref<LabelDirection[]>(Array(props.places.length).fill("right"));
25
- watchEffectForDeepOption(
26
- () => props.places.map(place2point),
27
- (points) => {
28
- const sortedPoints = points
29
- .map((point, index) => ({ point, index }))
30
- .sort(({ point: [, lat1] }, { point: [, lat2] }) =>
31
- lat1 < lat2 ? 1 : lat1 > lat2 ? -1 : 0
32
- );
33
- const len = points.length;
34
- const result: LabelDirection[] = Array(len);
35
- let prevDirection: LabelDirection = "right";
36
- let isLimited = false;
37
- for (let idx = 0; idx < len; idx++) {
38
- const { index } = sortedPoints[idx];
39
- if (idx === len - 1) {
40
- result[index] = isLimited ? reverse(prevDirection) : "right";
41
- continue;
42
- }
43
- if (idx === 0) {
44
- const [dx, dy] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
45
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
46
- const direction: LabelDirection = !isLimited ? "right" : dx > 0 ? "left" : "right";
47
- result[index] = direction;
48
- prevDirection = direction;
49
- continue;
50
- }
51
- const [dx, dy] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
52
- const direction: LabelDirection = isLimited ? reverse(prevDirection) : "right";
53
- result[index] = direction;
54
- prevDirection = direction;
55
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
56
- }
57
- directionsRef.value = result;
58
- }
59
- );
60
- return directionsRef;
61
- };
@@ -1,9 +0,0 @@
1
- import { ref } from "vue-demi";
2
-
3
- export const useUpdate = () => {
4
- const idx = ref(0);
5
- const update = () => {
6
- idx.value += 1;
7
- };
8
- return { idx, update };
9
- };
@@ -1,25 +0,0 @@
1
- interface TimerStop {
2
- promise: Promise<void>;
3
- resolve?: () => void;
4
- }
5
-
6
- export interface UseWaitTimerProps {
7
- interval: number;
8
- }
9
- export const useWaitTimer = (props: UseWaitTimerProps) => {
10
- const { interval } = props;
11
- let timer: number | undefined = undefined;
12
- const timerStop: TimerStop = {
13
- promise: Promise.resolve(),
14
- resolve: undefined,
15
- };
16
- const timerStart = () => {
17
- if (timer) clearTimeout(timer);
18
- timerStop.resolve?.();
19
- timerStop.promise = new Promise((resolve) => {
20
- timerStop.resolve = resolve;
21
- timer = setTimeout(resolve, interval);
22
- });
23
- };
24
- return { timerStart, timerStop };
25
- };
@@ -1,87 +0,0 @@
1
- import { ShallowRef, shallowRef } from "vue-demi";
2
- import type { Point } from "../types/interface";
3
- import { watchPostEffectForDeepOption } from "../utils/compare";
4
- import { useMapSupplier } from "./useMapSupplier";
5
-
6
- export interface UseWalkingRouteProps {
7
- from: Point;
8
- to: Point;
9
- }
10
-
11
- export const useAWalkingRoute = (props: UseWalkingRouteProps) => {
12
- const pathRef = shallowRef<Point[]>([]);
13
- const amapWalking = new AMap.Walking({});
14
- watchPostEffectForDeepOption(
15
- () => ({ ...props }),
16
- ({ from, to }) => {
17
- amapWalking.search(AMap.LngLat.from(from), AMap.LngLat.from(to), (status, result) => {
18
- switch (status) {
19
- case "complete": {
20
- let path: Point[] = [];
21
- const walkingResult = result as AMap.WalkingResult;
22
- if (!walkingResult.routes) {
23
- return;
24
- }
25
- const firstRoute = walkingResult.routes[0];
26
- for (const step of firstRoute.steps) {
27
- const stepPath = step.path.map<Point>(({ lng, lat }) => [lng, lat]);
28
- path = path.concat(stepPath);
29
- }
30
- pathRef.value = path;
31
- return;
32
- }
33
- case "no_data":
34
- pathRef.value = [];
35
- return;
36
- default:
37
- throw result;
38
- }
39
- });
40
- }
41
- );
42
- return pathRef;
43
- };
44
-
45
- export const useGWalkingRoute = (props: UseWalkingRouteProps) => {
46
- const pathRef = shallowRef<Point[]>([]);
47
- const gmapDirectionsService = new google.maps.DirectionsService();
48
- watchPostEffectForDeepOption(
49
- () => ({ ...props }),
50
- ({ from, to }) => {
51
- gmapDirectionsService.route(
52
- {
53
- origin: { lng: from[0], lat: from[1] },
54
- destination: { lng: to[0], lat: to[1] },
55
- travelMode: google.maps.TravelMode.WALKING,
56
- },
57
- (result, status) => {
58
- switch (status) {
59
- case google.maps.DirectionsStatus.OK: {
60
- let path: Point[] = [];
61
- const firstRoute = result!.routes[0];
62
- const stepPath = firstRoute.overview_path.map<Point>((item) => [
63
- item.lng(),
64
- item.lat(),
65
- ]);
66
- path = path.concat(stepPath);
67
- pathRef.value = path;
68
- return;
69
- }
70
- case google.maps.DirectionsStatus.ZERO_RESULTS:
71
- case google.maps.DirectionsStatus.NOT_FOUND:
72
- pathRef.value = [];
73
- return;
74
- default:
75
- throw new Error(status);
76
- }
77
- }
78
- );
79
- }
80
- );
81
- return pathRef;
82
- };
83
-
84
- export const useWalkingRoute = (props: UseWalkingRouteProps): ShallowRef<Point[]> => {
85
- const { supplier } = useMapSupplier();
86
- return supplier === "gmap" ? useGWalkingRoute(props) : useAWalkingRoute(props);
87
- };
@@ -1,22 +0,0 @@
1
- import type { Ref } from "vue-demi";
2
- import { useMapAutoComplete } from "../hooks/useMapAutoComplete";
3
- import { useMapBoundCity } from "../hooks/useMapCityBound";
4
- import type { MapLogProps } from "../hooks/useMapLog";
5
-
6
- export interface UseBusinessMapAutoCompleteProps extends MapLogProps {
7
- cityNameRef: Ref<string>;
8
- }
9
-
10
- export const useBusinessMapAutoComplete = (props: UseBusinessMapAutoCompleteProps) => {
11
- const { cityNameRef } = props;
12
- const city = useMapBoundCity({
13
- cityNameRef,
14
- onChange: (v) => setCity(v),
15
- });
16
- const { autoCompletePlaces, setKeyword, setCity } = useMapAutoComplete({ city, log: props.log });
17
- const handleKeywordInput = (e: Event) => {
18
- const target = e.target as HTMLInputElement;
19
- setKeyword(target.value);
20
- };
21
- return { autoCompletePlaces, setKeyword, setCity, handleKeywordInput };
22
- };
@@ -1,11 +0,0 @@
1
- import { useHeycarMap } from "../hooks/useHeycarMap";
2
- import { useMapFitView } from "../hooks/useMapFitView";
3
-
4
- export const useBusinessQuotingMap = () => {
5
- const { setMap, mapRef } = useHeycarMap();
6
- const { registerFitVeiw, setFitView } = useMapFitView({
7
- mapRef,
8
- padding: [25, 20, 15, 15],
9
- });
10
- return { setMap, registerFitVeiw, setFitView };
11
- };
@@ -1,45 +0,0 @@
1
- import { reactive, ref } from "vue-demi";
2
- import { useMapGeometry } from "../hooks/useMapGeometry";
3
- import type { Place, Point } from "../types/interface";
4
-
5
- export interface BusinessRecomendPlaceContext {
6
- panToGeoPositionByRecomend: (value: Point) => void;
7
- setCenterPlaceByUserSpecified: (value: Place) => void;
8
- onChangeCenterPlace: (value: Place) => void;
9
- onChangeRecomendPlaces: (value: Place[]) => void;
10
- }
11
-
12
- export const useBusinessRecomendPlaceMap = () => {
13
- const centerPlace = reactive<Place>({
14
- lng: 0,
15
- lat: 0,
16
- name: "",
17
- });
18
- const placeCandidates = ref<Place[]>([]);
19
- const { apiMapDistance } = useMapGeometry();
20
- const panToGeoPositionByRecomend = (value: Point) => mapContext.panToGeoPositionByRecomend(value);
21
- const setCenterPlaceByUserSpecified = (value: Place) =>
22
- mapContext.setCenterPlaceByUserSpecified(value);
23
- const mapContext: BusinessRecomendPlaceContext = {
24
- panToGeoPositionByRecomend: () => {
25
- throw new Error("MyError: panToGeoPositionByRecomend used before assigned");
26
- },
27
- setCenterPlaceByUserSpecified: () => {
28
- throw new Error("MyError: setCenterPlaceByRecomand used before assigned");
29
- },
30
- onChangeCenterPlace: (place: Place) => {
31
- Object.assign(centerPlace, { ...place });
32
- },
33
- onChangeRecomendPlaces: (places: Place[]) => {
34
- placeCandidates.value = [...places];
35
- },
36
- };
37
- return {
38
- mapContext,
39
- centerPlace,
40
- placeCandidates,
41
- panToGeoPositionByRecomend,
42
- setCenterPlaceByUserSpecified,
43
- apiMapDistance,
44
- };
45
- };
@@ -1,12 +0,0 @@
1
- import { useHeycarMap } from "../hooks/useHeycarMap";
2
- import { useMapFitView } from "../hooks/useMapFitView";
3
-
4
- export const useBusinessTaxiServiceMap = () => {
5
- const { mapRef, setMap } = useHeycarMap();
6
- const { registerFitVeiw, setFitView } = useMapFitView({
7
- mapRef,
8
- autoFitTimeout: 5000,
9
- padding: [25, 20, 15, 15],
10
- });
11
- return { setMap, registerFitVeiw, setFitView };
12
- };
package/src/index.ts DELETED
@@ -1,33 +0,0 @@
1
- import "./style.css";
2
- export { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox";
3
- export { AddressBox } from "./business-components/AddressBox";
4
- export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
5
- export { BusinessRecomendPlaceMap } from "./business-components/BusinessRecomendPlaceMap";
6
- export { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap";
7
- export { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap";
8
- export { DrivingLine } from "./business-components/DrivingLine";
9
- export { DrivingRoute } from "./business-components/DrivingRoute";
10
- export { PassengerCircle } from "./business-components/PassengerCircle";
11
- export { PickupPoints } from "./business-components/PickupPoints";
12
- export { PlaceCircle } from "./business-components/PlaceCircle";
13
- export { StartEndPoint } from "./business-components/StartEndPoint";
14
- export { TaxiCar } from "./business-components/TaxiCar";
15
- export { WalkingLine } from "./business-components/WalkingLine";
16
- export { WalkingRoute } from "./business-components/WalkingRoute";
17
- export { WaveCircle } from "./business-components/WaveCircle";
18
- export * from "./components/MapProvider";
19
- export * from "./hooks-business/useBusinessMapAutoComplete";
20
- export * from "./hooks-business/useBusinessQuotingMap";
21
- export * from "./hooks-business/useBusinessRecomendPlaceMap";
22
- export * from "./hooks-business/useBusinessTaxiServiceMap";
23
- export { useDrivingRoute } from "./hooks/useDrivingRoute";
24
- export { useGeoLocation } from "./hooks/useGeoLocation";
25
- export { useHeycarMap } from "./hooks/useHeycarMap";
26
- export { useMapAngle } from "./hooks/useMapAngle";
27
- export { useMapDrag } from "./hooks/useMapDrag";
28
- export { useMapFitView } from "./hooks/useMapFitView";
29
- export { useMapGeometry } from "./hooks/useMapGeometry";
30
- export { useMapPlace } from "./hooks/useMapPlace";
31
- export { useMapRecomendPlace } from "./hooks/useMapRecomendPlace";
32
- export { useWalkingRoute } from "./hooks/useWalkingRoute";
33
- export * from "./types/interface";
package/src/main.ts DELETED
@@ -1,6 +0,0 @@
1
- import { createApp } from "vue-demi";
2
-
3
- import { App } from "./App";
4
- import "./style.css";
5
-
6
- createApp(App).mount("#app");
package/src/style.css DELETED
File without changes