@heycar/heycars-map 0.1.0
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/.eslintrc.json +15 -0
- package/README.md +18 -0
- package/dist/App.d.ts +1 -0
- package/dist/api/driving.d.ts +12 -0
- package/dist/api/geocoder.d.ts +16 -0
- package/dist/api/geometry.d.ts +20 -0
- package/dist/api/place.d.ts +16 -0
- package/dist/business-components/AddressBox/AddressBox.css.d.ts +7 -0
- package/dist/business-components/AddressBox/AddressBox.d.ts +10 -0
- package/dist/business-components/AddressBox/index.d.ts +1 -0
- package/dist/business-components/AddressLocator/AddressLocator.css.d.ts +1 -0
- package/dist/business-components/AddressLocator/AddressLocator.d.ts +7 -0
- package/dist/business-components/AddressLocator/index.d.ts +1 -0
- package/dist/business-components/DrivingLine/DrivingLine.css.d.ts +1 -0
- package/dist/business-components/DrivingLine/DrivingLine.d.ts +6 -0
- package/dist/business-components/DrivingLine/index.d.ts +1 -0
- package/dist/business-components/PassengerCircle/PassengerCircle.css.d.ts +1 -0
- package/dist/business-components/PassengerCircle/PassengerCircle.d.ts +7 -0
- package/dist/business-components/PassengerCircle/index.d.ts +1 -0
- package/dist/business-components/PlaceCircle/PlaceCircle.css.d.ts +5 -0
- package/dist/business-components/PlaceCircle/PlaceCircle.d.ts +8 -0
- package/dist/business-components/PlaceCircle/index.d.ts +1 -0
- package/dist/business-components/StartEndPoint/StartEndPoint.css.d.ts +20 -0
- package/dist/business-components/StartEndPoint/StartEndPoint.d.ts +9 -0
- package/dist/business-components/StartEndPoint/index.d.ts +1 -0
- package/dist/business-components/TaxiCar/TaxiCar.css.d.ts +3 -0
- package/dist/business-components/TaxiCar/TaxiCar.d.ts +8 -0
- package/dist/business-components/TaxiCar/index.d.ts +1 -0
- package/dist/business-components/WalkingLine/WalkingLine.d.ts +6 -0
- package/dist/business-components/WalkingLine/index.d.ts +1 -0
- package/dist/business-components/WaveCircle/WaveCircle.css.d.ts +4 -0
- package/dist/business-components/WaveCircle/WaveCircle.d.ts +6 -0
- package/dist/business-components/WaveCircle/index.d.ts +1 -0
- package/dist/components/Amap/Amap.css.d.ts +1 -0
- package/dist/components/Amap/Amap.d.ts +7 -0
- package/dist/components/Amap/index.d.ts +1 -0
- package/dist/components/Amap/useAmap.d.ts +399 -0
- package/dist/components/AmapInfoWindow/AmapInfoWindow.d.ts +4 -0
- package/dist/components/AmapInfoWindow/index.d.ts +1 -0
- package/dist/components/AmapLoader/AmapLoader.d.ts +20 -0
- package/dist/components/AmapLoader/index.d.ts +1 -0
- package/dist/components/AmapMarker/AmapMarker.d.ts +2 -0
- package/dist/components/AmapMarker/index.d.ts +1 -0
- package/dist/components/AmapPolygon/AmapPolygon.d.ts +2 -0
- package/dist/components/AmapPolygon/index.d.ts +1 -0
- package/dist/components/AmapPolyline/AmapPolyline.d.ts +2 -0
- package/dist/components/AmapPolyline/index.d.ts +1 -0
- package/dist/components/AmapText/AmapText.d.ts +2 -0
- package/dist/components/AmapText/index.d.ts +1 -0
- package/dist/components/Demo/BusinessDemo.d.ts +2 -0
- package/dist/components/Demo/Demo.css.d.ts +1 -0
- package/dist/components/Demo/Demo.d.ts +2 -0
- package/dist/components/Demo/Hello.d.ts +17 -0
- package/dist/components/Demo/HeycarDemo.d.ts +1 -0
- package/dist/components/Demo/index.d.ts +1 -0
- package/dist/components/Gmap/Gmap.d.ts +5 -0
- package/dist/components/Gmap/index.d.ts +1 -0
- package/dist/components/Gmap/useGmap.d.ts +5 -0
- package/dist/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.d.ts +3 -0
- package/dist/components/GmapAdvancedMarkerView/index.d.ts +1 -0
- package/dist/components/GmapInfoWindow/GmapInfoWindow.d.ts +5 -0
- package/dist/components/GmapInfoWindow/index.d.ts +1 -0
- package/dist/components/GmapLoader/GmapLoader.d.ts +37 -0
- package/dist/components/GmapLoader/index.d.ts +1 -0
- package/dist/components/GmapMarker/GmapMarker.d.ts +3 -0
- package/dist/components/GmapMarker/index.d.ts +1 -0
- package/dist/components/GmapPolygon/GmapPolygon.d.ts +3 -0
- package/dist/components/GmapPolygon/index.d.ts +1 -0
- package/dist/components/GmapPolyline/GmapPolyline.d.ts +3 -0
- package/dist/components/GmapPolyline/index.d.ts +1 -0
- package/dist/components/MapProvider/MapProvider.d.ts +7 -0
- package/dist/components/MapProvider/index.d.ts +1 -0
- package/dist/components/MapProvider/useMapSupplier.d.ts +11 -0
- package/dist/index.cjs +70 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1498 -0
- package/dist/main.d.ts +1 -0
- package/dist/style.css +1 -0
- package/dist/types/amap/marker.d.ts +11 -0
- package/dist/types/helper.d.ts +30 -0
- package/dist/types/interface.d.ts +1 -0
- package/dist/utils/compare.d.ts +21 -0
- package/dist/utils/dom.d.ts +2 -0
- package/dist/utils/transform.d.ts +9 -0
- package/dist/vite.svg +1 -0
- package/esbuild.mjs +40 -0
- package/index.html +13 -0
- package/package.json +94 -0
- package/public/vite.svg +1 -0
- package/src/App.tsx +10 -0
- package/src/api/driving.ts +87 -0
- package/src/api/geocoder.ts +88 -0
- package/src/api/geometry.ts +44 -0
- package/src/api/place.ts +107 -0
- package/src/assets/icons/svg/address-locator.svg +1 -0
- package/src/assets/icons/svg/arrow-right.svg +1 -0
- package/src/assets/icons/svg/end-point.svg +1 -0
- package/src/assets/icons/svg/passenger-circle.svg +1 -0
- package/src/assets/icons/svg/place-circle.svg +22 -0
- package/src/assets/icons/svg/start-point.svg +1 -0
- package/src/assets/icons/svg/taxi-car.svg +1 -0
- package/src/assets/icons/svg/wave-circle.svg +1 -0
- package/src/business-components/AddressBox/AddressBox.css.ts +55 -0
- package/src/business-components/AddressBox/AddressBox.tsx +69 -0
- package/src/business-components/AddressBox/index.ts +1 -0
- package/src/business-components/AddressLocator/AddressLocator.css.ts +7 -0
- package/src/business-components/AddressLocator/AddressLocator.tsx +40 -0
- package/src/business-components/AddressLocator/index.ts +1 -0
- package/src/business-components/DrivingLine/DrivingLine.css.ts +10 -0
- package/src/business-components/DrivingLine/DrivingLine.tsx +124 -0
- package/src/business-components/DrivingLine/index.ts +1 -0
- package/src/business-components/PassengerCircle/PassengerCircle.css.ts +8 -0
- package/src/business-components/PassengerCircle/PassengerCircle.tsx +42 -0
- package/src/business-components/PassengerCircle/index.ts +1 -0
- package/src/business-components/PlaceCircle/PlaceCircle.css.ts +30 -0
- package/src/business-components/PlaceCircle/PlaceCircle.tsx +66 -0
- package/src/business-components/PlaceCircle/index.ts +1 -0
- package/src/business-components/StartEndPoint/StartEndPoint.css.ts +70 -0
- package/src/business-components/StartEndPoint/StartEndPoint.tsx +103 -0
- package/src/business-components/StartEndPoint/index.ts +1 -0
- package/src/business-components/TaxiCar/TaxiCar.css.ts +16 -0
- package/src/business-components/TaxiCar/TaxiCar.tsx +77 -0
- package/src/business-components/TaxiCar/index.ts +1 -0
- package/src/business-components/WalkingLine/WalkingLine.tsx +73 -0
- package/src/business-components/WalkingLine/index.ts +1 -0
- package/src/business-components/WaveCircle/WaveCircle.css.ts +54 -0
- package/src/business-components/WaveCircle/WaveCircle.tsx +56 -0
- package/src/business-components/WaveCircle/index.ts +1 -0
- package/src/components/Amap/Amap.css.ts +3 -0
- package/src/components/Amap/Amap.ts +58 -0
- package/src/components/Amap/index.ts +1 -0
- package/src/components/Amap/useAmap.ts +9 -0
- package/src/components/AmapInfoWindow/AmapInfoWindow.ts +45 -0
- package/src/components/AmapInfoWindow/index.ts +1 -0
- package/src/components/AmapLoader/AmapLoader.ts +68 -0
- package/src/components/AmapLoader/index.ts +1 -0
- package/src/components/AmapMarker/AmapMarker.ts +38 -0
- package/src/components/AmapMarker/index.ts +1 -0
- package/src/components/AmapPolygon/AmapPolygon.ts +41 -0
- package/src/components/AmapPolygon/index.ts +1 -0
- package/src/components/AmapPolyline/AmapPolyline.ts +40 -0
- package/src/components/AmapPolyline/index.ts +1 -0
- package/src/components/AmapText/AmapText.ts +39 -0
- package/src/components/AmapText/index.ts +1 -0
- package/src/components/Demo/BusinessDemo.tsx +117 -0
- package/src/components/Demo/Demo.css.ts +6 -0
- package/src/components/Demo/Demo.tsx +97 -0
- package/src/components/Demo/Hello.tsx +15 -0
- package/src/components/Demo/HeycarDemo.tsx +31 -0
- package/src/components/Demo/TemplateDemo.vue +11 -0
- package/src/components/Demo/index.ts +1 -0
- package/src/components/Gmap/Gmap.ts +34 -0
- package/src/components/Gmap/index.ts +1 -0
- package/src/components/Gmap/useGmap.ts +7 -0
- package/src/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.ts +48 -0
- package/src/components/GmapAdvancedMarkerView/index.ts +1 -0
- package/src/components/GmapInfoWindow/GmapInfoWindow.ts +38 -0
- package/src/components/GmapInfoWindow/index.ts +1 -0
- package/src/components/GmapLoader/GmapLoader.ts +79 -0
- package/src/components/GmapLoader/index.ts +1 -0
- package/src/components/GmapMarker/GmapMarker.ts +31 -0
- package/src/components/GmapMarker/index.ts +1 -0
- package/src/components/GmapPolygon/GmapPolygon.ts +29 -0
- package/src/components/GmapPolygon/index.ts +1 -0
- package/src/components/GmapPolyline/GmapPolyline.ts +29 -0
- package/src/components/GmapPolyline/index.ts +1 -0
- package/src/components/MapProvider/MapProvider.tsx +64 -0
- package/src/components/MapProvider/index.ts +1 -0
- package/src/components/MapProvider/useMapSupplier.ts +19 -0
- package/src/index.ts +14 -0
- package/src/main.ts +6 -0
- package/src/style.css +0 -0
- package/src/types/amap/autocomplete.d.ts +64 -0
- package/src/types/amap/driving.d.ts +168 -0
- package/src/types/amap/geocoder.d.ts +214 -0
- package/src/types/amap/marker.ts +11 -0
- package/src/types/amap/place.d.ts +114 -0
- package/src/types/amap/plugin.d.ts +27 -0
- package/src/types/amap/walking.d.ts +76 -0
- package/src/types/global.d.ts +10 -0
- package/src/types/helper.ts +139 -0
- package/src/types/interface.ts +1 -0
- package/src/utils/compare.ts +174 -0
- package/src/utils/dom.ts +14 -0
- package/src/utils/transform.ts +27 -0
- package/src/vite-env.d.ts +12 -0
- package/todo.md +1 -0
- package/tsconfig.json +25 -0
- package/tsconfig.node.json +9 -0
- package/vite.config.dev.ts +17 -0
- package/vite.config.ts +40 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./StartEndPoint";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { style } from "@vanilla-extract/css";
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
pointInfoBoxEmphasize,
|
|
5
|
+
pointLayout,
|
|
6
|
+
pointSingleInfoBox,
|
|
7
|
+
} from "../StartEndPoint/StartEndPoint.css";
|
|
8
|
+
|
|
9
|
+
export const taxiCarLayout = style({});
|
|
10
|
+
|
|
11
|
+
export const carIcon = style({
|
|
12
|
+
marginTop: "1.87vw",
|
|
13
|
+
marginBottom: "-5.5vw",
|
|
14
|
+
width: "6vw",
|
|
15
|
+
height: "11vw",
|
|
16
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { computed } from "vue-demi";
|
|
2
|
+
import imgTaxicar from "../../assets/icons/svg/taxi-car.svg";
|
|
3
|
+
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
|
+
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView/GmapAdvancedMarkerView";
|
|
5
|
+
import { useMapSupplier } from "../../components/MapProvider/useMapSupplier";
|
|
6
|
+
import { createElement, defineSetup } from "../../types/helper";
|
|
7
|
+
import { createDom } from "../../utils/dom";
|
|
8
|
+
import { decodeAsterisk, vec2lnglat } from "../../utils/transform";
|
|
9
|
+
import * as css from "./TaxiCar.css";
|
|
10
|
+
|
|
11
|
+
export interface TaxiCarProps {
|
|
12
|
+
position: [number, number];
|
|
13
|
+
angle?: number;
|
|
14
|
+
title?: string;
|
|
15
|
+
}
|
|
16
|
+
export const ATaxiCar = defineSetup(function ATaxiCar(props: TaxiCarProps) {
|
|
17
|
+
const contentRef = computed(() => {
|
|
18
|
+
const titleRow = !props.title
|
|
19
|
+
? ""
|
|
20
|
+
: decodeAsterisk(props.title)
|
|
21
|
+
.map((item) =>
|
|
22
|
+
item.type === "normal"
|
|
23
|
+
? item.value
|
|
24
|
+
: `<span class="${css.pointInfoBoxEmphasize}">${item.value}</span>`
|
|
25
|
+
)
|
|
26
|
+
.join("");
|
|
27
|
+
if (!props.title) return `<img src="${imgTaxicar}" class="${css.carIcon}">`;
|
|
28
|
+
const carStyle = `transform:rotate(${props.angle ?? 0}deg)`;
|
|
29
|
+
return `
|
|
30
|
+
<div class="${css.pointLayout}">
|
|
31
|
+
<div class="${css.pointSingleInfoBox}">${titleRow}</div>
|
|
32
|
+
<img src="${imgTaxicar}" class="${css.carIcon}" style="${carStyle}">
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
});
|
|
36
|
+
return () => (
|
|
37
|
+
<AmapMarker position={props.position} content={contentRef.value} anchor={"bottom-center"} />
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const GTaxiCar = defineSetup(function GTaxiCar(props: TaxiCarProps) {
|
|
42
|
+
const contentRef = computed(() => {
|
|
43
|
+
const titleRow = !props.title
|
|
44
|
+
? ""
|
|
45
|
+
: decodeAsterisk(props.title)
|
|
46
|
+
.map((item) =>
|
|
47
|
+
item.type === "normal"
|
|
48
|
+
? item.value
|
|
49
|
+
: `<span class="${css.pointInfoBoxEmphasize}">${item.value}</span>`
|
|
50
|
+
)
|
|
51
|
+
.join("");
|
|
52
|
+
if (!props.title) return createDom("img", { class: css.carIcon, src: imgTaxicar });
|
|
53
|
+
const carStyle = `transform:rotate(${props.angle ?? 0}deg)`;
|
|
54
|
+
return createDom(
|
|
55
|
+
"div",
|
|
56
|
+
{ class: css.pointLayout },
|
|
57
|
+
`
|
|
58
|
+
<div class="${css.pointSingleInfoBox}">${titleRow}</div>
|
|
59
|
+
<img src="${imgTaxicar}" class="${css.carIcon}" style="${carStyle}">
|
|
60
|
+
`
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
return () => {
|
|
64
|
+
return (
|
|
65
|
+
<GmapAdvancedMarkerView position={vec2lnglat(props.position)} content={contentRef.value} />
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const TaxiCar = defineSetup(function TaxiCar(props: TaxiCarProps) {
|
|
71
|
+
const payload = useMapSupplier();
|
|
72
|
+
return () => {
|
|
73
|
+
return createElement(payload.supplier === "gmap" ? GTaxiCar : ATaxiCar, {
|
|
74
|
+
attrs: props,
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TaxiCar";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { computed } from "vue-demi";
|
|
2
|
+
import { AmapPolyline } from "../../components/AmapPolyline";
|
|
3
|
+
import { GmapPolyline } from "../../components/GmapPolyline";
|
|
4
|
+
import { useMapSupplier } from "../../components/MapProvider/useMapSupplier";
|
|
5
|
+
import { createElement, defineSetup } from "../../types/helper";
|
|
6
|
+
import { vec2lnglat } from "../../utils/transform";
|
|
7
|
+
|
|
8
|
+
export interface WalkingLineProps {
|
|
9
|
+
path: [number, number][];
|
|
10
|
+
}
|
|
11
|
+
export const AWalkingLine = defineSetup(function AWalkingLine(props: WalkingLineProps) {
|
|
12
|
+
return () => {
|
|
13
|
+
const vw = window.innerWidth * 0.01;
|
|
14
|
+
const strokeWidth = 2 * vw;
|
|
15
|
+
return (
|
|
16
|
+
<AmapPolyline
|
|
17
|
+
path={props.path}
|
|
18
|
+
strokeWeight={strokeWidth}
|
|
19
|
+
strokeOpacity={1}
|
|
20
|
+
strokeColor={"#38A3FE"}
|
|
21
|
+
strokeStyle="dashed"
|
|
22
|
+
strokeDasharray={[strokeWidth, strokeWidth * 1.5]}
|
|
23
|
+
lineJoin={"round"}
|
|
24
|
+
lineCap={"round"}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const GWalkingLine = defineSetup(function GWalkingLine(props: WalkingLineProps) {
|
|
31
|
+
const pathRef = computed(() => props.path.map(vec2lnglat));
|
|
32
|
+
return () => {
|
|
33
|
+
const vw = window.innerWidth * 0.01;
|
|
34
|
+
const strokeWidth = 2 * vw;
|
|
35
|
+
const r = strokeWidth / 4;
|
|
36
|
+
return (
|
|
37
|
+
<GmapPolyline
|
|
38
|
+
path={pathRef.value}
|
|
39
|
+
strokeWeight={strokeWidth}
|
|
40
|
+
strokeOpacity={1}
|
|
41
|
+
strokeColor={"transparent"}
|
|
42
|
+
icons={[
|
|
43
|
+
{
|
|
44
|
+
icon: {
|
|
45
|
+
path: `
|
|
46
|
+
M ${r}, ${r}
|
|
47
|
+
m -${r}, 0
|
|
48
|
+
a ${r},${r} 0 1,0 ${2 * r},0
|
|
49
|
+
a ${r},${r} 0 1,0 -${2 * r},0
|
|
50
|
+
`,
|
|
51
|
+
strokeColor: "#38A3FE",
|
|
52
|
+
fillColor: "#38A3FE",
|
|
53
|
+
fillOpacity: 1,
|
|
54
|
+
strokeOpacity: 1,
|
|
55
|
+
strokeWeight: strokeWidth / 2,
|
|
56
|
+
scale: 1,
|
|
57
|
+
},
|
|
58
|
+
repeat: `${strokeWidth * 2}px`,
|
|
59
|
+
},
|
|
60
|
+
]}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const WalkingLine = defineSetup(function WalkingLine(props: WalkingLineProps) {
|
|
67
|
+
const payload = useMapSupplier();
|
|
68
|
+
return () => {
|
|
69
|
+
return createElement(payload.supplier === "gmap" ? GWalkingLine : AWalkingLine, {
|
|
70
|
+
attrs: props,
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./WalkingLine";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { keyframes, style } from "@vanilla-extract/css";
|
|
2
|
+
|
|
3
|
+
export const waveAnimationFirst = keyframes({
|
|
4
|
+
"0%": {
|
|
5
|
+
transform: "scale(0)",
|
|
6
|
+
opacity: 1,
|
|
7
|
+
},
|
|
8
|
+
"33.33%": {
|
|
9
|
+
transform: "scale(0.5)",
|
|
10
|
+
opacity: 1,
|
|
11
|
+
},
|
|
12
|
+
"66.66%": {
|
|
13
|
+
transform: "scale(1)",
|
|
14
|
+
opacity: 0,
|
|
15
|
+
},
|
|
16
|
+
"100%": {
|
|
17
|
+
transform: "scale(1)",
|
|
18
|
+
opacity: 0,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const waveAnimationSecond = keyframes({
|
|
23
|
+
"0%": {
|
|
24
|
+
transform: "scale(0)",
|
|
25
|
+
opacity: 0,
|
|
26
|
+
},
|
|
27
|
+
"33.33%": {
|
|
28
|
+
transform: "scale(0)",
|
|
29
|
+
opacity: 1,
|
|
30
|
+
},
|
|
31
|
+
"66.66%": {
|
|
32
|
+
transform: "scale(0.5)",
|
|
33
|
+
opacity: 1,
|
|
34
|
+
},
|
|
35
|
+
"100%": {
|
|
36
|
+
transform: "scale(1)",
|
|
37
|
+
opacity: 0,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const waveCircle = style({
|
|
42
|
+
display: "flex",
|
|
43
|
+
marginBottom: "-30.935vw",
|
|
44
|
+
width: "61.87vw",
|
|
45
|
+
height: "61.87vw",
|
|
46
|
+
animationName: waveAnimationFirst,
|
|
47
|
+
animationDuration: "3s",
|
|
48
|
+
animationIterationCount: "infinite",
|
|
49
|
+
animationTimingFunction: "linear",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const secondCircle = style({
|
|
53
|
+
animationName: waveAnimationSecond,
|
|
54
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { computed } from "vue-demi";
|
|
2
|
+
import imgWaveCircle from "../../assets/icons/svg/wave-circle.svg";
|
|
3
|
+
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
|
+
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView";
|
|
5
|
+
import { useMapSupplier } from "../../components/MapProvider/useMapSupplier";
|
|
6
|
+
import { createElement, defineSetup } from "../../types/helper";
|
|
7
|
+
import { createDom } from "../../utils/dom";
|
|
8
|
+
import { vec2lnglat } from "../../utils/transform";
|
|
9
|
+
import * as css from "./WaveCircle.css";
|
|
10
|
+
|
|
11
|
+
export interface WaveCircleProps {
|
|
12
|
+
position: [number, number];
|
|
13
|
+
}
|
|
14
|
+
export const AWaveCircle = defineSetup(function AWaveCircle(props: WaveCircleProps) {
|
|
15
|
+
const contentRef = computed(() => `<img src="${imgWaveCircle}" class="${css.waveCircle}">`);
|
|
16
|
+
const contentAnotherRef = computed(
|
|
17
|
+
() => `<img src="${imgWaveCircle}" class="${css.waveCircle} ${css.secondCircle}">`
|
|
18
|
+
);
|
|
19
|
+
return () => (
|
|
20
|
+
<div>
|
|
21
|
+
<AmapMarker position={props.position} anchor="bottom-center" content={contentRef.value} />
|
|
22
|
+
<AmapMarker
|
|
23
|
+
position={props.position}
|
|
24
|
+
anchor="bottom-center"
|
|
25
|
+
content={contentAnotherRef.value}
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const GWaveCircle = defineSetup(function AWaveCircle(props: WaveCircleProps) {
|
|
32
|
+
const contentRef = computed(() =>
|
|
33
|
+
createDom("img", { class: css.waveCircle, src: imgWaveCircle })
|
|
34
|
+
);
|
|
35
|
+
const contentAnotherRef = computed(() =>
|
|
36
|
+
createDom("img", { class: `${css.waveCircle} ${css.secondCircle}`, src: imgWaveCircle })
|
|
37
|
+
);
|
|
38
|
+
return () => {
|
|
39
|
+
const position = vec2lnglat(props.position);
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<GmapAdvancedMarkerView position={position} content={contentRef.value} />
|
|
43
|
+
<GmapAdvancedMarkerView position={position} content={contentAnotherRef.value} />
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const WaveCircle = defineSetup(function WaveCircle(props: WaveCircleProps) {
|
|
50
|
+
const payload = useMapSupplier();
|
|
51
|
+
return () => {
|
|
52
|
+
return createElement(payload.supplier === "gmap" ? GWaveCircle : AWaveCircle, {
|
|
53
|
+
attrs: props,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./WaveCircle";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { computed, h, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { defineSetup } from "../../types/helper";
|
|
3
|
+
import {
|
|
4
|
+
watchNoneImmediatePostEffectForDeepOption,
|
|
5
|
+
watchNoneImmediatePostEffectForMapProperty,
|
|
6
|
+
watchPostEffectForAMapEvent,
|
|
7
|
+
} from "../../utils/compare";
|
|
8
|
+
import * as css from "./Amap.css";
|
|
9
|
+
import { provideAmap } from "./useAmap";
|
|
10
|
+
|
|
11
|
+
export interface AmapProps extends AMap.MapOptions {
|
|
12
|
+
onMapMove?: (e: { type: "mapmove"; target: AMap.Map }) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const Amap = defineSetup(function Amap(props: AmapProps, { slots, emit }) {
|
|
16
|
+
const { onMapMove, ...defaultOptions } = props;
|
|
17
|
+
const statusOptions = computed(() => {
|
|
18
|
+
return {
|
|
19
|
+
dragEnable: !!props.dragEnable,
|
|
20
|
+
zoomEnable: !!props.zoomEnable,
|
|
21
|
+
jogEnable: !!props.jogEnable,
|
|
22
|
+
pitchEnable: !!props.pitchEnable,
|
|
23
|
+
rotateEnable: !!props.rotateEnable,
|
|
24
|
+
animateEnable: !!props.animateEnable,
|
|
25
|
+
keyboardEnable: !!props.keyboardEnable,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const elementRef = shallowRef();
|
|
29
|
+
const mapRef = shallowRef<AMap.Map>();
|
|
30
|
+
provideAmap(mapRef);
|
|
31
|
+
watchPostEffect(() => {
|
|
32
|
+
// todo 这里是否会因为 mapRef 的赋值导致不停运行?
|
|
33
|
+
if (mapRef.value || !elementRef.value) return;
|
|
34
|
+
mapRef.value = new AMap.Map(elementRef.value, { ...defaultOptions });
|
|
35
|
+
});
|
|
36
|
+
watchNoneImmediatePostEffectForDeepOption(
|
|
37
|
+
() => statusOptions.value,
|
|
38
|
+
(statusOptions) => {
|
|
39
|
+
mapRef.value?.setStatus(statusOptions);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
watchNoneImmediatePostEffectForMapProperty(mapRef, props, [
|
|
43
|
+
{ name: "center", defaultValue: [0, 0] },
|
|
44
|
+
{ name: "zooms", defaultValue: [0, 0] },
|
|
45
|
+
{ name: "zoom", defaultValue: 0 },
|
|
46
|
+
{ name: "layers", defaultValue: [] },
|
|
47
|
+
{ name: "limitBounds", defaultValue: [] },
|
|
48
|
+
{ name: "rotation", defaultValue: 0 },
|
|
49
|
+
{ name: "defaultCursor", defaultValue: "" },
|
|
50
|
+
{ name: "mapStyle", defaultValue: "" },
|
|
51
|
+
{ name: "features", defaultValue: [] },
|
|
52
|
+
{ name: "pitch", defaultValue: 0 },
|
|
53
|
+
{ name: "mask", defaultValue: [] },
|
|
54
|
+
{ name: "labelRejectMask", defaultValue: false },
|
|
55
|
+
]);
|
|
56
|
+
watchPostEffectForAMapEvent(mapRef, props, emit, ["onMapMove"]);
|
|
57
|
+
return () => h("div", { ref: elementRef, class: css.amap }, slots.default?.());
|
|
58
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Amap";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { inject, provide, ShallowRef } from "vue-demi";
|
|
2
|
+
|
|
3
|
+
export const amapContext = Symbol();
|
|
4
|
+
|
|
5
|
+
export const useAmap = () => {
|
|
6
|
+
return inject<ShallowRef<AMap.Map | undefined>>(amapContext);
|
|
7
|
+
};
|
|
8
|
+
export const provideAmap = (mapRef: ShallowRef<AMap.Map | undefined>) =>
|
|
9
|
+
provide(amapContext, mapRef);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { computed, onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { defineSetup } from "../../types/helper";
|
|
3
|
+
import { watchNoneImmediatePostEffectForMapProperty } from "../../utils/compare";
|
|
4
|
+
import { useAmap } from "../Amap/useAmap";
|
|
5
|
+
|
|
6
|
+
export interface AmapInfoWindowProps extends AMap.InfoOptions {
|
|
7
|
+
visible: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const AmapInfoWindow = defineSetup(function AmapInfoWindow(props: AmapInfoWindowProps) {
|
|
11
|
+
const options = computed(() => {
|
|
12
|
+
const { visible, ...options } = props;
|
|
13
|
+
return options;
|
|
14
|
+
});
|
|
15
|
+
const defaultOptions = options.value;
|
|
16
|
+
const infoWindowRef = shallowRef<AMap.InfoWindow>();
|
|
17
|
+
const mapRef = useAmap();
|
|
18
|
+
onMounted(() => {
|
|
19
|
+
infoWindowRef.value = new AMap.InfoWindow({ ...defaultOptions });
|
|
20
|
+
});
|
|
21
|
+
onUnmounted(() => {
|
|
22
|
+
infoWindowRef.value?.close();
|
|
23
|
+
});
|
|
24
|
+
watchPostEffect(() => {
|
|
25
|
+
const { visible } = props;
|
|
26
|
+
const infoWindow = infoWindowRef.value;
|
|
27
|
+
const map = mapRef?.value;
|
|
28
|
+
if (!map || !infoWindow) return;
|
|
29
|
+
const position = infoWindow.getPosition();
|
|
30
|
+
if (!position) return;
|
|
31
|
+
visible ? infoWindow.open(map, [position.lng, position.lat]) : infoWindow.close();
|
|
32
|
+
});
|
|
33
|
+
watchNoneImmediatePostEffectForMapProperty(infoWindowRef, props, [
|
|
34
|
+
{ name: "anchor", defaultValue: undefined },
|
|
35
|
+
{ name: "angle", defaultValue: undefined },
|
|
36
|
+
{ name: "content", defaultValue: undefined },
|
|
37
|
+
{ name: "extData", defaultValue: undefined },
|
|
38
|
+
{ name: "offset", defaultValue: undefined },
|
|
39
|
+
{ name: "orientation", defaultValue: undefined },
|
|
40
|
+
{ name: "position", defaultValue: undefined },
|
|
41
|
+
{ name: "size", defaultValue: undefined },
|
|
42
|
+
{ name: "zIndex", defaultValue: undefined },
|
|
43
|
+
]);
|
|
44
|
+
return () => null;
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AmapInfoWindow";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { load as loadAmap } from "@amap/amap-jsapi-loader";
|
|
2
|
+
import { computed, shallowRef } from "vue-demi";
|
|
3
|
+
import { defineSetup, VueNode } from "../../types/helper";
|
|
4
|
+
import { watchPostEffectForDeepOption } from "../../utils/compare";
|
|
5
|
+
import { GmapLoaderProps, Status } from "../GmapLoader";
|
|
6
|
+
|
|
7
|
+
type AMapLoaderOptions = Parameters<typeof loadAmap>[0];
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
_AMapSecurityConfig: {
|
|
11
|
+
securityJsCode?: string;
|
|
12
|
+
serviceHost?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AmapLoaderProps
|
|
18
|
+
extends Pick<GmapLoaderProps, "fallback" | "loading" | "onChange">,
|
|
19
|
+
Omit<AMapLoaderOptions, "key" | "version" | "plugins"> {
|
|
20
|
+
apiKey: string;
|
|
21
|
+
apiSecret?: string;
|
|
22
|
+
apiServiceHost?: string;
|
|
23
|
+
version?: string;
|
|
24
|
+
plugins?: `AMap.${AMap.PluginName}`[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const AmapLoader = defineSetup(function AmapLoader(props: AmapLoaderProps, { slots, emit }) {
|
|
28
|
+
const statusRef = shallowRef(Status.LOADING);
|
|
29
|
+
const optionsRef = computed(() => {
|
|
30
|
+
const { onChange, loading, fallback, apiKey, apiSecret, apiServiceHost, version, ...options } =
|
|
31
|
+
props;
|
|
32
|
+
return { ...options, key: apiKey, version: version ?? "2.0" };
|
|
33
|
+
});
|
|
34
|
+
watchPostEffectForDeepOption(
|
|
35
|
+
() => optionsRef.value,
|
|
36
|
+
(options) => {
|
|
37
|
+
const setStatusAndExecuteCallback = (status: Status) => {
|
|
38
|
+
emit("change", status);
|
|
39
|
+
statusRef.value = status;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
setStatusAndExecuteCallback(Status.LOADING);
|
|
43
|
+
|
|
44
|
+
window._AMapSecurityConfig = props.apiServiceHost
|
|
45
|
+
? {
|
|
46
|
+
serviceHost: props.apiServiceHost,
|
|
47
|
+
}
|
|
48
|
+
: { securityJsCode: props.apiSecret };
|
|
49
|
+
|
|
50
|
+
loadAmap(options).then(
|
|
51
|
+
() => setStatusAndExecuteCallback(Status.SUCCESS),
|
|
52
|
+
() => setStatusAndExecuteCallback(Status.FAILURE)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
return () => {
|
|
57
|
+
switch (statusRef.value) {
|
|
58
|
+
case Status.SUCCESS:
|
|
59
|
+
return slots.default?.() as VueNode;
|
|
60
|
+
case Status.LOADING:
|
|
61
|
+
return slots.loading?.();
|
|
62
|
+
case Status.FAILURE:
|
|
63
|
+
return slots.fallback?.();
|
|
64
|
+
default:
|
|
65
|
+
throw new Error("MyError: unknown loader status");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AmapLoader";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { defineSetup } from "../../types/helper";
|
|
3
|
+
import { watchNoneImmediatePostEffectForMapProperty } from "../../utils/compare";
|
|
4
|
+
import { useAmap } from "../Amap/useAmap";
|
|
5
|
+
|
|
6
|
+
export type AmapMarkerProps = AMap.MarkerOptions;
|
|
7
|
+
|
|
8
|
+
export const AmapMarker = defineSetup(function AmapMarker(props: AmapMarkerProps) {
|
|
9
|
+
const markerRef = shallowRef<AMap.Marker>();
|
|
10
|
+
const mapRef = useAmap();
|
|
11
|
+
onMounted(() => {
|
|
12
|
+
markerRef.value = new AMap.Marker({ ...props });
|
|
13
|
+
});
|
|
14
|
+
onUnmounted(() => {
|
|
15
|
+
markerRef.value?.setMap(null);
|
|
16
|
+
});
|
|
17
|
+
watchPostEffect(() => {
|
|
18
|
+
const map = mapRef?.value;
|
|
19
|
+
if (!map) return;
|
|
20
|
+
markerRef.value?.setMap(map);
|
|
21
|
+
});
|
|
22
|
+
watchNoneImmediatePostEffectForMapProperty(markerRef, props, [
|
|
23
|
+
{ name: "anchor", defaultValue: "" },
|
|
24
|
+
{ name: "offset", defaultValue: [0, 0] },
|
|
25
|
+
{ name: "clickable", defaultValue: false },
|
|
26
|
+
{ name: "position", defaultValue: [0, 0] },
|
|
27
|
+
{ name: "angle", defaultValue: 0 },
|
|
28
|
+
{ name: "label", defaultValue: undefined },
|
|
29
|
+
{ name: "zIndex", defaultValue: 0 },
|
|
30
|
+
{ name: "icon", defaultValue: "" },
|
|
31
|
+
{ name: "draggable", defaultValue: false },
|
|
32
|
+
{ name: "cursor", defaultValue: "" },
|
|
33
|
+
{ name: "content", defaultValue: "" },
|
|
34
|
+
{ name: "title", defaultValue: "" },
|
|
35
|
+
{ name: "extData", defaultValue: "" },
|
|
36
|
+
]);
|
|
37
|
+
return () => null;
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AmapMarker";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { defineSetup } from "../../types/helper";
|
|
3
|
+
import {
|
|
4
|
+
watchNoneImmediatePostEffectForDeepOption,
|
|
5
|
+
watchNoneImmediatePostEffectForMapProperty,
|
|
6
|
+
} from "../../utils/compare";
|
|
7
|
+
import { useAmap } from "../Amap/useAmap";
|
|
8
|
+
|
|
9
|
+
export type AmapPolygonProps = AMap.PolygonOptions;
|
|
10
|
+
|
|
11
|
+
export const AmapPolygon = defineSetup(function AmapPolygon(props: AmapPolygonProps) {
|
|
12
|
+
const polygonRef = shallowRef<AMap.Polygon>();
|
|
13
|
+
const mapRef = useAmap();
|
|
14
|
+
onMounted(() => {
|
|
15
|
+
polygonRef.value = new AMap.Polygon();
|
|
16
|
+
polygonRef.value.setOptions(props);
|
|
17
|
+
});
|
|
18
|
+
onUnmounted(() => {
|
|
19
|
+
polygonRef.value?.setMap(null);
|
|
20
|
+
});
|
|
21
|
+
watchPostEffect(() => {
|
|
22
|
+
const map = mapRef?.value;
|
|
23
|
+
if (!map) return;
|
|
24
|
+
polygonRef.value?.setMap(map);
|
|
25
|
+
});
|
|
26
|
+
watchNoneImmediatePostEffectForMapProperty(polygonRef, props, [
|
|
27
|
+
{ name: "path", defaultValue: [[0, 0]] },
|
|
28
|
+
{ name: "extData", defaultValue: undefined },
|
|
29
|
+
{ name: "draggable", defaultValue: false },
|
|
30
|
+
]);
|
|
31
|
+
watchNoneImmediatePostEffectForDeepOption(
|
|
32
|
+
() => {
|
|
33
|
+
const { path, extData, draggable, ...otherOptions } = props;
|
|
34
|
+
return otherOptions;
|
|
35
|
+
},
|
|
36
|
+
(otherOptions) => {
|
|
37
|
+
polygonRef.value?.setOptions({ ...otherOptions });
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
return () => null;
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AmapPolygon";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { defineSetup } from "../../types/helper";
|
|
3
|
+
import {
|
|
4
|
+
watchNoneImmediatePostEffectForDeepOption,
|
|
5
|
+
watchNoneImmediatePostEffectForMapProperty,
|
|
6
|
+
} from "../../utils/compare";
|
|
7
|
+
import { useAmap } from "../Amap/useAmap";
|
|
8
|
+
|
|
9
|
+
export type AmapPolylineProps = AMap.PolylineOptions;
|
|
10
|
+
|
|
11
|
+
export const AmapPolyline = defineSetup(function AmapPolyline(props: AmapPolylineProps) {
|
|
12
|
+
const polylineRef = shallowRef<AMap.Polyline>();
|
|
13
|
+
const mapRef = useAmap();
|
|
14
|
+
onMounted(() => {
|
|
15
|
+
polylineRef.value = new AMap.Polyline({ ...props });
|
|
16
|
+
});
|
|
17
|
+
onUnmounted(() => {
|
|
18
|
+
polylineRef.value?.setMap(null);
|
|
19
|
+
});
|
|
20
|
+
watchPostEffect(() => {
|
|
21
|
+
const map = mapRef?.value;
|
|
22
|
+
if (!map) return;
|
|
23
|
+
polylineRef.value?.setMap(map);
|
|
24
|
+
});
|
|
25
|
+
watchNoneImmediatePostEffectForMapProperty(polylineRef, props, [
|
|
26
|
+
{ name: "path", defaultValue: [[0, 0]] },
|
|
27
|
+
{ name: "extData", defaultValue: undefined },
|
|
28
|
+
{ name: "draggable", defaultValue: false },
|
|
29
|
+
]);
|
|
30
|
+
watchNoneImmediatePostEffectForDeepOption(
|
|
31
|
+
() => {
|
|
32
|
+
const { path, extData, draggable, ...otherOptions } = props;
|
|
33
|
+
return otherOptions;
|
|
34
|
+
},
|
|
35
|
+
(otherOptions) => {
|
|
36
|
+
polylineRef.value?.setOptions({ ...otherOptions });
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
return () => null;
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AmapPolyline";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { defineSetup } from "../../types/helper";
|
|
3
|
+
import { watchNoneImmediatePostEffectForMapProperty } from "../../utils/compare";
|
|
4
|
+
import { useAmap } from "../Amap/useAmap";
|
|
5
|
+
|
|
6
|
+
export type AmapTextProps = AMap.TextOptions;
|
|
7
|
+
|
|
8
|
+
export const AmapText = defineSetup(function AmapText(props: AmapTextProps) {
|
|
9
|
+
const textRef = shallowRef<AMap.Text>();
|
|
10
|
+
const mapRef = useAmap();
|
|
11
|
+
onMounted(() => {
|
|
12
|
+
textRef.value = new AMap.Text({ ...props });
|
|
13
|
+
});
|
|
14
|
+
onUnmounted(() => {
|
|
15
|
+
textRef.value?.setMap(null);
|
|
16
|
+
});
|
|
17
|
+
watchPostEffect(() => {
|
|
18
|
+
const map = mapRef?.value;
|
|
19
|
+
if (!map) return;
|
|
20
|
+
textRef.value?.setMap(map);
|
|
21
|
+
});
|
|
22
|
+
watchNoneImmediatePostEffectForMapProperty(textRef, props, [
|
|
23
|
+
{ name: "anchor", defaultValue: "" },
|
|
24
|
+
{ name: "offset", defaultValue: [0, 0] },
|
|
25
|
+
{ name: "clickable", defaultValue: false },
|
|
26
|
+
{ name: "position", defaultValue: [0, 0] },
|
|
27
|
+
{ name: "angle", defaultValue: 0 },
|
|
28
|
+
{ name: "label", defaultValue: undefined },
|
|
29
|
+
{ name: "zIndex", defaultValue: 0 },
|
|
30
|
+
{ name: "icon", defaultValue: "" },
|
|
31
|
+
{ name: "draggable", defaultValue: false },
|
|
32
|
+
{ name: "cursor", defaultValue: "" },
|
|
33
|
+
{ name: "content", defaultValue: "" },
|
|
34
|
+
{ name: "title", defaultValue: "" },
|
|
35
|
+
{ name: "extData", defaultValue: "" },
|
|
36
|
+
{ name: "style", defaultValue: undefined },
|
|
37
|
+
]);
|
|
38
|
+
return () => null;
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AmapText";
|