@heycar/heycars-map 0.9.27-google3 → 0.9.27-google5

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.
@@ -1,4 +1,4 @@
1
- import "../../css/PlaceCircle-2369f992.css";
1
+ import "../../css/PlaceCircle-3c051f4e.css";
2
2
  import { computed, h } from "vue";
3
3
  import "../../chunks/index.fbc1adc8.js";
4
4
  import { ZINDEX_PLACE_LAYER } from "../../api/contants.js";
@@ -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: computed(() => !!props.touchZoomCenter) });
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;
@@ -12,7 +12,6 @@
12
12
  margin-left: -2.265vw;
13
13
  }
14
14
  .fhyw85 {
15
- margin-bottom: -2.265vw;
16
15
  width: max-content;
17
16
  }
18
17
  .fhyw86 {
@@ -1,9 +1,11 @@
1
1
  /// <reference types="google.maps" />
2
2
  import { type Ref, type ShallowRef } from "vue-demi";
3
- interface UseMapGestureZoomCenterProps {
3
+ import type { AmapMap } from "../types/interface";
4
+ interface UseMapGestureZoomCenterProps<M = AmapMap | google.maps.Map> {
4
5
  elementRef: ShallowRef<HTMLDivElement | undefined>;
5
- mapRef: ShallowRef<google.maps.Map | undefined>;
6
+ mapRef: ShallowRef<M | undefined>;
6
7
  enableRef: Ref<boolean>;
7
8
  }
8
- export declare const useGmapGestureZoomCenter: (props: UseMapGestureZoomCenterProps) => void;
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
- var _a;
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-google3";
3
+ const pkgVersion = "0.9.27-google5";
4
4
  const isEnableLog = (name) => {
5
5
  const searchParam = new URLSearchParams(location.search);
6
6
  return searchParam.has(`log-${name}`);
@@ -77,7 +77,6 @@ const isGeoPositionEqual = (p1, p2) => {
77
77
  const isZoneEqual = (z1, z2) => {
78
78
  return z1.path.every((point, idx) => isPointEqual(point, z2 == null ? void 0 : z2.path[idx]));
79
79
  };
80
- const ILLEGAL_DISPLAY_NAME_WITHOUT_STREET_NUMBER_REGEX = /(?:^\s*$|\(\)|())/;
81
80
  const amapPlaceName2DisplayName = (name, options) => {
82
81
  const { isChina } = options;
83
82
  if (!name)
@@ -85,19 +84,19 @@ const amapPlaceName2DisplayName = (name, options) => {
85
84
  return isChina ? amapPlaceName2DisplayNameInChina(name, options) : amapPlaceName2DisplayNameOutChina(name, options);
86
85
  };
87
86
  function amapPlaceName2DisplayNameInChina(name, options) {
88
- const { province, city, district, township, building, neighborhood, street, streetNumber } = options;
87
+ const { province, city, district, township, building, neighborhood } = options;
89
88
  if (building)
90
89
  return building;
91
90
  if (neighborhood)
92
91
  return neighborhood;
93
92
  let result = name;
94
93
  for (const item of [province, city, district, township]) {
95
- if (result.trim() === item)
96
- return item;
97
- result = result.replace(item, "");
94
+ const replacedName = result.replace(item, "");
95
+ if (replacedName.length < 20)
96
+ return replacedName;
97
+ result = replacedName;
98
98
  }
99
- const resultWithoutStreetNumber = result.replace(street, "").replace(streetNumber, "");
100
- return ILLEGAL_DISPLAY_NAME_WITHOUT_STREET_NUMBER_REGEX.test(resultWithoutStreetNumber) ? result : resultWithoutStreetNumber;
99
+ return result;
101
100
  }
102
101
  const NOT_ONLY_NUMBERS_REGEX = /[^\d\s-]/;
103
102
  function amapPlaceName2DisplayNameOutChina(name, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.9.27-google3",
3
+ "version": "0.9.27-google5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js"