@heycar/heycars-map 0.1.8 → 0.2.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/README.md +30 -7
- package/dist/business-components/StartEndPoint/StartEndPoint.d.ts +18309 -4
- package/dist/components/AmapLoader/AmapLoader.d.ts +5 -20
- package/dist/components/AmapMarker/AmapMarker.d.ts +3 -2
- package/dist/components/Demo/HeycarDemo.d.ts +3 -3
- package/dist/components/Demo/searchResult.d.ts +1 -1
- package/dist/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.d.ts +3 -2
- package/dist/components/GmapLoader/GmapLoader.d.ts +3 -35
- package/dist/components/GmapMarker/GmapMarker.d.ts +3 -2
- package/dist/components/MapProvider/MapProvider.d.ts +4 -5
- package/dist/hooks/useGeoLocation.d.ts +2 -2
- package/dist/hooks/useMap.d.ts +801 -0
- package/dist/hooks/useMapAutoComplete.d.ts +4 -6
- package/dist/hooks/useMapCityBound.d.ts +5 -6
- package/dist/hooks/useMapEventSource.d.ts +5 -0
- package/dist/hooks/useMapFitView.d.ts +4599 -0
- package/dist/hooks/useMapLoader.d.ts +67 -0
- package/dist/hooks/useMapPlace.d.ts +4 -6
- package/dist/hooks/useMapRecomendPlace.d.ts +5 -797
- package/dist/hooks/useMapSupplier.d.ts +8 -0
- package/dist/hooks/useOverlay.d.ts +12 -0
- package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +5 -6
- package/dist/hooks-business/useBusinessMapRecomendPlace.d.ts +4 -3
- package/dist/index.cjs +52 -52
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1149 -920
- package/dist/types/interface.d.ts +4 -0
- package/package.json +1 -1
- package/src/App.tsx +1 -1
- package/src/api/place.ts +0 -2
- package/src/business-components/AddressBox/AddressBox.tsx +1 -1
- package/src/business-components/AddressLocator/AddressLocator.tsx +1 -1
- package/src/business-components/DrivingLine/DrivingLine.tsx +1 -1
- package/src/business-components/DrivingRoute/DrivingRoute.tsx +2 -3
- package/src/business-components/PassengerCircle/PassengerCircle.tsx +1 -1
- package/src/business-components/PlaceCircle/PlaceCircle.tsx +1 -1
- package/src/business-components/StartEndPoint/StartEndPoint.tsx +23 -7
- package/src/business-components/TaxiCar/TaxiCar.tsx +1 -1
- package/src/business-components/WalkingLine/WalkingLine.tsx +1 -1
- package/src/business-components/WalkingRoute/WalkingRoute.tsx +2 -3
- package/src/business-components/WaveCircle/WaveCircle.tsx +1 -1
- package/src/components/Amap/Amap.ts +1 -1
- package/src/components/AmapInfoWindow/AmapInfoWindow.ts +1 -1
- package/src/components/AmapLoader/AmapLoader.ts +6 -54
- package/src/components/AmapMarker/AmapMarker.ts +5 -2
- package/src/components/AmapPolygon/AmapPolygon.ts +1 -1
- package/src/components/AmapPolyline/AmapPolyline.ts +1 -1
- package/src/components/AmapText/AmapText.ts +1 -1
- package/src/components/Demo/Demo.css.ts +1 -1
- package/src/components/Demo/HeycarDemo.tsx +50 -33
- package/src/components/Demo/SearchDemo.tsx +40 -65
- package/src/components/Demo/searchResult.ts +12888 -1
- package/src/components/Gmap/Gmap.ts +17 -5
- package/src/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.ts +9 -4
- package/src/components/GmapInfoWindow/GmapInfoWindow.ts +1 -1
- package/src/components/GmapLoader/GmapLoader.ts +4 -62
- package/src/components/GmapMarker/GmapMarker.ts +5 -2
- package/src/components/GmapPolygon/GmapPolygon.ts +1 -1
- package/src/components/GmapPolyline/GmapPolyline.ts +1 -1
- package/src/components/MapProvider/MapProvider.tsx +33 -50
- package/src/hooks/useDrivingRoute.ts +1 -1
- package/src/hooks/useGeoLocation.ts +4 -2
- package/src/hooks/useHeycarMap.ts +1 -1
- package/src/hooks/useMap.ts +29 -0
- package/src/hooks/useMapAngle.ts +1 -1
- package/src/hooks/useMapAutoComplete.ts +16 -19
- package/src/hooks/useMapCityBound.ts +36 -24
- package/src/hooks/useMapDrag.ts +1 -1
- package/src/hooks/useMapEventSource.ts +20 -0
- package/src/hooks/useMapFitView.ts +127 -0
- package/src/hooks/useMapLoader.ts +164 -0
- package/src/hooks/useMapPlace.ts +20 -22
- package/src/hooks/useMapRecomendPlace.ts +18 -25
- package/src/{components/MapProvider → hooks}/useMapSupplier.ts +4 -7
- package/src/hooks/useOverlay.ts +22 -0
- package/src/hooks/useWalkingRoute.ts +1 -1
- package/src/hooks-business/useBusinessMapAutoComplete.ts +13 -8
- package/src/hooks-business/useBusinessMapRecomendPlace.ts +10 -10
- package/src/index.ts +3 -1
- package/src/types/interface.ts +5 -0
- package/dist/components/Amap/useAmap.d.ts +0 -399
- package/dist/components/Gmap/useGmap.d.ts +0 -5
- package/dist/components/MapProvider/useMapSupplier.d.ts +0 -11
- package/dist/hooks/useMapReady.d.ts +0 -4
- package/src/components/Amap/useAmap.ts +0 -9
- package/src/components/Gmap/useGmap.ts +0 -7
- package/src/hooks/useMapReady.ts +0 -14
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { HeycarDemo } from "./components/Demo/HeycarDemo";
|
|
|
4
4
|
export const App = defineComponent({
|
|
5
5
|
setup() {
|
|
6
6
|
// return () => <Hello class={"helloclass2"} qyc={2} style={{ color: "red" }} />;
|
|
7
|
-
// return () => <
|
|
7
|
+
// return () => <ABusinessDemo />;
|
|
8
8
|
// return () => <SearchDemo />;
|
|
9
9
|
return () => <HeycarDemo />;
|
|
10
10
|
},
|
package/src/api/place.ts
CHANGED
|
@@ -32,7 +32,6 @@ export const apiAutoCompleteSearch = async (
|
|
|
32
32
|
return new Promise((resolve, reject) => {
|
|
33
33
|
// todo 高德海外怎么传 country ?
|
|
34
34
|
amapAutoComplete.search(keyword, (status, result) => {
|
|
35
|
-
console.log("status, result = ", status, result);
|
|
36
35
|
switch (status) {
|
|
37
36
|
case "complete":
|
|
38
37
|
return resolve(result as AMap.AutocompleteResult);
|
|
@@ -74,7 +73,6 @@ export const apiPlaceSearchInBounds = async (
|
|
|
74
73
|
const amapPlaceSearch = getAmapPlaceSearch({ pageSize });
|
|
75
74
|
return new Promise((resolve, reject) => {
|
|
76
75
|
amapPlaceSearch.searchInBounds(keyword, new AMap.Bounds(bounds), (status, result) => {
|
|
77
|
-
console.log("status, result = ", status, result);
|
|
78
76
|
switch (status) {
|
|
79
77
|
case "complete":
|
|
80
78
|
return resolve(result as AMap.PlaceSearchResult);
|
|
@@ -3,7 +3,7 @@ import imgArrowRight from "../../assets/icons/svg/arrow-right.svg";
|
|
|
3
3
|
import imgPlaceCircle from "../../assets/icons/svg/place-circle.svg";
|
|
4
4
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
5
5
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView/GmapAdvancedMarkerView";
|
|
6
|
-
import { useMapSupplier } from "../../
|
|
6
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
7
7
|
import { createElement, defineSetup } from "../../types/helper";
|
|
8
8
|
import type { Point } from "../../types/interface";
|
|
9
9
|
import { createDom } from "../../utils/dom";
|
|
@@ -2,7 +2,7 @@ import { computed } from "vue-demi";
|
|
|
2
2
|
import imgAddressLocator from "../../assets/icons/svg/address-locator.svg";
|
|
3
3
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
4
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView";
|
|
5
|
-
import { useMapSupplier } from "../../
|
|
5
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
6
6
|
import { createElement, defineSetup } from "../../types/helper";
|
|
7
7
|
import { createDom } from "../../utils/dom";
|
|
8
8
|
import { vec2lnglat } from "../../utils/transform";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed } from "vue-demi";
|
|
2
2
|
import { AmapPolyline } from "../../components/AmapPolyline";
|
|
3
3
|
import { GmapPolyline } from "../../components/GmapPolyline";
|
|
4
|
-
import { useMapSupplier } from "../../
|
|
4
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
5
5
|
import { createElement, defineSetup } from "../../types/helper";
|
|
6
6
|
import { vec2lnglat } from "../../utils/transform";
|
|
7
7
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { reactive, VNodeData } from "vue-demi";
|
|
2
|
-
import { useAmap } from "../../components/Amap/useAmap";
|
|
3
|
-
import { useGmap } from "../../components/Gmap/useGmap";
|
|
4
|
-
import { useMapSupplier } from "../../components/MapProvider/useMapSupplier";
|
|
5
2
|
import {
|
|
6
3
|
useADrivingRoute,
|
|
7
4
|
UseDrivingRouteProps,
|
|
8
5
|
useGDrivingRoute,
|
|
9
6
|
} from "../../hooks/useDrivingRoute";
|
|
7
|
+
import { useAmap, useGmap } from "../../hooks/useMap";
|
|
10
8
|
import { useAmapAngle, useGmapAngle } from "../../hooks/useMapAngle";
|
|
9
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
11
10
|
import { createElement, defineSetup, VNodeChild } from "../../types/helper";
|
|
12
11
|
import type { Point } from "../../types/interface";
|
|
13
12
|
|
|
@@ -2,7 +2,7 @@ import { computed } from "vue";
|
|
|
2
2
|
import imgPassengerCircle from "../../assets/icons/svg/passenger-circle.svg";
|
|
3
3
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
4
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView";
|
|
5
|
-
import { useMapSupplier } from "../../
|
|
5
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
6
6
|
import { createElement, defineSetup } from "../../types/helper";
|
|
7
7
|
import { createDom } from "../../utils/dom";
|
|
8
8
|
import { vec2lnglat } from "../../utils/transform";
|
|
@@ -2,7 +2,7 @@ import { computed } from "vue-demi";
|
|
|
2
2
|
import imgPlaceCircle from "../../assets/icons/svg/place-circle.svg";
|
|
3
3
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
4
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView";
|
|
5
|
-
import { useMapSupplier } from "../../
|
|
5
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
6
6
|
import { AnchorType } from "../../types/amap/marker";
|
|
7
7
|
import { createElement, defineSetup } from "../../types/helper";
|
|
8
8
|
import { createDom } from "../../utils/dom";
|
|
@@ -3,19 +3,22 @@ import imgEndPoint from "../../assets/icons/svg/end-point.svg";
|
|
|
3
3
|
import imgStartPoint from "../../assets/icons/svg/start-point.svg";
|
|
4
4
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
5
5
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView/GmapAdvancedMarkerView";
|
|
6
|
-
import { useMapSupplier } from "../../
|
|
6
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
7
|
+
import type { AmapOverlay, GmapOverlay, MapRegisterOverlayProps } from "../../hooks/useOverlay";
|
|
7
8
|
import { createElement, defineSetup } from "../../types/helper";
|
|
8
9
|
import { createDom } from "../../utils/dom";
|
|
9
10
|
import { decodeAsterisk, vec2lnglat } from "../../utils/transform";
|
|
10
11
|
import * as css from "./StartEndPoint.css";
|
|
11
12
|
|
|
12
|
-
export interface StartEndPointProps {
|
|
13
|
+
export interface StartEndPointProps<T> extends MapRegisterOverlayProps<T> {
|
|
13
14
|
type: "start" | "end";
|
|
14
15
|
position: [number, number];
|
|
15
16
|
title?: string;
|
|
16
17
|
description?: string;
|
|
17
18
|
}
|
|
18
|
-
export const AStartEndPoint = defineSetup(function AStartEndPoint(
|
|
19
|
+
export const AStartEndPoint = defineSetup(function AStartEndPoint(
|
|
20
|
+
props: StartEndPointProps<AmapOverlay>
|
|
21
|
+
) {
|
|
19
22
|
const contentRef = computed(() => {
|
|
20
23
|
const icon = props.type === "start" ? imgStartPoint : imgEndPoint;
|
|
21
24
|
const descriptionRow = !props.description
|
|
@@ -47,11 +50,18 @@ export const AStartEndPoint = defineSetup(function AStartEndPoint(props: StartEn
|
|
|
47
50
|
`;
|
|
48
51
|
});
|
|
49
52
|
return () => (
|
|
50
|
-
<AmapMarker
|
|
53
|
+
<AmapMarker
|
|
54
|
+
registerOverlay={props.registerOverlay}
|
|
55
|
+
position={props.position}
|
|
56
|
+
content={contentRef.value}
|
|
57
|
+
anchor={"bottom-center"}
|
|
58
|
+
/>
|
|
51
59
|
);
|
|
52
60
|
});
|
|
53
61
|
|
|
54
|
-
export const GStartEndPoint = defineSetup(function GStartEndPoint(
|
|
62
|
+
export const GStartEndPoint = defineSetup(function GStartEndPoint(
|
|
63
|
+
props: StartEndPointProps<GmapOverlay>
|
|
64
|
+
) {
|
|
55
65
|
const contentRef = computed(() => {
|
|
56
66
|
const icon = props.type === "start" ? imgStartPoint : imgEndPoint;
|
|
57
67
|
const descriptionRow = !props.description
|
|
@@ -88,12 +98,18 @@ export const GStartEndPoint = defineSetup(function GStartEndPoint(props: StartEn
|
|
|
88
98
|
});
|
|
89
99
|
return () => {
|
|
90
100
|
return (
|
|
91
|
-
<GmapAdvancedMarkerView
|
|
101
|
+
<GmapAdvancedMarkerView
|
|
102
|
+
registerOverlay={props.registerOverlay}
|
|
103
|
+
position={vec2lnglat(props.position)}
|
|
104
|
+
content={contentRef.value}
|
|
105
|
+
/>
|
|
92
106
|
);
|
|
93
107
|
};
|
|
94
108
|
});
|
|
95
109
|
|
|
96
|
-
export const StartEndPoint = defineSetup(function StartEndPoint(
|
|
110
|
+
export const StartEndPoint = defineSetup(function StartEndPoint(
|
|
111
|
+
props: StartEndPointProps<AmapOverlay> | StartEndPointProps<GmapOverlay>
|
|
112
|
+
) {
|
|
97
113
|
const payload = useMapSupplier();
|
|
98
114
|
return () => {
|
|
99
115
|
return createElement(payload.supplier === "gmap" ? GStartEndPoint : AStartEndPoint, {
|
|
@@ -2,7 +2,7 @@ import { computed } from "vue-demi";
|
|
|
2
2
|
import imgTaxicar from "../../assets/icons/svg/taxi-car.svg";
|
|
3
3
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
4
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView/GmapAdvancedMarkerView";
|
|
5
|
-
import { useMapSupplier } from "../../
|
|
5
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
6
6
|
import { createElement, defineSetup } from "../../types/helper";
|
|
7
7
|
import { createDom } from "../../utils/dom";
|
|
8
8
|
import { decodeAsterisk, vec2lnglat } from "../../utils/transform";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed } from "vue-demi";
|
|
2
2
|
import { AmapPolyline } from "../../components/AmapPolyline";
|
|
3
3
|
import { GmapPolyline } from "../../components/GmapPolyline";
|
|
4
|
-
import { useMapSupplier } from "../../
|
|
4
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
5
5
|
import { createElement, defineSetup } from "../../types/helper";
|
|
6
6
|
import { vec2lnglat } from "../../utils/transform";
|
|
7
7
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { reactive, VNodeData } from "vue-demi";
|
|
2
|
-
import { useAmap } from "../../
|
|
3
|
-
import { useGmap } from "../../components/Gmap/useGmap";
|
|
4
|
-
import { useMapSupplier } from "../../components/MapProvider/useMapSupplier";
|
|
2
|
+
import { useAmap, useGmap } from "../../hooks/useMap";
|
|
5
3
|
import { useAmapAngle, useGmapAngle } from "../../hooks/useMapAngle";
|
|
4
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
6
5
|
import {
|
|
7
6
|
useAWalkingRoute,
|
|
8
7
|
useGWalkingRoute,
|
|
@@ -2,7 +2,7 @@ import { computed } from "vue-demi";
|
|
|
2
2
|
import imgWaveCircle from "../../assets/icons/svg/wave-circle.svg";
|
|
3
3
|
import { AmapMarker } from "../../components/AmapMarker";
|
|
4
4
|
import { GmapAdvancedMarkerView } from "../../components/GmapAdvancedMarkerView";
|
|
5
|
-
import { useMapSupplier } from "../../
|
|
5
|
+
import { useMapSupplier } from "../../hooks/useMapSupplier";
|
|
6
6
|
import { createElement, defineSetup } from "../../types/helper";
|
|
7
7
|
import { createDom } from "../../utils/dom";
|
|
8
8
|
import { vec2lnglat } from "../../utils/transform";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, h, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
2
|
import type { SetMap } from "../../hooks/useHeycarMap";
|
|
3
|
+
import { provideAmap } from "../../hooks/useMap";
|
|
3
4
|
import { defineSetup } from "../../types/helper";
|
|
4
5
|
import type { MapEventHandler } from "../../types/mapHelper";
|
|
5
6
|
import {
|
|
@@ -9,7 +10,6 @@ import {
|
|
|
9
10
|
} from "../../utils/compare";
|
|
10
11
|
import type { VectorMapForeign } from "../../utils/transform";
|
|
11
12
|
import * as css from "./Amap.css";
|
|
12
|
-
import { provideAmap } from "./useAmap";
|
|
13
13
|
|
|
14
14
|
export interface AmapProps extends Omit<AMap.MapOptions, "vectorMapForeign"> {
|
|
15
15
|
vectorMapForeign?: VectorMapForeign;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { useAmap } from "../../hooks/useMap";
|
|
2
3
|
import { defineSetup } from "../../types/helper";
|
|
3
4
|
import { watchNoneImmediatePostEffectForMapProperty } from "../../utils/compare";
|
|
4
|
-
import { useAmap } from "../Amap/useAmap";
|
|
5
5
|
|
|
6
6
|
export interface AmapInfoWindowProps extends AMap.InfoOptions {
|
|
7
7
|
visible: boolean;
|
|
@@ -1,58 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { computed, shallowRef } from "vue-demi";
|
|
1
|
+
import { AmapLoaderProps, Status, useAmapLoader } from "../../hooks/useMapLoader";
|
|
3
2
|
import { defineSetup, VueNode } from "../../types/helper";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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.5.16" };
|
|
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
|
-
);
|
|
3
|
+
/**
|
|
4
|
+
* Deprcated
|
|
5
|
+
*/
|
|
6
|
+
export const AmapLoader = defineSetup(function AmapLoader(props: AmapLoaderProps, { slots }) {
|
|
7
|
+
const { statusRef } = useAmapLoader(props);
|
|
56
8
|
return () => {
|
|
57
9
|
switch (statusRef.value) {
|
|
58
10
|
case Status.SUCCESS:
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { useAmap } from "../../hooks/useMap";
|
|
3
|
+
import { AmapOverlay, MapRegisterOverlayProps, useMapOverlay } from "../../hooks/useOverlay";
|
|
2
4
|
import { defineSetup } from "../../types/helper";
|
|
3
5
|
import { watchNoneImmediatePostEffectForMapProperty } from "../../utils/compare";
|
|
4
|
-
import { useAmap } from "../Amap/useAmap";
|
|
5
6
|
|
|
6
|
-
export type AmapMarkerProps = AMap.MarkerOptions
|
|
7
|
+
export type AmapMarkerProps = AMap.MarkerOptions & MapRegisterOverlayProps<AmapOverlay>;
|
|
7
8
|
|
|
8
9
|
export const AmapMarker = defineSetup(function AmapMarker(props: AmapMarkerProps) {
|
|
10
|
+
const { registerOverlay } = props;
|
|
9
11
|
const markerRef = shallowRef<AMap.Marker>();
|
|
10
12
|
const mapRef = useAmap();
|
|
11
13
|
onMounted(() => {
|
|
@@ -14,6 +16,7 @@ export const AmapMarker = defineSetup(function AmapMarker(props: AmapMarkerProps
|
|
|
14
16
|
onUnmounted(() => {
|
|
15
17
|
markerRef.value?.setMap(null);
|
|
16
18
|
});
|
|
19
|
+
useMapOverlay({ registerOverlay, overlayRef: markerRef });
|
|
17
20
|
watchPostEffect(() => {
|
|
18
21
|
const map = mapRef?.value;
|
|
19
22
|
if (!map) return;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { useAmap } from "../../hooks/useMap";
|
|
2
3
|
import { defineSetup } from "../../types/helper";
|
|
3
4
|
import {
|
|
4
5
|
watchNoneImmediatePostEffectForDeepOption,
|
|
5
6
|
watchNoneImmediatePostEffectForMapProperty,
|
|
6
7
|
} from "../../utils/compare";
|
|
7
|
-
import { useAmap } from "../Amap/useAmap";
|
|
8
8
|
|
|
9
9
|
export type AmapPolygonProps = AMap.PolygonOptions;
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { useAmap } from "../../hooks/useMap";
|
|
2
3
|
import { defineSetup } from "../../types/helper";
|
|
3
4
|
import {
|
|
4
5
|
watchNoneImmediatePostEffectForDeepOption,
|
|
5
6
|
watchNoneImmediatePostEffectForMapProperty,
|
|
6
7
|
} from "../../utils/compare";
|
|
7
|
-
import { useAmap } from "../Amap/useAmap";
|
|
8
8
|
|
|
9
9
|
export type AmapPolylineProps = AMap.PolylineOptions;
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { onMounted, onUnmounted, shallowRef, watchPostEffect } from "vue-demi";
|
|
2
|
+
import { useAmap } from "../../hooks/useMap";
|
|
2
3
|
import { defineSetup } from "../../types/helper";
|
|
3
4
|
import { watchNoneImmediatePostEffectForMapProperty } from "../../utils/compare";
|
|
4
|
-
import { useAmap } from "../Amap/useAmap";
|
|
5
5
|
|
|
6
6
|
export type AmapTextProps = AMap.TextOptions;
|
|
7
7
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { WalkingLine } from "../../business-components/WalkingLine";
|
|
4
|
-
import { WalkingRoute } from "../../business-components/WalkingRoute";
|
|
1
|
+
import { computed } from "vue-demi";
|
|
2
|
+
import { StartEndPoint } from "../../business-components/StartEndPoint";
|
|
5
3
|
import { useBusinessMapAutoComplete } from "../../hooks-business/useBusinessMapAutoComplete";
|
|
6
4
|
import {
|
|
7
5
|
useBusinessMapRecomendPlace,
|
|
8
6
|
UseBusinessMapRecomendPlaceProps,
|
|
9
7
|
} from "../../hooks-business/useBusinessMapRecomendPlace";
|
|
10
8
|
import { useHeycarMap } from "../../hooks/useHeycarMap";
|
|
9
|
+
import { useMapFitView } from "../../hooks/useMapFitView";
|
|
11
10
|
import { defineSetup } from "../../types/helper";
|
|
12
11
|
import { HeycarMap, MapProvider } from "../MapProvider/MapProvider";
|
|
13
12
|
import * as css from "./Demo.css";
|
|
@@ -24,46 +23,47 @@ export const HeycarDemo = defineSetup(function HeycarDemo() {
|
|
|
24
23
|
amapSecret={amapApiSecret}
|
|
25
24
|
gmapId={gmapId}
|
|
26
25
|
gmapKey={gmapApiKey}
|
|
27
|
-
supplier={"
|
|
26
|
+
supplier={"amap"}
|
|
28
27
|
>
|
|
29
28
|
<SomeHomePage />
|
|
30
29
|
</MapProvider>
|
|
31
30
|
);
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
export const
|
|
35
|
-
const { mapRef, setMap } = useHeycarMap();
|
|
36
|
-
const cityName = "上海市";
|
|
37
|
-
const { autoCompletePlaces, setKeyword, setCity } = useBusinessMapAutoComplete({
|
|
38
|
-
mapRef,
|
|
39
|
-
defaultCityName: cityName,
|
|
40
|
-
});
|
|
41
|
-
(window as any).setKeyword = setKeyword;
|
|
42
|
-
(window as any).setCity = setCity;
|
|
33
|
+
export const SomeOuterPage = defineSetup(function SomeOuterPage() {
|
|
43
34
|
return () => {
|
|
44
|
-
const list = autoCompletePlaces.value.map((place) => (
|
|
45
|
-
<div>
|
|
46
|
-
{place.lng} | {place.lat} | {place.name} | {place.description}
|
|
47
|
-
</div>
|
|
48
|
-
));
|
|
49
35
|
return (
|
|
50
36
|
<div>
|
|
51
|
-
<
|
|
37
|
+
<SomeAutoComplete cityName="上海市"></SomeAutoComplete>
|
|
52
38
|
<HeycarMap
|
|
53
39
|
class={css.demo}
|
|
54
40
|
fallback={() => <div>error</div>}
|
|
55
41
|
loading={() => <div>loading</div>}
|
|
56
|
-
center={[
|
|
57
|
-
zoom={
|
|
58
|
-
mapRef={setMap}
|
|
42
|
+
center={[121.5, 31]}
|
|
43
|
+
zoom={13}
|
|
59
44
|
></HeycarMap>
|
|
60
45
|
</div>
|
|
61
46
|
);
|
|
62
47
|
};
|
|
63
48
|
});
|
|
49
|
+
const SomeAutoComplete = defineSetup(function SomeAutoComplete(props: { cityName: string }) {
|
|
50
|
+
const { autoCompletePlaces, setKeyword, setCity } = useBusinessMapAutoComplete({
|
|
51
|
+
cityNameRef: computed(() => props.cityName),
|
|
52
|
+
});
|
|
53
|
+
(window as any).setKeyword = setKeyword;
|
|
54
|
+
(window as any).setCity = setCity;
|
|
55
|
+
return () => {
|
|
56
|
+
const list = autoCompletePlaces.value.map((place) => (
|
|
57
|
+
<div>
|
|
58
|
+
{place.lng} | {place.lat} | {place.name} | {place.description}
|
|
59
|
+
</div>
|
|
60
|
+
));
|
|
61
|
+
return <div>{list}</div>;
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
64
|
|
|
65
|
-
export const SomeHomePage = defineSetup(function
|
|
66
|
-
const { mapRef, setMap
|
|
65
|
+
export const SomeHomePage = defineSetup(function SomeHomePage() {
|
|
66
|
+
const { mapRef, setMap } = useHeycarMap();
|
|
67
67
|
const getRecomendPlace: UseBusinessMapRecomendPlaceProps["getRecomendPlace"] = async (
|
|
68
68
|
place,
|
|
69
69
|
context
|
|
@@ -82,7 +82,6 @@ export const SomeHomePage = defineSetup(function Hello() {
|
|
|
82
82
|
setCenterPlaceByRecomand,
|
|
83
83
|
} = useBusinessMapRecomendPlace({
|
|
84
84
|
mapRef,
|
|
85
|
-
defaultCenterPoint: [131, 31],
|
|
86
85
|
recomendPlaceGeoLimit: 300,
|
|
87
86
|
recomendPlaceDragLimit: 30,
|
|
88
87
|
getRecomendPlace,
|
|
@@ -90,7 +89,13 @@ export const SomeHomePage = defineSetup(function Hello() {
|
|
|
90
89
|
onChangePlace: (v) => console.log("onChangePlace: ", v),
|
|
91
90
|
onChangeRecomandPlace: (v) => console.log("onChangeRecomandPlace: ", v),
|
|
92
91
|
});
|
|
92
|
+
const { registerFitVeiw, setFitView } = useMapFitView({
|
|
93
|
+
mapRef,
|
|
94
|
+
padding: [15, 15, 5, 15],
|
|
95
|
+
autoFitTimeout: 5000,
|
|
96
|
+
});
|
|
93
97
|
(window as any).setCenterPlaceByRecomand = setCenterPlaceByRecomand;
|
|
98
|
+
(window as any).setFitView = setFitView;
|
|
94
99
|
return () => {
|
|
95
100
|
return (
|
|
96
101
|
<div>
|
|
@@ -103,17 +108,29 @@ export const SomeHomePage = defineSetup(function Hello() {
|
|
|
103
108
|
class={css.demo}
|
|
104
109
|
fallback={() => <div>error</div>}
|
|
105
110
|
loading={() => <div>loading</div>}
|
|
106
|
-
center={
|
|
107
|
-
zoom={
|
|
111
|
+
center={centerPoint.value}
|
|
112
|
+
zoom={centerPoint.value[0] === 0 ? 3 : 13}
|
|
108
113
|
mapRef={setMap}
|
|
109
114
|
>
|
|
110
|
-
<
|
|
111
|
-
|
|
115
|
+
<StartEndPoint
|
|
116
|
+
registerOverlay={registerFitVeiw}
|
|
117
|
+
position={[121.4897065, 31.0842552]}
|
|
118
|
+
title={"start point"}
|
|
119
|
+
type="start"
|
|
120
|
+
/>
|
|
121
|
+
<StartEndPoint
|
|
122
|
+
registerOverlay={registerFitVeiw}
|
|
123
|
+
position={[centerPoint.value[0] + 0.01, centerPoint.value[1] + 0.01]}
|
|
124
|
+
title={"end point"}
|
|
125
|
+
type="end"
|
|
126
|
+
/>
|
|
127
|
+
{/* <PickupPoints places={placeCandidates.value} /> */}
|
|
128
|
+
{/* <AddressBox
|
|
112
129
|
type="box"
|
|
113
130
|
position={centerPoint.value}
|
|
114
131
|
title={"Martyrs Lawn"}
|
|
115
132
|
description={"您将在此处上车"}
|
|
116
|
-
/>
|
|
133
|
+
/> */}
|
|
117
134
|
{/* <TaxiCar position={[121, 31]} angle={0} /> */}
|
|
118
135
|
{/* <PickupPoints
|
|
119
136
|
positions={[
|
|
@@ -130,11 +147,11 @@ export const SomeHomePage = defineSetup(function Hello() {
|
|
|
130
147
|
<TaxiCar position={[121, 31]} angle={angle} />,
|
|
131
148
|
]}
|
|
132
149
|
/> */}
|
|
133
|
-
<WalkingRoute
|
|
150
|
+
{/* <WalkingRoute
|
|
134
151
|
from={centerPoint.value}
|
|
135
152
|
to={[centerPoint.value[0] + 0.1, centerPoint.value[1] + 0.1]}
|
|
136
153
|
render={({ path }) => <WalkingLine path={path} />}
|
|
137
|
-
/>
|
|
154
|
+
/> */}
|
|
138
155
|
</HeycarMap>
|
|
139
156
|
</div>
|
|
140
157
|
);
|