@heycar/heycars-map 0.3.1 → 0.3.2
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.
- package/README.md +1 -1
- package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +3 -1
- package/dist/hooks/useMapAutoComplete.d.ts +5 -5
- package/dist/hooks/useMapCityBound.d.ts +5 -5
- package/dist/hooks/useMapPlace.d.ts +10 -2
- package/dist/hooks/useMapRecomendPlace.d.ts +6 -2
- package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +1 -1
- package/dist/hooks-business/useBusinessRecomendPlaceMap.d.ts +2 -2
- package/dist/index.cjs +52 -52
- package/dist/index.js +1464 -1439
- package/dist/style.css +1 -1
- package/dist/types/interface.d.ts +1 -1
- package/package.json +1 -1
- package/src/Demo/DemoBusinessRecomendPlace.tsx +13 -6
- package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.ts +2 -0
- package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.tsx +5 -3
- package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +26 -22
- package/src/hooks/useGeoLocation.ts +6 -2
- package/src/hooks/useMapAutoComplete.ts +4 -4
- package/src/hooks/useMapCityBound.ts +5 -5
- package/src/hooks/useMapDrag.ts +7 -2
- package/src/hooks/useMapPlace.ts +37 -18
- package/src/hooks/useMapRecomendPlace.ts +17 -4
- package/src/hooks-business/useBusinessRecomendPlaceMap.ts +5 -5
- package/src/types/interface.ts +1 -1
- package/dist/hooks-business/useLagecyMapRecomendPlace.d.ts +0 -57
- package/src/hooks-business/useLagecyMapRecomendPlace.ts +0 -152
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.n8tgem0{position:absolute;bottom:50%;left:0;right:0;margin-left:auto;margin-right:auto;display:flex;flex-direction:column;align-items:center;z-index:1}.n8tgem1{padding:2.67vw 4.27vw;background:linear-gradient(90deg,#79AFFF 0%,#5C8DFF 32%,#507FFF 75%,#4471FF 100%);border-radius:3.2vw;display:flex;align-items:center}.n8tgem2{padding-right:2.67vw;max-width:41.33vw}.n8tgem3{display:-webkit-box;font-size:3.47vw;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:4.8vw;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.n8tgem4{margin-top:.53vw;font-size:2.93vw;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;color:#fff;line-height:4.27vw;opacity:.8}.n8tgem5{width:1.758vw;height:2.93vw}.n8tgem6{width:.8vw;height:4vw;background:#4C80FF;border-radius:0vw 0vw 26.67vw 26.67vw}.n8tgem7{width:6.9355vw;height:10.67vw}.rgf09w0{width:7.1045vw;height:10.93vw;display:flex}._15rq2xn0{display:flex;flex-direction:column;align-items:center;margin-bottom:-1.6vw}._15rq2xn1{padding:2.13vw 4.5vw 2.67vw 4.27vw;display:flex;align-items:center;background:linear-gradient(90deg,#79AFFF 0%,#5C8DFF 32%,#507FFF 75%,#4471FF 100%);border-radius:3.2vw}._15rq2xn2{font-size:3.47vw;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:4.8vw;white-space:nowrap}._15rq2xn3{font-size:2.93vw;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;color:#eafaf8;line-height:4.27vw;white-space:nowrap;opacity:.8}._15rq2xn4{margin-left:3.2vw;width:1.44vw;height:2.4vw}._15rq2xn5{width:.8vw;height:4vw;background:#4C80FF;border-radius:0vw 0vw 26.67vw 26.67vw;z-index:1}._15rq2xn6{margin-top:-1.5vw;width:3.2vw;height:3.2vw}._1d8ur7t0,._7anfuo0{position:relative}._4a4ovk0{margin-bottom:-.4vw;display:flex;flex-direction:column;align-items:center}._4a4ovk1{padding:1.07vw 2.4vw 1.6vw 2.67vw;background:#FFFFFF;box-shadow:0 .53vw 2.4vw #3f3f3f33;border-radius:2.13vw}._4a4ovk2{padding:2.67vw 2.67vw 2.4vw 3.2vw;background:#FFFFFF;box-shadow:0 0 2.67vw #4e556c26;border-radius:4.8vw;font-size:3.2vw;font-family:PingFangSC-Medium,PingFang SC;font-weight:500;color:#1e1e1e;line-height:4.53vw;white-space:nowrap}._4a4ovk3{font-size:3.2vw;font-family:PingFangSC-Medium,PingFang SC;font-weight:500;color:#1e1e1e;line-height:4.53vw;white-space:nowrap}._4a4ovk4{font-size:2.4vw;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;color:#7e7e7e;line-height:3.47vw;white-space:nowrap}._4a4ovk5{color:#4471ff;font-family:PingFangSC-Medium,PingFang SC;font-weight:500}._4a4ovk6{margin-top:1.33vw;width:6.192vw;height:7.998vw}._4a4ovk7{margin-top:2.4vw;width:6.192vw;height:7.998vw}._1l6offo0{display:flex}._1l6offo1{width:4.53vw;height:4.53vw;margin-bottom:-2.265vw}._1l6offo2{width:16.27vw;height:16.27vw;margin-bottom:-8.135vw}.fhyw80{display:flex;align-items:center}.fhyw81{flex-direction:row-reverse}.fhyw83{margin-right:-2.265vw}.fhyw84{margin-left:-2.265vw}.fhyw85{margin-bottom:-2.265vw}.fhyw86{margin-right:calc(50% - 2.265vw)}.fhyw87{margin-left:calc(50% - 2.265vw)}.fhyw88{display:flex;width:4.53vw;height:4.53vw}.fhyw89{opacity:0}.fhyw8b{font-size:3.47vw;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#243e66;line-height:4.53vw;white-space:nowrap}._65j3sr1{margin-top:1.87vw;margin-bottom:-5.5vw;width:6vw;height:11vw}@keyframes rrvp0y0{0%{transform:scale(0);opacity:1}33.33%{transform:scale(.5);opacity:1}66.66%{transform:scale(1);opacity:0}to{transform:scale(1);opacity:0}}@keyframes rrvp0y1{0%{transform:scale(0);opacity:0}33.33%{transform:scale(0);opacity:1}66.66%{transform:scale(.5);opacity:1}to{transform:scale(1);opacity:0}}.rrvp0y2{display:flex;margin-bottom:-30.935vw;width:61.87vw;height:61.87vw;animation-name:rrvp0y0;animation-duration:3s;animation-iteration-count:infinite;animation-timing-function:linear}.rrvp0y3{animation-name:rrvp0y1}
|
|
1
|
+
.n8tgem0{pointer-events:none;position:absolute;bottom:50%;left:0;right:0;margin-left:auto;margin-right:auto;display:flex;flex-direction:column;align-items:center;z-index:1}.n8tgem1{pointer-events:auto;padding:2.67vw 4.27vw;background:linear-gradient(90deg,#79AFFF 0%,#5C8DFF 32%,#507FFF 75%,#4471FF 100%);border-radius:3.2vw;display:flex;align-items:center}.n8tgem2{padding-right:2.67vw;max-width:41.33vw}.n8tgem3{display:-webkit-box;font-size:3.47vw;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:4.8vw;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.n8tgem4{margin-top:.53vw;font-size:2.93vw;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;color:#fff;line-height:4.27vw;opacity:.8}.n8tgem5{width:1.758vw;height:2.93vw}.n8tgem6{width:.8vw;height:4vw;background:#4C80FF;border-radius:0vw 0vw 26.67vw 26.67vw}.n8tgem7{width:6.9355vw;height:10.67vw}.rgf09w0{width:7.1045vw;height:10.93vw;display:flex}._15rq2xn0{display:flex;flex-direction:column;align-items:center;margin-bottom:-1.6vw}._15rq2xn1{padding:2.13vw 4.5vw 2.67vw 4.27vw;display:flex;align-items:center;background:linear-gradient(90deg,#79AFFF 0%,#5C8DFF 32%,#507FFF 75%,#4471FF 100%);border-radius:3.2vw}._15rq2xn2{font-size:3.47vw;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#fff;line-height:4.8vw;white-space:nowrap}._15rq2xn3{font-size:2.93vw;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;color:#eafaf8;line-height:4.27vw;white-space:nowrap;opacity:.8}._15rq2xn4{margin-left:3.2vw;width:1.44vw;height:2.4vw}._15rq2xn5{width:.8vw;height:4vw;background:#4C80FF;border-radius:0vw 0vw 26.67vw 26.67vw;z-index:1}._15rq2xn6{margin-top:-1.5vw;width:3.2vw;height:3.2vw}._1d8ur7t0,._7anfuo0{position:relative}._4a4ovk0{margin-bottom:-.4vw;display:flex;flex-direction:column;align-items:center}._4a4ovk1{padding:1.07vw 2.4vw 1.6vw 2.67vw;background:#FFFFFF;box-shadow:0 .53vw 2.4vw #3f3f3f33;border-radius:2.13vw}._4a4ovk2{padding:2.67vw 2.67vw 2.4vw 3.2vw;background:#FFFFFF;box-shadow:0 0 2.67vw #4e556c26;border-radius:4.8vw;font-size:3.2vw;font-family:PingFangSC-Medium,PingFang SC;font-weight:500;color:#1e1e1e;line-height:4.53vw;white-space:nowrap}._4a4ovk3{font-size:3.2vw;font-family:PingFangSC-Medium,PingFang SC;font-weight:500;color:#1e1e1e;line-height:4.53vw;white-space:nowrap}._4a4ovk4{font-size:2.4vw;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;color:#7e7e7e;line-height:3.47vw;white-space:nowrap}._4a4ovk5{color:#4471ff;font-family:PingFangSC-Medium,PingFang SC;font-weight:500}._4a4ovk6{margin-top:1.33vw;width:6.192vw;height:7.998vw}._4a4ovk7{margin-top:2.4vw;width:6.192vw;height:7.998vw}._1l6offo0{display:flex}._1l6offo1{width:4.53vw;height:4.53vw;margin-bottom:-2.265vw}._1l6offo2{width:16.27vw;height:16.27vw;margin-bottom:-8.135vw}.fhyw80{display:flex;align-items:center}.fhyw81{flex-direction:row-reverse}.fhyw83{margin-right:-2.265vw}.fhyw84{margin-left:-2.265vw}.fhyw85{margin-bottom:-2.265vw}.fhyw86{margin-right:calc(50% - 2.265vw)}.fhyw87{margin-left:calc(50% - 2.265vw)}.fhyw88{display:flex;width:4.53vw;height:4.53vw}.fhyw89{opacity:0}.fhyw8b{font-size:3.47vw;font-family:PingFangSC-Semibold,PingFang SC;font-weight:600;color:#243e66;line-height:4.53vw;white-space:nowrap}._65j3sr1{margin-top:1.87vw;margin-bottom:-5.5vw;width:6vw;height:11vw}@keyframes rrvp0y0{0%{transform:scale(0);opacity:1}33.33%{transform:scale(.5);opacity:1}66.66%{transform:scale(1);opacity:0}to{transform:scale(1);opacity:0}}@keyframes rrvp0y1{0%{transform:scale(0);opacity:0}33.33%{transform:scale(0);opacity:1}66.66%{transform:scale(.5);opacity:1}to{transform:scale(1);opacity:0}}.rrvp0y2{display:flex;margin-bottom:-30.935vw;width:61.87vw;height:61.87vw;animation-name:rrvp0y0;animation-duration:3s;animation-iteration-count:infinite;animation-timing-function:linear}.rrvp0y3{animation-name:rrvp0y1}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed } from "vue-demi";
|
|
1
|
+
import { computed, reactive } from "vue-demi";
|
|
2
2
|
import {
|
|
3
3
|
BusinessRecomendPlaceMap,
|
|
4
4
|
BusinessRecomendPlaceMapProps,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { useBusinessMapAutoComplete } from "../hooks-business/useBusinessMapAutoComplete";
|
|
7
7
|
import { useBusinessRecomendPlaceMap } from "../hooks-business/useBusinessRecomendPlaceMap";
|
|
8
8
|
import { defineSetup } from "../types/helper";
|
|
9
|
+
import type { Region } from "../types/interface";
|
|
9
10
|
import * as css from "./Demo.css";
|
|
10
11
|
|
|
11
12
|
const SomeAutoComplete = defineSetup(function SomeAutoComplete(props: { cityName: string }) {
|
|
@@ -32,6 +33,8 @@ const SomeAutoComplete = defineSetup(function SomeAutoComplete(props: { cityName
|
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecomendPlace() {
|
|
36
|
+
const city = reactive<Region>({ name: "" });
|
|
37
|
+
const cityParent = reactive<Region>({ name: "" });
|
|
35
38
|
const getRecomendPlace: BusinessRecomendPlaceMapProps["getRecomendPlace"] = async (
|
|
36
39
|
place,
|
|
37
40
|
context
|
|
@@ -46,22 +49,22 @@ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecome
|
|
|
46
49
|
const {
|
|
47
50
|
centerPlace,
|
|
48
51
|
placeCandidates,
|
|
49
|
-
|
|
52
|
+
setCenterPlaceByUserSpecified,
|
|
50
53
|
mapContext,
|
|
51
|
-
apiMapDistance,
|
|
52
54
|
panToGeoPositionByRecomend,
|
|
53
55
|
} = useBusinessRecomendPlaceMap();
|
|
54
|
-
(window as any).
|
|
56
|
+
(window as any).setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
|
|
55
57
|
(window as any).panToGeoPositionByRecomend = panToGeoPositionByRecomend;
|
|
56
58
|
return () => {
|
|
57
59
|
return (
|
|
58
60
|
<div>
|
|
59
61
|
placeCandidates: {placeCandidates} <br />
|
|
60
|
-
centerPlace: {centerPlace.lng} | {centerPlace.lat} | {centerPlace.name} |{" "}
|
|
61
|
-
{
|
|
62
|
+
centerPlace: {centerPlace.lng} | {centerPlace.lat} | {centerPlace.name} | {city.name} |{" "}
|
|
63
|
+
{cityParent.name} <br />
|
|
62
64
|
<SomeAutoComplete cityName="Shinjuku-ku"></SomeAutoComplete>
|
|
63
65
|
<BusinessRecomendPlaceMap
|
|
64
66
|
class={css.demo}
|
|
67
|
+
geoLoadingTitle={"正在读取GPS位置信息..."}
|
|
65
68
|
unavailableTitle={"当前区域暂未开通服务"}
|
|
66
69
|
noRecomendDescription={"附近无推荐上车地点"}
|
|
67
70
|
recomendDescription={"最佳上车地点"}
|
|
@@ -70,6 +73,10 @@ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecome
|
|
|
70
73
|
mapContext={mapContext}
|
|
71
74
|
onGeoError={(e) => console.log("onGeoError e = ", e)}
|
|
72
75
|
onClickLocator={() => alert("hi")}
|
|
76
|
+
onChangeCity={({ cityName, cityParentName }) => {
|
|
77
|
+
city.name = cityName ?? "";
|
|
78
|
+
cityParent.name = cityParentName ?? "";
|
|
79
|
+
}}
|
|
73
80
|
/>
|
|
74
81
|
</div>
|
|
75
82
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { style } from "@vanilla-extract/css";
|
|
2
2
|
|
|
3
3
|
export const absoluteAddressBoxLayout = style({
|
|
4
|
+
pointerEvents: "none",
|
|
4
5
|
position: "absolute",
|
|
5
6
|
bottom: "50%",
|
|
6
7
|
left: 0,
|
|
@@ -14,6 +15,7 @@ export const absoluteAddressBoxLayout = style({
|
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
export const absoluteAddressBox = style({
|
|
18
|
+
pointerEvents: "auto",
|
|
17
19
|
padding: "2.67vw 4.27vw",
|
|
18
20
|
background: "linear-gradient(90deg, #79AFFF 0%, #5C8DFF 32%, #507FFF 75%, #4471FF 100%)",
|
|
19
21
|
borderRadius: "3.2vw",
|
|
@@ -25,12 +25,14 @@ export const AbsoluteAddressBox = defineSetup(function AbsoluteAddressBox(
|
|
|
25
25
|
);
|
|
26
26
|
return (
|
|
27
27
|
<div class={css.absoluteAddressBoxLayout}>
|
|
28
|
-
<div class={css.absoluteAddressBox}
|
|
28
|
+
<div class={css.absoluteAddressBox}>
|
|
29
29
|
<div class={css.boxTextLayout}>
|
|
30
|
-
<div class={css.boxTitle}
|
|
30
|
+
<div class={css.boxTitle} onClick={handleClick}>
|
|
31
|
+
{title}
|
|
32
|
+
</div>
|
|
31
33
|
{description && <div class={css.boxDescription}>{description}</div>}
|
|
32
34
|
</div>
|
|
33
|
-
<img class={css.arrowRight} src={imgArrowRight} />
|
|
35
|
+
<img class={css.arrowRight} src={imgArrowRight} onClick={handleClick} />
|
|
34
36
|
</div>
|
|
35
37
|
<i class={css.straightLine} />
|
|
36
38
|
</div>
|
|
@@ -23,6 +23,7 @@ export interface BusinessRecomendPlaceMapProps
|
|
|
23
23
|
extends Omit<HeycarMapProps, "center" | "zoom" | "mapRef">,
|
|
24
24
|
Pick<UseMapRecomendPlaceProps<CenterPlaceSource>, "getRecomendPlace">,
|
|
25
25
|
MapLogProps {
|
|
26
|
+
geoLoadingTitle: string;
|
|
26
27
|
unavailableTitle: string;
|
|
27
28
|
recomendDescription: string;
|
|
28
29
|
noRecomendDescription: string;
|
|
@@ -33,6 +34,7 @@ export interface BusinessRecomendPlaceMapProps
|
|
|
33
34
|
onChangeByDrag?: UseMapDragProps["onChange"];
|
|
34
35
|
onChangeGeoLocation?: UseGeoLocationProps["onChange"];
|
|
35
36
|
onChangePlace?: UseMapPlaceProps["onChange"];
|
|
37
|
+
onChangeCity?: UseMapPlaceProps["onChangeCity"];
|
|
36
38
|
onChangeRecomandPlace?: UseMapRecomendPlaceProps["onChange"];
|
|
37
39
|
onGeoError?: UseGeoLocationProps["onError"];
|
|
38
40
|
onClickLocator?: AbsoluteAddressBoxProps["onClick"];
|
|
@@ -47,15 +49,17 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
47
49
|
lng: geoDefaultPosition?.[0] ?? 0,
|
|
48
50
|
lat: geoDefaultPosition?.[1] ?? 0,
|
|
49
51
|
name: "",
|
|
50
|
-
cityName: undefined,
|
|
51
52
|
});
|
|
52
53
|
const centerPoint = computed<Point>(() => [centerPlace.lng, centerPlace.lat]);
|
|
53
54
|
const centerSource: CenterPlaceSource = { source: "geo" };
|
|
54
55
|
const setCenterPlaceByRecomand = (point: Point) => {
|
|
55
56
|
centerSource.source = "api";
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
updatePlace(point);
|
|
58
|
+
};
|
|
59
|
+
const setCenterPlaceByUserSpecified = (place: Place) => {
|
|
60
|
+
centerSource.source = "api";
|
|
61
|
+
setPlace(place);
|
|
62
|
+
updateRecomandPlace();
|
|
59
63
|
};
|
|
60
64
|
const setCenterByPlace = (place: Place) => {
|
|
61
65
|
centerSource.source = "api";
|
|
@@ -64,30 +68,26 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
64
68
|
centerPlace.name = place.name;
|
|
65
69
|
};
|
|
66
70
|
|
|
67
|
-
const { geoPosition, geoError } = useGeoLocation({
|
|
71
|
+
const { geoPosition, geoError, geoLoading } = useGeoLocation({
|
|
68
72
|
geoDefaultPosition,
|
|
69
73
|
onLoad: async (value) => {
|
|
70
74
|
// geo 主入口
|
|
71
75
|
await readyPromise;
|
|
72
76
|
centerSource.source = "geo";
|
|
73
|
-
|
|
74
|
-
centerPlace.lat = value.position[1];
|
|
75
|
-
updatePlace();
|
|
77
|
+
updatePlace(value.position);
|
|
76
78
|
emit("loadGeoLocation", value);
|
|
77
79
|
},
|
|
78
80
|
onLoadDefault: async (value) => {
|
|
79
81
|
// geo default position 主入口
|
|
80
82
|
await readyPromise;
|
|
81
83
|
centerSource.source = "geo";
|
|
82
|
-
|
|
83
|
-
centerPlace.lat = value.position[1];
|
|
84
|
-
updatePlace();
|
|
84
|
+
updatePlace(value.position);
|
|
85
85
|
emit("loadDefaultGeoLocation", value);
|
|
86
86
|
},
|
|
87
87
|
onChange: (v) => emit("changeGeoLocation", v),
|
|
88
88
|
onError: (e) => emit("geoError", e),
|
|
89
89
|
});
|
|
90
|
-
mapContext.
|
|
90
|
+
mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
|
|
91
91
|
mapContext.panToGeoPositionByRecomend = () => {
|
|
92
92
|
if (geoError.value) return false;
|
|
93
93
|
setCenterPlaceByRecomand(geoPosition.value);
|
|
@@ -97,14 +97,12 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
97
97
|
mapRef,
|
|
98
98
|
onChange: (point) => {
|
|
99
99
|
centerSource.source = "drag";
|
|
100
|
-
|
|
101
|
-
centerPlace.lat = point[1];
|
|
102
|
-
updatePlace();
|
|
100
|
+
updatePlace(point);
|
|
103
101
|
emit("changeByDrag", point);
|
|
104
102
|
},
|
|
105
103
|
});
|
|
106
|
-
const { updatePlace, updateRecomandPlace, placeCandidates, availableRef } =
|
|
107
|
-
{
|
|
104
|
+
const { updatePlace, setPlace, updateRecomandPlace, placeCandidates, availableRef } =
|
|
105
|
+
useMapRecomendPlace({
|
|
108
106
|
pointRef: centerPoint,
|
|
109
107
|
context: centerSource,
|
|
110
108
|
getRecomendPlace,
|
|
@@ -122,7 +120,6 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
122
120
|
}
|
|
123
121
|
},
|
|
124
122
|
onChangePlace: (place) => {
|
|
125
|
-
Object.assign(centerPlace, { ...place });
|
|
126
123
|
if (centerSource.source !== "recomend") {
|
|
127
124
|
updateRecomandPlace();
|
|
128
125
|
}
|
|
@@ -131,11 +128,12 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
131
128
|
onChange: (place) => {
|
|
132
129
|
centerSource.source = "recomend";
|
|
133
130
|
Object.assign(centerPlace, { ...place });
|
|
134
|
-
updatePlace();
|
|
135
131
|
emit("changeRecomandPlace", place);
|
|
136
132
|
},
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
onChangeCity: (value) => {
|
|
134
|
+
emit("changeCity", value);
|
|
135
|
+
},
|
|
136
|
+
});
|
|
139
137
|
watchEffect(() => {
|
|
140
138
|
mapContext.onChangeCenterPlace({ ...centerPlace });
|
|
141
139
|
});
|
|
@@ -143,6 +141,11 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
143
141
|
mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
|
|
144
142
|
});
|
|
145
143
|
return () => {
|
|
144
|
+
const title = geoLoading.value
|
|
145
|
+
? props.geoLoadingTitle
|
|
146
|
+
: availableRef.value
|
|
147
|
+
? centerPlace.name
|
|
148
|
+
: props.unavailableTitle;
|
|
146
149
|
const description = !availableRef.value
|
|
147
150
|
? undefined
|
|
148
151
|
: placeCandidates.value.length > 0
|
|
@@ -153,7 +156,7 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
153
156
|
<PassengerCircle position={geoPosition.value} />
|
|
154
157
|
<PickupPoints places={placeCandidates.value} onClick={setCenterByPlace} log={props.log} />
|
|
155
158
|
<AbsoluteAddressBox
|
|
156
|
-
title={
|
|
159
|
+
title={title}
|
|
157
160
|
description={description}
|
|
158
161
|
type={isDragging.value ? "locator" : "box"}
|
|
159
162
|
log={props.log}
|
|
@@ -165,6 +168,7 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
|
|
|
165
168
|
}
|
|
166
169
|
).props([
|
|
167
170
|
"log",
|
|
171
|
+
"geoLoadingTitle",
|
|
168
172
|
"unavailableTitle",
|
|
169
173
|
"recomendDescription",
|
|
170
174
|
"noRecomendDescription",
|
|
@@ -10,6 +10,7 @@ export interface UseGeoLocationProps {
|
|
|
10
10
|
}
|
|
11
11
|
export const useGeoLocation = (props?: UseGeoLocationProps) => {
|
|
12
12
|
const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props ?? {};
|
|
13
|
+
let isOnLoadDefaultTriggered = false;
|
|
13
14
|
const loading = ref(false);
|
|
14
15
|
const readyRef = ref(false);
|
|
15
16
|
const errorRef = ref<GeolocationPositionError>();
|
|
@@ -44,12 +45,15 @@ export const useGeoLocation = (props?: UseGeoLocationProps) => {
|
|
|
44
45
|
loading.value = false;
|
|
45
46
|
errorRef.value = error;
|
|
46
47
|
const position = props?.geoDefaultPosition;
|
|
47
|
-
if (position)
|
|
48
|
+
if (position && !isOnLoadDefaultTriggered) {
|
|
49
|
+
isOnLoadDefaultTriggered = true;
|
|
50
|
+
onLoadDefault?.({ position });
|
|
51
|
+
}
|
|
48
52
|
onError?.(error);
|
|
49
53
|
console.log("errorRef = ", errorRef);
|
|
50
54
|
},
|
|
51
55
|
// todo 要不要 timeout
|
|
52
|
-
{ timeout:
|
|
56
|
+
{ timeout: 3000, maximumAge: 0, enableHighAccuracy: false }
|
|
53
57
|
);
|
|
54
58
|
onCleanup(() => navigator.geolocation.clearWatch(watchId));
|
|
55
59
|
},
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ref, watch } from "vue-demi";
|
|
2
|
-
import type { AutoCompletePlace,
|
|
2
|
+
import type { AutoCompletePlace, Region } from "../types/interface";
|
|
3
3
|
import { MapLogProps, useMapLogVariable } from "./useMapLog";
|
|
4
4
|
import { useMapSupplier } from "./useMapSupplier";
|
|
5
5
|
import { useUpdate } from "./useUdate";
|
|
6
6
|
|
|
7
7
|
export interface UseMapAutoCompleteProps extends MapLogProps {
|
|
8
|
-
city:
|
|
8
|
+
city: Region;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const useAmapAutoComplete = (props: UseMapAutoCompleteProps) => {
|
|
@@ -16,7 +16,7 @@ export const useAmapAutoComplete = (props: UseMapAutoCompleteProps) => {
|
|
|
16
16
|
const keywordRef = ref("");
|
|
17
17
|
const autoCompletePlacesRef = ref<AutoCompletePlace[]>([]);
|
|
18
18
|
const { update, idx: updateKey } = useUpdate();
|
|
19
|
-
const setCity = (value:
|
|
19
|
+
const setCity = (value: Region) => {
|
|
20
20
|
cityRef.value = value;
|
|
21
21
|
update();
|
|
22
22
|
};
|
|
@@ -65,7 +65,7 @@ export const useGmapAutoComplete = (props: UseMapAutoCompleteProps) => {
|
|
|
65
65
|
const keywordRef = ref("");
|
|
66
66
|
const autoCompletePlacesRef = ref<AutoCompletePlace[]>([]);
|
|
67
67
|
const { update, idx: updateKey } = useUpdate();
|
|
68
|
-
const setCity = (value:
|
|
68
|
+
const setCity = (value: Region) => {
|
|
69
69
|
cityRef.value = value;
|
|
70
70
|
update();
|
|
71
71
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { reactive, Ref, watch, watchEffect } from "vue-demi";
|
|
2
2
|
import { LANGUAGE } from "../types/helper";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Region } from "../types/interface";
|
|
4
4
|
import { useMapSupplier } from "./useMapSupplier";
|
|
5
5
|
|
|
6
6
|
export interface UseMapCityBoundProps {
|
|
7
7
|
cityNameRef: Ref<string | undefined>;
|
|
8
|
-
onChange?: (value:
|
|
8
|
+
onChange?: (value: Region) => any;
|
|
9
9
|
}
|
|
10
|
-
export const useAmapBoundCity = (props: UseMapCityBoundProps):
|
|
10
|
+
export const useAmapBoundCity = (props: UseMapCityBoundProps): Region => {
|
|
11
11
|
const { cityNameRef, onChange } = props;
|
|
12
12
|
const city = reactive({ name: cityNameRef.value ?? "" });
|
|
13
13
|
watch(
|
|
@@ -21,10 +21,10 @@ export const useAmapBoundCity = (props: UseMapCityBoundProps): City => {
|
|
|
21
21
|
return city;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const useGmapBoundCity = (props: UseMapCityBoundProps):
|
|
24
|
+
export const useGmapBoundCity = (props: UseMapCityBoundProps): Region => {
|
|
25
25
|
const { cityNameRef, onChange } = props;
|
|
26
26
|
const { readyPromise } = useMapSupplier();
|
|
27
|
-
const city = reactive<
|
|
27
|
+
const city = reactive<Region>({
|
|
28
28
|
name: cityNameRef.value ?? "",
|
|
29
29
|
bound: {
|
|
30
30
|
east: 0,
|
package/src/hooks/useMapDrag.ts
CHANGED
|
@@ -18,9 +18,12 @@ export const useAmapDrag = (props: UseMapDragProps<AMap.Map>) => {
|
|
|
18
18
|
const centerRef = ref<Point>([0, 0]);
|
|
19
19
|
const isDragging = ref(false);
|
|
20
20
|
const emitDragStart: SetupContextEmitHandler<Pick<AmapProps, "onDragStart">> = () => {
|
|
21
|
-
|
|
21
|
+
pipeAsync(() => {
|
|
22
|
+
isDragging.value = true;
|
|
23
|
+
});
|
|
22
24
|
};
|
|
23
25
|
const emitDragEnd: SetupContextEmitHandler<Pick<AmapProps, "onDragEnd">> = (_, { target }) => {
|
|
26
|
+
console.log("on DragEnd ------");
|
|
24
27
|
isDragging.value = false;
|
|
25
28
|
const { lng, lat } = target.getCenter();
|
|
26
29
|
centerRef.value = [lng, lat];
|
|
@@ -40,7 +43,9 @@ export const useGmapDrag = (props: UseMapDragProps<google.maps.Map>) => {
|
|
|
40
43
|
const centerRef = ref<Point>([0, 0]);
|
|
41
44
|
const isDragging = ref(false);
|
|
42
45
|
const emitDragStart: SetupContextEmitHandler<Pick<GmapProps, "onDragStart">> = () => {
|
|
43
|
-
|
|
46
|
+
pipeAsync(() => {
|
|
47
|
+
isDragging.value = true;
|
|
48
|
+
});
|
|
44
49
|
};
|
|
45
50
|
const emitDragEnd: SetupContextEmitHandler<Pick<GmapProps, "onDragEnd">> = async () => {
|
|
46
51
|
isDragging.value = false;
|
package/src/hooks/useMapPlace.ts
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
import { reactive, Ref, watch } from "vue-demi";
|
|
1
|
+
import { reactive, ref, Ref, watch } from "vue-demi";
|
|
2
2
|
import { LANGUAGE } from "../types/helper";
|
|
3
3
|
import type { Place, Point } from "../types/interface";
|
|
4
4
|
import { geocoderResult2cityName } from "../utils/transform";
|
|
5
5
|
import { useMapSupplier } from "./useMapSupplier";
|
|
6
6
|
import { useUpdate } from "./useUdate";
|
|
7
7
|
|
|
8
|
+
export interface UseMapPlaceOnChangeCityProps {
|
|
9
|
+
cityName?: string;
|
|
10
|
+
cityParentName?: string;
|
|
11
|
+
}
|
|
8
12
|
export interface UseMapPlaceProps {
|
|
9
13
|
pointRef: Ref<Point>;
|
|
10
14
|
onChange?: (value: Place) => any;
|
|
15
|
+
onChangeCity?: (value: UseMapPlaceOnChangeCityProps) => any;
|
|
11
16
|
}
|
|
12
17
|
export const useAmapPlace = (props: UseMapPlaceProps) => {
|
|
13
|
-
const {
|
|
18
|
+
const { onChange, onChangeCity } = props;
|
|
19
|
+
const defaultPoint: Point = [...props.pointRef.value];
|
|
20
|
+
const pointRef = ref<Point>(defaultPoint);
|
|
14
21
|
const { readyPromise } = useMapSupplier();
|
|
15
|
-
const { idx: placeKey, update: updatePlace } = useUpdate();
|
|
16
22
|
const place = reactive<Place>({
|
|
17
23
|
lng: pointRef.value[0],
|
|
18
24
|
lat: pointRef.value[1],
|
|
19
25
|
name: "",
|
|
20
|
-
cityName: undefined,
|
|
21
26
|
});
|
|
27
|
+
const { idx: placeKey, update } = useUpdate();
|
|
28
|
+
const updatePlace = (value: Point) => {
|
|
29
|
+
pointRef.value = value;
|
|
30
|
+
update();
|
|
31
|
+
};
|
|
32
|
+
const setPlace = (value: Place) => {
|
|
33
|
+
place.lng = value.lng;
|
|
34
|
+
place.lat = value.lat;
|
|
35
|
+
place.name = value.name;
|
|
36
|
+
};
|
|
22
37
|
watch(
|
|
23
38
|
() => placeKey.value,
|
|
24
39
|
async () => {
|
|
@@ -33,15 +48,12 @@ export const useAmapPlace = (props: UseMapPlaceProps) => {
|
|
|
33
48
|
const cityName = addressComponent.city
|
|
34
49
|
? addressComponent.city
|
|
35
50
|
: addressComponent.province;
|
|
36
|
-
const countryName = addressComponent.country;
|
|
37
51
|
const cityParentName = addressComponent.province;
|
|
38
52
|
place.name = name;
|
|
39
53
|
place.lng = lng;
|
|
40
54
|
place.lat = lat;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
place.countryName = countryName;
|
|
44
|
-
onChange?.({ lng, lat, name, cityName, cityParentName, countryName });
|
|
55
|
+
onChange?.({ lng, lat, name });
|
|
56
|
+
onChangeCity?.({ cityName, cityParentName });
|
|
45
57
|
return;
|
|
46
58
|
}
|
|
47
59
|
|
|
@@ -55,14 +67,23 @@ export const useAmapPlace = (props: UseMapPlaceProps) => {
|
|
|
55
67
|
});
|
|
56
68
|
}
|
|
57
69
|
);
|
|
58
|
-
return { place, updatePlace };
|
|
70
|
+
return { place, updatePlace, setPlace };
|
|
59
71
|
};
|
|
60
72
|
|
|
61
73
|
export const useGmapPlace = (props: UseMapPlaceProps) => {
|
|
62
|
-
const { pointRef, onChange } = props;
|
|
74
|
+
const { pointRef, onChange, onChangeCity } = props;
|
|
63
75
|
const { readyPromise } = useMapSupplier();
|
|
64
76
|
const { idx: placeKey, update: updatePlace } = useUpdate();
|
|
65
|
-
const place = reactive<Place>({
|
|
77
|
+
const place = reactive<Place>({
|
|
78
|
+
lng: pointRef.value[0],
|
|
79
|
+
lat: pointRef.value[1],
|
|
80
|
+
name: "",
|
|
81
|
+
});
|
|
82
|
+
const setPlace = (value: Place) => {
|
|
83
|
+
place.lng = value.lng;
|
|
84
|
+
place.lat = value.lat;
|
|
85
|
+
place.name = value.name;
|
|
86
|
+
};
|
|
66
87
|
watch(
|
|
67
88
|
() => placeKey.value,
|
|
68
89
|
async () => {
|
|
@@ -73,17 +94,15 @@ export const useGmapPlace = (props: UseMapPlaceProps) => {
|
|
|
73
94
|
const name = results[0].formatted_address;
|
|
74
95
|
const cityName = geocoderResult2cityName(results[0]);
|
|
75
96
|
const cityParentName = results.slice(-2)[0].address_components[0].long_name;
|
|
76
|
-
const countryName = results.slice(-1)[0].address_components[0].long_name;
|
|
97
|
+
// const countryName = results.slice(-1)[0].address_components[0].long_name;
|
|
77
98
|
place.lng = lng;
|
|
78
99
|
place.lat = lat;
|
|
79
100
|
place.name = name;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
place.countryName = countryName;
|
|
83
|
-
onChange?.({ lng, lat, name, cityName, cityParentName, countryName });
|
|
101
|
+
onChange?.({ lng, lat, name });
|
|
102
|
+
onChangeCity?.({ cityName, cityParentName });
|
|
84
103
|
}
|
|
85
104
|
);
|
|
86
|
-
return { place, updatePlace };
|
|
105
|
+
return { place, updatePlace, setPlace };
|
|
87
106
|
};
|
|
88
107
|
|
|
89
108
|
export const useMapPlace = (props: UseMapPlaceProps) => {
|
|
@@ -35,16 +35,22 @@ export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
|
|
|
35
35
|
getLimit: (context?: C) => number;
|
|
36
36
|
// 如果返回 undefined, 表示当前位置无服务可提供
|
|
37
37
|
getRecomendPlace: (place: Place, context?: C) => Promise<Place[] | undefined>;
|
|
38
|
+
onChangeCity?: UseMapPlaceProps["onChangeCity"];
|
|
38
39
|
onChangePlace?: UseMapPlaceProps["onChange"];
|
|
39
40
|
onChange?: (place: Place) => any;
|
|
40
41
|
}
|
|
41
42
|
export const useAmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
|
|
42
|
-
const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace } =
|
|
43
|
+
const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace, onChangeCity } =
|
|
44
|
+
props;
|
|
43
45
|
const availableRef = ref(true);
|
|
44
46
|
const placeCandidatesRef = ref<Place[]>([]);
|
|
45
47
|
const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
|
|
46
48
|
const { readyPromise } = useMapSupplier();
|
|
47
|
-
const { place, updatePlace } = useAmapPlace({
|
|
49
|
+
const { place, updatePlace, setPlace } = useAmapPlace({
|
|
50
|
+
pointRef,
|
|
51
|
+
onChange: onChangePlace,
|
|
52
|
+
onChangeCity,
|
|
53
|
+
});
|
|
48
54
|
const recomendPlace = reactive<Place>({ ...place });
|
|
49
55
|
watch(
|
|
50
56
|
() => recomendPlaceKey.value,
|
|
@@ -73,16 +79,22 @@ export const useAmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
|
|
|
73
79
|
availableRef,
|
|
74
80
|
updateRecomandPlace,
|
|
75
81
|
updatePlace,
|
|
82
|
+
setPlace,
|
|
76
83
|
};
|
|
77
84
|
};
|
|
78
85
|
|
|
79
86
|
export const useGmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
|
|
80
|
-
const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace } =
|
|
87
|
+
const { pointRef, getRecomendPlace, getLimit, context, onChange, onChangePlace, onChangeCity } =
|
|
88
|
+
props;
|
|
81
89
|
const availableRef = ref(true);
|
|
82
90
|
const placeCandidatesRef = ref<Place[]>([]);
|
|
83
91
|
const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
|
|
84
92
|
const { readyPromise } = useMapSupplier();
|
|
85
|
-
const { place, updatePlace } = useGmapPlace({
|
|
93
|
+
const { place, updatePlace, setPlace } = useGmapPlace({
|
|
94
|
+
pointRef,
|
|
95
|
+
onChange: onChangePlace,
|
|
96
|
+
onChangeCity,
|
|
97
|
+
});
|
|
86
98
|
const recomendPlace = reactive<Place>({ ...place });
|
|
87
99
|
watch(
|
|
88
100
|
() => recomendPlaceKey.value,
|
|
@@ -111,6 +123,7 @@ export const useGmapRecomendPlace = <C>(props: UseMapRecomendPlaceProps<C>) => {
|
|
|
111
123
|
availableRef,
|
|
112
124
|
updateRecomandPlace,
|
|
113
125
|
updatePlace,
|
|
126
|
+
setPlace,
|
|
114
127
|
};
|
|
115
128
|
};
|
|
116
129
|
|
|
@@ -4,7 +4,7 @@ import type { Place, Point } from "../types/interface";
|
|
|
4
4
|
|
|
5
5
|
export interface BusinessRecomendPlaceContext {
|
|
6
6
|
panToGeoPositionByRecomend: (value: Point) => void;
|
|
7
|
-
|
|
7
|
+
setCenterPlaceByUserSpecified: (value: Place) => void;
|
|
8
8
|
onChangeCenterPlace: (value: Place) => void;
|
|
9
9
|
onChangeRecomendPlaces: (value: Place[]) => void;
|
|
10
10
|
}
|
|
@@ -14,17 +14,17 @@ export const useBusinessRecomendPlaceMap = () => {
|
|
|
14
14
|
lng: 0,
|
|
15
15
|
lat: 0,
|
|
16
16
|
name: "",
|
|
17
|
-
cityName: undefined,
|
|
18
17
|
});
|
|
19
18
|
const placeCandidates = ref<Place[]>([]);
|
|
20
19
|
const { apiMapDistance } = useMapGeometry();
|
|
21
20
|
const panToGeoPositionByRecomend = (value: Point) => mapContext.panToGeoPositionByRecomend(value);
|
|
22
|
-
const
|
|
21
|
+
const setCenterPlaceByUserSpecified = (value: Place) =>
|
|
22
|
+
mapContext.setCenterPlaceByUserSpecified(value);
|
|
23
23
|
const mapContext: BusinessRecomendPlaceContext = {
|
|
24
24
|
panToGeoPositionByRecomend: () => {
|
|
25
25
|
throw new Error("MyError: panToGeoPositionByRecomend used before assigned");
|
|
26
26
|
},
|
|
27
|
-
|
|
27
|
+
setCenterPlaceByUserSpecified: () => {
|
|
28
28
|
throw new Error("MyError: setCenterPlaceByRecomand used before assigned");
|
|
29
29
|
},
|
|
30
30
|
onChangeCenterPlace: (place: Place) => {
|
|
@@ -39,7 +39,7 @@ export const useBusinessRecomendPlaceMap = () => {
|
|
|
39
39
|
centerPlace,
|
|
40
40
|
placeCandidates,
|
|
41
41
|
panToGeoPositionByRecomend,
|
|
42
|
-
|
|
42
|
+
setCenterPlaceByUserSpecified,
|
|
43
43
|
apiMapDistance,
|
|
44
44
|
};
|
|
45
45
|
};
|