@heycar/heycars-map 0.5.1 → 0.5.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.
|
@@ -12,6 +12,7 @@ export interface AmapProps extends Omit<AMap.MapOptions, "vectorMapForeign"> {
|
|
|
12
12
|
touchZoom?: boolean;
|
|
13
13
|
keyboardEnable?: boolean;
|
|
14
14
|
pitchEnable?: boolean;
|
|
15
|
+
touchZoomCenter?: 0 | 1;
|
|
15
16
|
onDragStart?: MapEventHandler<AMap.Map>;
|
|
16
17
|
onDragEnd?: MapEventHandler<AMap.Map>;
|
|
17
18
|
onZoomEnd?: MapEventHandler<AMap.Map>;
|
|
@@ -7,9 +7,10 @@ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gma
|
|
|
7
7
|
export declare const MapProvider: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "change", MapProviderProps, {}>;
|
|
8
8
|
export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
|
|
9
9
|
mapRef?: SetMap<AMap.Map> | SetMap<google.maps.Map>;
|
|
10
|
+
touchZoomCenter?: boolean;
|
|
11
|
+
touchEnable?: boolean;
|
|
10
12
|
onDragEnd?: (value: [number, number]) => any;
|
|
11
13
|
onZoomEnd?: (value: number) => any;
|
|
12
14
|
onResize?: () => any;
|
|
13
|
-
touchEnable?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export declare const HeycarMap: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<HeycarMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<HeycarMapProps, Required<HeycarMapProps>>, "resize" | "dragEnd" | "zoomEnd", HeycarMapProps, {}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import { Ref, ShallowRef } from "vue-demi";
|
|
3
|
+
interface UseWheelZoomCenterProps<M = AMap.Map | google.maps.Map> {
|
|
4
|
+
mapRef: ShallowRef<M | undefined>;
|
|
5
|
+
enableRef?: Ref<boolean>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useAmapWheelZoomCenter: (props: UseWheelZoomCenterProps<AMap.Map>) => void;
|
|
8
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1859,6 +1859,35 @@ const useMapLoader = (props) => {
|
|
|
1859
1859
|
onChange
|
|
1860
1860
|
});
|
|
1861
1861
|
};
|
|
1862
|
+
const ZOOM_WHEEL_RATIO = -135e-5;
|
|
1863
|
+
const useAmapWheelZoomCenter = (props) => {
|
|
1864
|
+
const { mapRef, enableRef } = props;
|
|
1865
|
+
const handleWheel = (e) => {
|
|
1866
|
+
var _a, _b, _c;
|
|
1867
|
+
const { deltaY } = e;
|
|
1868
|
+
const prevZoom = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : 0;
|
|
1869
|
+
const zoom = prevZoom + ZOOM_WHEEL_RATIO * deltaY;
|
|
1870
|
+
console.log("handleWheel zoom = ", zoom);
|
|
1871
|
+
(_c = mapRef.value) == null ? void 0 : _c.setZoom(zoom);
|
|
1872
|
+
};
|
|
1873
|
+
Vue.watch(
|
|
1874
|
+
() => enableRef == null ? void 0 : enableRef.value,
|
|
1875
|
+
(enable, _, onCleanup) => {
|
|
1876
|
+
if (enable) {
|
|
1877
|
+
console.log("addEventListener wheel");
|
|
1878
|
+
addEventListener("wheel", handleWheel);
|
|
1879
|
+
} else {
|
|
1880
|
+
console.log("removeEventListener wheel");
|
|
1881
|
+
removeEventListener("wheel", handleWheel);
|
|
1882
|
+
}
|
|
1883
|
+
onCleanup(() => {
|
|
1884
|
+
console.log("onClean removeEventListener wheel");
|
|
1885
|
+
removeEventListener("wheel", handleWheel);
|
|
1886
|
+
});
|
|
1887
|
+
},
|
|
1888
|
+
{ immediate: true }
|
|
1889
|
+
);
|
|
1890
|
+
};
|
|
1862
1891
|
const Amap_css_ts_vanilla = "";
|
|
1863
1892
|
var amap = "_1d8ur7t0";
|
|
1864
1893
|
const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
@@ -1881,9 +1910,10 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
|
1881
1910
|
animateEnable = true,
|
|
1882
1911
|
keyboardEnable = true,
|
|
1883
1912
|
doubleClickZoom = true,
|
|
1884
|
-
|
|
1885
|
-
|
|
1913
|
+
touchZoom = true,
|
|
1914
|
+
touchZoomCenter = 0
|
|
1886
1915
|
} = props;
|
|
1916
|
+
const scrollWheel = touchZoomCenter ? false : props.scrollWheel;
|
|
1887
1917
|
return {
|
|
1888
1918
|
dragEnable,
|
|
1889
1919
|
zoomEnable,
|
|
@@ -1894,17 +1924,20 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
|
1894
1924
|
keyboardEnable,
|
|
1895
1925
|
doubleClickZoom,
|
|
1896
1926
|
scrollWheel,
|
|
1897
|
-
touchZoom
|
|
1927
|
+
touchZoom,
|
|
1928
|
+
touchZoomCenter
|
|
1898
1929
|
};
|
|
1899
1930
|
});
|
|
1900
1931
|
const elementRef = Vue.shallowRef();
|
|
1901
1932
|
const mapRef = Vue.shallowRef();
|
|
1902
1933
|
provideAmap(mapRef);
|
|
1934
|
+
useAmapWheelZoomCenter({ mapRef, enableRef: Vue.computed(() => !!props.touchZoomCenter) });
|
|
1903
1935
|
Vue.watchPostEffect(() => {
|
|
1904
1936
|
if (mapRef.value || !elementRef.value)
|
|
1905
1937
|
return;
|
|
1906
1938
|
const map = new AMap.Map(elementRef.value, {
|
|
1907
1939
|
...defaultOptions,
|
|
1940
|
+
scrollWheel: defaultOptions.touchZoomCenter ? false : defaultOptions.scrollWheel,
|
|
1908
1941
|
vectorMapForeign,
|
|
1909
1942
|
mapStyle: "amap://styles/95498a904992a4c0b866a3e4d7729682"
|
|
1910
1943
|
});
|
|
@@ -2063,7 +2096,8 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
|
|
|
2063
2096
|
mapRef: setMap,
|
|
2064
2097
|
center,
|
|
2065
2098
|
zoom,
|
|
2066
|
-
touchEnable = true
|
|
2099
|
+
touchEnable = true,
|
|
2100
|
+
touchZoomCenter
|
|
2067
2101
|
} = props;
|
|
2068
2102
|
if (status === Status.LOADING)
|
|
2069
2103
|
return (_a = slots.loading) == null ? void 0 : _a.call(slots);
|
|
@@ -2104,6 +2138,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
|
|
|
2104
2138
|
"doubleClickZoom": touchEnable,
|
|
2105
2139
|
"scrollWheel": touchEnable,
|
|
2106
2140
|
"touchZoom": touchEnable,
|
|
2141
|
+
"touchZoomCenter": touchZoomCenter ? 1 : 0,
|
|
2107
2142
|
"keyboardEnable": touchEnable,
|
|
2108
2143
|
"pitchEnable": touchEnable
|
|
2109
2144
|
},
|
|
@@ -2114,7 +2149,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
|
|
|
2114
2149
|
}, [children]);
|
|
2115
2150
|
}
|
|
2116
2151
|
};
|
|
2117
|
-
}).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable"]);
|
|
2152
|
+
}).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable", "touchZoomCenter"]);
|
|
2118
2153
|
const AmapPolyline = defineSetup(function AmapPolyline2(props) {
|
|
2119
2154
|
const polylineRef = Vue.shallowRef();
|
|
2120
2155
|
const mapRef = useAmap();
|
|
@@ -3999,6 +4034,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
|
|
|
3999
4034
|
"attrs": {
|
|
4000
4035
|
"center": centerPoint.value,
|
|
4001
4036
|
"zoom": zoomRef.value,
|
|
4037
|
+
"touchZoomCenter": true,
|
|
4002
4038
|
"mapRef": setMap
|
|
4003
4039
|
}
|
|
4004
4040
|
}, [!geoLoading.value && !geoError.value && Vue.h(PassengerCircle, {
|
package/dist/index.js
CHANGED
|
@@ -1857,6 +1857,35 @@ const useMapLoader = (props) => {
|
|
|
1857
1857
|
onChange
|
|
1858
1858
|
});
|
|
1859
1859
|
};
|
|
1860
|
+
const ZOOM_WHEEL_RATIO = -135e-5;
|
|
1861
|
+
const useAmapWheelZoomCenter = (props) => {
|
|
1862
|
+
const { mapRef, enableRef } = props;
|
|
1863
|
+
const handleWheel = (e) => {
|
|
1864
|
+
var _a, _b, _c;
|
|
1865
|
+
const { deltaY } = e;
|
|
1866
|
+
const prevZoom = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : 0;
|
|
1867
|
+
const zoom = prevZoom + ZOOM_WHEEL_RATIO * deltaY;
|
|
1868
|
+
console.log("handleWheel zoom = ", zoom);
|
|
1869
|
+
(_c = mapRef.value) == null ? void 0 : _c.setZoom(zoom);
|
|
1870
|
+
};
|
|
1871
|
+
watch(
|
|
1872
|
+
() => enableRef == null ? void 0 : enableRef.value,
|
|
1873
|
+
(enable, _, onCleanup) => {
|
|
1874
|
+
if (enable) {
|
|
1875
|
+
console.log("addEventListener wheel");
|
|
1876
|
+
addEventListener("wheel", handleWheel);
|
|
1877
|
+
} else {
|
|
1878
|
+
console.log("removeEventListener wheel");
|
|
1879
|
+
removeEventListener("wheel", handleWheel);
|
|
1880
|
+
}
|
|
1881
|
+
onCleanup(() => {
|
|
1882
|
+
console.log("onClean removeEventListener wheel");
|
|
1883
|
+
removeEventListener("wheel", handleWheel);
|
|
1884
|
+
});
|
|
1885
|
+
},
|
|
1886
|
+
{ immediate: true }
|
|
1887
|
+
);
|
|
1888
|
+
};
|
|
1860
1889
|
const Amap_css_ts_vanilla = "";
|
|
1861
1890
|
var amap = "_1d8ur7t0";
|
|
1862
1891
|
const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
@@ -1879,9 +1908,10 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
|
1879
1908
|
animateEnable = true,
|
|
1880
1909
|
keyboardEnable = true,
|
|
1881
1910
|
doubleClickZoom = true,
|
|
1882
|
-
|
|
1883
|
-
|
|
1911
|
+
touchZoom = true,
|
|
1912
|
+
touchZoomCenter = 0
|
|
1884
1913
|
} = props;
|
|
1914
|
+
const scrollWheel = touchZoomCenter ? false : props.scrollWheel;
|
|
1885
1915
|
return {
|
|
1886
1916
|
dragEnable,
|
|
1887
1917
|
zoomEnable,
|
|
@@ -1892,17 +1922,20 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
|
1892
1922
|
keyboardEnable,
|
|
1893
1923
|
doubleClickZoom,
|
|
1894
1924
|
scrollWheel,
|
|
1895
|
-
touchZoom
|
|
1925
|
+
touchZoom,
|
|
1926
|
+
touchZoomCenter
|
|
1896
1927
|
};
|
|
1897
1928
|
});
|
|
1898
1929
|
const elementRef = shallowRef();
|
|
1899
1930
|
const mapRef = shallowRef();
|
|
1900
1931
|
provideAmap(mapRef);
|
|
1932
|
+
useAmapWheelZoomCenter({ mapRef, enableRef: computed(() => !!props.touchZoomCenter) });
|
|
1901
1933
|
watchPostEffect(() => {
|
|
1902
1934
|
if (mapRef.value || !elementRef.value)
|
|
1903
1935
|
return;
|
|
1904
1936
|
const map = new AMap.Map(elementRef.value, {
|
|
1905
1937
|
...defaultOptions,
|
|
1938
|
+
scrollWheel: defaultOptions.touchZoomCenter ? false : defaultOptions.scrollWheel,
|
|
1906
1939
|
vectorMapForeign,
|
|
1907
1940
|
mapStyle: "amap://styles/95498a904992a4c0b866a3e4d7729682"
|
|
1908
1941
|
});
|
|
@@ -2061,7 +2094,8 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
|
|
|
2061
2094
|
mapRef: setMap,
|
|
2062
2095
|
center,
|
|
2063
2096
|
zoom,
|
|
2064
|
-
touchEnable = true
|
|
2097
|
+
touchEnable = true,
|
|
2098
|
+
touchZoomCenter
|
|
2065
2099
|
} = props;
|
|
2066
2100
|
if (status === Status.LOADING)
|
|
2067
2101
|
return (_a = slots.loading) == null ? void 0 : _a.call(slots);
|
|
@@ -2102,6 +2136,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
|
|
|
2102
2136
|
"doubleClickZoom": touchEnable,
|
|
2103
2137
|
"scrollWheel": touchEnable,
|
|
2104
2138
|
"touchZoom": touchEnable,
|
|
2139
|
+
"touchZoomCenter": touchZoomCenter ? 1 : 0,
|
|
2105
2140
|
"keyboardEnable": touchEnable,
|
|
2106
2141
|
"pitchEnable": touchEnable
|
|
2107
2142
|
},
|
|
@@ -2112,7 +2147,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
|
|
|
2112
2147
|
}, [children]);
|
|
2113
2148
|
}
|
|
2114
2149
|
};
|
|
2115
|
-
}).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable"]);
|
|
2150
|
+
}).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable", "touchZoomCenter"]);
|
|
2116
2151
|
const AmapPolyline = defineSetup(function AmapPolyline2(props) {
|
|
2117
2152
|
const polylineRef = shallowRef();
|
|
2118
2153
|
const mapRef = useAmap();
|
|
@@ -3997,6 +4032,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
|
|
|
3997
4032
|
"attrs": {
|
|
3998
4033
|
"center": centerPoint.value,
|
|
3999
4034
|
"zoom": zoomRef.value,
|
|
4035
|
+
"touchZoomCenter": true,
|
|
4000
4036
|
"mapRef": setMap
|
|
4001
4037
|
}
|
|
4002
4038
|
}, [!geoLoading.value && !geoError.value && h(PassengerCircle, {
|