@heycar/heycars-map 0.9.27-google3 → 0.9.27-google4
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.
|
@@ -2,6 +2,7 @@ import "../../css/Amap-139f163d.css";
|
|
|
2
2
|
import "../../chunks/index.fbc1adc8.js";
|
|
3
3
|
import { MAX_ANIMATION_DISTANCE_VW } from "../../api/contants.js";
|
|
4
4
|
import { provideAmap } from "../../hooks/useMap.js";
|
|
5
|
+
import { useAmapDoubleClickZoomCenter } from "../../hooks/useMapGestureZoomCenter.js";
|
|
5
6
|
import { useMapLngLatToVw } from "../../hooks/useMapLngLatToVw.js";
|
|
6
7
|
import { useAmapWheelZoomCenter } from "../../hooks/useMapWheelZoomCenter.js";
|
|
7
8
|
import { defineSetup } from "../../types/helper.js";
|
|
@@ -31,11 +32,11 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
|
31
32
|
rotateEnable = true,
|
|
32
33
|
animateEnable = true,
|
|
33
34
|
keyboardEnable = true,
|
|
34
|
-
doubleClickZoom = true,
|
|
35
35
|
touchZoom = true,
|
|
36
36
|
touchZoomCenter = 0
|
|
37
37
|
} = props;
|
|
38
38
|
const scrollWheel = touchZoomCenter ? false : props.scrollWheel;
|
|
39
|
+
const doubleClickZoom = touchZoomCenter ? false : props.doubleClickZoom;
|
|
39
40
|
return {
|
|
40
41
|
dragEnable,
|
|
41
42
|
zoomEnable,
|
|
@@ -52,9 +53,11 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
|
52
53
|
});
|
|
53
54
|
const elementRef = shallowRef();
|
|
54
55
|
const mapRef = shallowRef();
|
|
56
|
+
const touchZoomCenterRef = computed(() => !!props.touchZoomCenter);
|
|
55
57
|
provideAmap(mapRef);
|
|
56
58
|
const { apiMapDistanceVwOfPoints } = useMapLngLatToVw({ mapRef });
|
|
57
|
-
useAmapWheelZoomCenter({ mapRef, enableRef:
|
|
59
|
+
useAmapWheelZoomCenter({ mapRef, enableRef: touchZoomCenterRef });
|
|
60
|
+
useAmapDoubleClickZoomCenter({ elementRef, mapRef, enableRef: touchZoomCenterRef });
|
|
58
61
|
watchPostEffect((onCleanup) => {
|
|
59
62
|
if (mapRef.value || !elementRef.value)
|
|
60
63
|
return;
|
|
@@ -62,6 +65,7 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
|
|
|
62
65
|
const map = new SafeAmap(elementRef.value, {
|
|
63
66
|
...defaultOptions,
|
|
64
67
|
scrollWheel: defaultOptions.touchZoomCenter ? false : defaultOptions.scrollWheel,
|
|
68
|
+
doubleClickZoom: defaultOptions.touchZoomCenter ? false : defaultOptions.doubleClickZoom,
|
|
65
69
|
vectorMapForeign
|
|
66
70
|
});
|
|
67
71
|
window.GlobalAmap = map;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
2
|
import { type Ref, type ShallowRef } from "vue-demi";
|
|
3
|
-
|
|
3
|
+
import type { AmapMap } from "../types/interface";
|
|
4
|
+
interface UseMapGestureZoomCenterProps<M = AmapMap | google.maps.Map> {
|
|
4
5
|
elementRef: ShallowRef<HTMLDivElement | undefined>;
|
|
5
|
-
mapRef: ShallowRef<
|
|
6
|
+
mapRef: ShallowRef<M | undefined>;
|
|
6
7
|
enableRef: Ref<boolean>;
|
|
7
8
|
}
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const useAmapDoubleClickZoomCenter: (props: UseMapGestureZoomCenterProps<AmapMap>) => void;
|
|
10
|
+
export declare const useGmapGestureZoomCenter: (props: UseMapGestureZoomCenterProps<google.maps.Map>) => void;
|
|
9
11
|
export {};
|
|
@@ -7,6 +7,26 @@ const SCALE_RATIO = 0.1;
|
|
|
7
7
|
const GMAP_MAX_ZOOM = 22;
|
|
8
8
|
const DOUBLE_CLICK_ZOOM_ANIMATION_DURATION = 750;
|
|
9
9
|
const distanceOf = (x, y) => Math.sqrt((y[0] - x[0]) ** 2 + (y[1] - x[1]) ** 2);
|
|
10
|
+
const useAmapDoubleClickZoomCenter = (props) => {
|
|
11
|
+
const { mapRef } = props;
|
|
12
|
+
watch(
|
|
13
|
+
[() => props.elementRef.value, () => props.enableRef.value],
|
|
14
|
+
([element, enable], _, onCleanup) => {
|
|
15
|
+
if (!element || !enable)
|
|
16
|
+
return;
|
|
17
|
+
const handleDoubleTap = () => {
|
|
18
|
+
var _a;
|
|
19
|
+
const map = mapRef.value;
|
|
20
|
+
if (!map)
|
|
21
|
+
return;
|
|
22
|
+
const zoom = (_a = map.getZoom()) != null ? _a : ZOOM_IF_NOT_EXIST;
|
|
23
|
+
map.setZoom(Math.min(GMAP_MAX_ZOOM, zoom + 1), false, DOUBLE_CLICK_ZOOM_ANIMATION_DURATION);
|
|
24
|
+
};
|
|
25
|
+
const unsubscribeDoubleTap = subscribeDoubleTap(element, handleDoubleTap);
|
|
26
|
+
onCleanup(unsubscribeDoubleTap);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
};
|
|
10
30
|
const useGmapGestureZoomCenter = (props) => {
|
|
11
31
|
const { mapRef } = props;
|
|
12
32
|
watch(
|
|
@@ -110,5 +130,6 @@ const useGmapGestureZoomCenter = (props) => {
|
|
|
110
130
|
);
|
|
111
131
|
};
|
|
112
132
|
export {
|
|
133
|
+
useAmapDoubleClickZoomCenter,
|
|
113
134
|
useGmapGestureZoomCenter
|
|
114
135
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "../chunks/index.fbc1adc8.js";
|
|
2
2
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
3
|
-
import { createRunOnce } from "../utils/helper.js";
|
|
4
3
|
import { shallowRef, computed } from "vue";
|
|
5
4
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
6
5
|
var distExports = {};
|
|
@@ -605,7 +604,6 @@ const useAmapLoader = (props) => {
|
|
|
605
604
|
);
|
|
606
605
|
return { statusRef, readyPromise };
|
|
607
606
|
};
|
|
608
|
-
const languageOnlyOnce = createRunOnce((lang) => lang);
|
|
609
607
|
const useGmapLoader = (props) => {
|
|
610
608
|
const { onChange } = props;
|
|
611
609
|
let resolveLoader;
|
|
@@ -625,8 +623,7 @@ const useGmapLoader = (props) => {
|
|
|
625
623
|
watchPostEffectForDeepOption(
|
|
626
624
|
() => optionsRef.value,
|
|
627
625
|
(options) => {
|
|
628
|
-
|
|
629
|
-
const language = languageOnlyOnce((_a = props.language) != null ? _a : "zh");
|
|
626
|
+
const language = navigator.language;
|
|
630
627
|
const loader = new Loader({ ...options, language });
|
|
631
628
|
const setStatusAndExecuteCallback = (status) => {
|
|
632
629
|
statusRef.value = status;
|
package/dist/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "0.9.27-
|
|
3
|
+
const pkgVersion = "0.9.27-google4";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|