@heycar/heycars-map 0.6.9 → 0.6.11

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.
@@ -15,8 +15,9 @@ export interface AmapProps extends Omit<AMap.MapOptions, "vectorMapForeign"> {
15
15
  touchZoomCenter?: 0 | 1;
16
16
  onDragStart?: MapEventHandler<AMap.Map>;
17
17
  onDragEnd?: MapEventHandler<AMap.Map>;
18
+ onZoomStart?: MapEventHandler<AMap.Map>;
18
19
  onZoomEnd?: MapEventHandler<AMap.Map>;
19
20
  onResize?: MapEventHandler<AMap.Map>;
20
21
  onMoveend?: MapEventHandler<AMap.Map>;
21
22
  }
22
- export declare const Amap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<AmapProps>, 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<AmapProps, Required<AmapProps>>, "resize" | "moveend" | "dragStart" | "dragEnd" | "zoomEnd", AmapProps, {}>;
23
+ export declare const Amap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<AmapProps>, 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<AmapProps, Required<AmapProps>>, "resize" | "moveend" | "dragStart" | "dragEnd" | "zoomStart" | "zoomEnd", AmapProps, {}>;
package/dist/index.cjs CHANGED
@@ -1893,6 +1893,34 @@ const useMapLoader = (props) => {
1893
1893
  onChange
1894
1894
  });
1895
1895
  };
1896
+ var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
1897
+ WEBGL_STATUS2["NOT_SUPPORTED"] = "NOT_SUPPORTED";
1898
+ WEBGL_STATUS2["DISABLED"] = "DISABLED";
1899
+ WEBGL_STATUS2["ENABLED"] = "ENABLED";
1900
+ return WEBGL_STATUS2;
1901
+ })(WEBGL_STATUS || {});
1902
+ function detectWebGL() {
1903
+ if (typeof window === "undefined")
1904
+ return "NOT_SUPPORTED";
1905
+ if (window.WebGLRenderingContext) {
1906
+ const canvas = document.createElement("canvas");
1907
+ const names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"];
1908
+ let context2 = null;
1909
+ for (const name of names) {
1910
+ try {
1911
+ context2 = canvas.getContext(name);
1912
+ if (context2 && typeof context2.getParameter === "function") {
1913
+ return "ENABLED";
1914
+ }
1915
+ } catch (e) {
1916
+ console.error("MyError: detectWebGL catch e = ", e);
1917
+ return "NOT_SUPPORTED";
1918
+ }
1919
+ }
1920
+ return "DISABLED";
1921
+ }
1922
+ return "NOT_SUPPORTED";
1923
+ }
1896
1924
  const ZOOM_WHEEL_RATIO = -135e-5;
1897
1925
  const useAmapWheelZoomCenter = (props) => {
1898
1926
  const { mapRef, enableRef } = props;
@@ -1984,7 +2012,7 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
1984
2012
  );
1985
2013
  watchNoneImmediatePostEffectForMapProperty(mapRef, props, [
1986
2014
  { name: "center", defaultValue: [0, 0] },
1987
- { name: "zooms", defaultValue: [0, 0] },
2015
+ { name: "zooms", defaultValue: [2, 20] },
1988
2016
  { name: "zoom", defaultValue: 0 },
1989
2017
  { name: "layers", defaultValue: [] },
1990
2018
  { name: "limitBounds", defaultValue: [] },
@@ -2134,7 +2162,6 @@ var createRuntimeFn = (config) => (options) => {
2134
2162
  return className;
2135
2163
  };
2136
2164
  var gmap = "_7anfuo0";
2137
- createRuntimeFn({ defaultClassName: "", variantClassNames: { enable: { true: "_7anfuo1", false: "_7anfuo2" } }, defaultVariants: {}, compoundVariants: [] });
2138
2165
  const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
2139
2166
  const setMap = props.mapRef;
2140
2167
  const { onResize } = props;
@@ -2207,6 +2234,9 @@ const Loading = defineSetup(function Loading2() {
2207
2234
  })]);
2208
2235
  });
2209
2236
  window.movingDraw = !new URLSearchParams(location.search).has("disableMovingDraw");
2237
+ if (detectWebGL() === WEBGL_STATUS.ENABLED) {
2238
+ window.forceWebGL = true;
2239
+ }
2210
2240
  const MapProvider = defineLagecySetup(function MapProvider2(props, {
2211
2241
  slots
2212
2242
  }) {
@@ -3385,12 +3415,28 @@ const useAmapDrag = (props) => {
3385
3415
  const centerRef = Vue.ref([0, 0]);
3386
3416
  const isDragging = Vue.ref(false);
3387
3417
  const isDragEndWaitingMovingEndRef = Vue.ref(false);
3418
+ let isZoom = false;
3419
+ let zoomStartCenter = void 0;
3388
3420
  let watchId = void 0;
3389
3421
  const emitDragStart = () => {
3390
3422
  pipeAsync(() => {
3391
3423
  isDragging.value = true;
3392
3424
  })();
3393
3425
  };
3426
+ const handleZoomStart = () => {
3427
+ var _a;
3428
+ isZoom = true;
3429
+ zoomStartCenter = (_a = mapRef.value) == null ? void 0 : _a.getCenter().toJSON();
3430
+ };
3431
+ const handleChange = (value) => {
3432
+ console.log("useAmapDrag value, zoomStartCenter = ", value, zoomStartCenter);
3433
+ if (isZoom) {
3434
+ isZoom = false;
3435
+ if (isPointEqual(value, zoomStartCenter))
3436
+ return;
3437
+ }
3438
+ onChange == null ? void 0 : onChange(value);
3439
+ };
3394
3440
  const handleDragEndWithAnimationEnd = (target) => {
3395
3441
  var _a;
3396
3442
  isDragEndWaitingMovingEndRef.value = false;
@@ -3398,7 +3444,7 @@ const useAmapDrag = (props) => {
3398
3444
  const { lng, lat } = target.getCenter();
3399
3445
  spaceLog("onDragEndWithAnimationEnd", "[lng, lat] = ", [lng, lat]);
3400
3446
  centerRef.value = [lng, lat];
3401
- (_a = pipeAsync(onChange)) == null ? void 0 : _a([lng, lat]);
3447
+ (_a = pipeAsync(handleChange)) == null ? void 0 : _a([lng, lat]);
3402
3448
  };
3403
3449
  const emitDragEnd = (_, { target }) => {
3404
3450
  const { lng: baseLng, lat: baseLat } = target.getCenter();
@@ -3420,6 +3466,9 @@ const useAmapDrag = (props) => {
3420
3466
  return;
3421
3467
  handleDragEndWithAnimationEnd(target);
3422
3468
  };
3469
+ watchPostEffectForAMapEvent(mapRef, {}, handleZoomStart, [
3470
+ "onZoomStart"
3471
+ ]);
3423
3472
  watchPostEffectForAMapEvent(mapRef, {}, emitDragStart, [
3424
3473
  "onDragStart"
3425
3474
  ]);
package/dist/index.js CHANGED
@@ -1891,6 +1891,34 @@ const useMapLoader = (props) => {
1891
1891
  onChange
1892
1892
  });
1893
1893
  };
1894
+ var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
1895
+ WEBGL_STATUS2["NOT_SUPPORTED"] = "NOT_SUPPORTED";
1896
+ WEBGL_STATUS2["DISABLED"] = "DISABLED";
1897
+ WEBGL_STATUS2["ENABLED"] = "ENABLED";
1898
+ return WEBGL_STATUS2;
1899
+ })(WEBGL_STATUS || {});
1900
+ function detectWebGL() {
1901
+ if (typeof window === "undefined")
1902
+ return "NOT_SUPPORTED";
1903
+ if (window.WebGLRenderingContext) {
1904
+ const canvas = document.createElement("canvas");
1905
+ const names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"];
1906
+ let context2 = null;
1907
+ for (const name of names) {
1908
+ try {
1909
+ context2 = canvas.getContext(name);
1910
+ if (context2 && typeof context2.getParameter === "function") {
1911
+ return "ENABLED";
1912
+ }
1913
+ } catch (e) {
1914
+ console.error("MyError: detectWebGL catch e = ", e);
1915
+ return "NOT_SUPPORTED";
1916
+ }
1917
+ }
1918
+ return "DISABLED";
1919
+ }
1920
+ return "NOT_SUPPORTED";
1921
+ }
1894
1922
  const ZOOM_WHEEL_RATIO = -135e-5;
1895
1923
  const useAmapWheelZoomCenter = (props) => {
1896
1924
  const { mapRef, enableRef } = props;
@@ -1982,7 +2010,7 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
1982
2010
  );
1983
2011
  watchNoneImmediatePostEffectForMapProperty(mapRef, props, [
1984
2012
  { name: "center", defaultValue: [0, 0] },
1985
- { name: "zooms", defaultValue: [0, 0] },
2013
+ { name: "zooms", defaultValue: [2, 20] },
1986
2014
  { name: "zoom", defaultValue: 0 },
1987
2015
  { name: "layers", defaultValue: [] },
1988
2016
  { name: "limitBounds", defaultValue: [] },
@@ -2132,7 +2160,6 @@ var createRuntimeFn = (config) => (options) => {
2132
2160
  return className;
2133
2161
  };
2134
2162
  var gmap = "_7anfuo0";
2135
- createRuntimeFn({ defaultClassName: "", variantClassNames: { enable: { true: "_7anfuo1", false: "_7anfuo2" } }, defaultVariants: {}, compoundVariants: [] });
2136
2163
  const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
2137
2164
  const setMap = props.mapRef;
2138
2165
  const { onResize } = props;
@@ -2205,6 +2232,9 @@ const Loading = defineSetup(function Loading2() {
2205
2232
  })]);
2206
2233
  });
2207
2234
  window.movingDraw = !new URLSearchParams(location.search).has("disableMovingDraw");
2235
+ if (detectWebGL() === WEBGL_STATUS.ENABLED) {
2236
+ window.forceWebGL = true;
2237
+ }
2208
2238
  const MapProvider = defineLagecySetup(function MapProvider2(props, {
2209
2239
  slots
2210
2240
  }) {
@@ -3383,12 +3413,28 @@ const useAmapDrag = (props) => {
3383
3413
  const centerRef = ref([0, 0]);
3384
3414
  const isDragging = ref(false);
3385
3415
  const isDragEndWaitingMovingEndRef = ref(false);
3416
+ let isZoom = false;
3417
+ let zoomStartCenter = void 0;
3386
3418
  let watchId = void 0;
3387
3419
  const emitDragStart = () => {
3388
3420
  pipeAsync(() => {
3389
3421
  isDragging.value = true;
3390
3422
  })();
3391
3423
  };
3424
+ const handleZoomStart = () => {
3425
+ var _a;
3426
+ isZoom = true;
3427
+ zoomStartCenter = (_a = mapRef.value) == null ? void 0 : _a.getCenter().toJSON();
3428
+ };
3429
+ const handleChange = (value) => {
3430
+ console.log("useAmapDrag value, zoomStartCenter = ", value, zoomStartCenter);
3431
+ if (isZoom) {
3432
+ isZoom = false;
3433
+ if (isPointEqual(value, zoomStartCenter))
3434
+ return;
3435
+ }
3436
+ onChange == null ? void 0 : onChange(value);
3437
+ };
3392
3438
  const handleDragEndWithAnimationEnd = (target) => {
3393
3439
  var _a;
3394
3440
  isDragEndWaitingMovingEndRef.value = false;
@@ -3396,7 +3442,7 @@ const useAmapDrag = (props) => {
3396
3442
  const { lng, lat } = target.getCenter();
3397
3443
  spaceLog("onDragEndWithAnimationEnd", "[lng, lat] = ", [lng, lat]);
3398
3444
  centerRef.value = [lng, lat];
3399
- (_a = pipeAsync(onChange)) == null ? void 0 : _a([lng, lat]);
3445
+ (_a = pipeAsync(handleChange)) == null ? void 0 : _a([lng, lat]);
3400
3446
  };
3401
3447
  const emitDragEnd = (_, { target }) => {
3402
3448
  const { lng: baseLng, lat: baseLat } = target.getCenter();
@@ -3418,6 +3464,9 @@ const useAmapDrag = (props) => {
3418
3464
  return;
3419
3465
  handleDragEndWithAnimationEnd(target);
3420
3466
  };
3467
+ watchPostEffectForAMapEvent(mapRef, {}, handleZoomStart, [
3468
+ "onZoomStart"
3469
+ ]);
3421
3470
  watchPostEffectForAMapEvent(mapRef, {}, emitDragStart, [
3422
3471
  "onDragStart"
3423
3472
  ]);
@@ -0,0 +1,25 @@
1
+ export declare enum BRWOSER_PLATFORM {
2
+ WECHAT = "WECHAT",
3
+ WECHAT_MINIPROGRAM = "WECHAT_MINIPROGRAM",
4
+ ALIPAY = "ALIPAY",
5
+ ALIPAY_MINIPROGRAM = "ALIPAY_MINIPROGRAM",
6
+ H5 = "H5",
7
+ NODE_JS = "NODE_JS"
8
+ }
9
+ export declare enum OS_PLATFORM {
10
+ IOS = "IOS",
11
+ ANDROID = "ANDROID",
12
+ OTHER = "OTHER"
13
+ }
14
+ export declare enum WEBGL_STATUS {
15
+ NOT_SUPPORTED = "NOT_SUPPORTED",
16
+ DISABLED = "DISABLED",
17
+ ENABLED = "ENABLED"
18
+ }
19
+ export declare const detectBrowserPlatform: () => BRWOSER_PLATFORM;
20
+ export declare const detectOSPlatform: () => OS_PLATFORM;
21
+ /**
22
+ * Detects if WebGL is enabled.
23
+ * Inspired from http://www.browserleaks.com/webgl#howto-detect-webgl
24
+ */
25
+ export declare function detectWebGL(): WEBGL_STATUS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.6.9",
3
+ "version": "0.6.11",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
package/todo.md CHANGED
@@ -1,131 +1,6 @@
1
1
  https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-component-like-airbnb-in-nextjs
2
2
 
3
- 2. Google 地址名称太长
4
- 3. 高德地图加载期间出现大量的请求
5
- 4. map 的两个 slot loading 和 error slot 没有生效
6
- 5. 企业微信如果关闭定位,会不停的跳 geoError 事件
7
-
8
- 二期:
9
-
10
- 1. 绿区数据格式约定
11
- 2. map loading 设计稿
12
-
13
- 缩放问题
14
-
15
- - 4867
16
- - 4920
17
-
18
- 章新华
19
-
20
- - 5238
21
-
22
- 不明白的
23
-
24
- - 5294
25
-
26
- 需要复现
27
-
28
- - 5044
29
- - 5113
30
- - 5291
31
- - 5257 我的 safari 没有问题
32
-
33
- 0.4.3
34
-
35
- - 5105
36
-
37
- 0.4.4
38
-
39
- - 5057
40
-
41
- 0.4.5
42
-
43
- - 5215
44
-
45
- 0.4.6
46
-
47
- - 4824
48
- - 4809
49
- - 4836
50
- - 4915
51
- - 5228
52
-
53
- 0.4.8
54
-
55
- - 5014
56
-
57
- 0.4.9
58
-
59
- - 4903
60
- - 5006
61
- - 5017
62
- - 5238
63
-
64
- 0.5.0
65
-
66
- - 5284
67
- - 5314
68
- - 5313
69
- - 5297
70
- - 5277
71
- - 5244
72
- - 5198
73
- - 5173
74
- - 5168
75
-
76
- 0.5.1
77
-
78
- - 5303
79
- - 5329
80
- - 4769
81
- - 5044 (跟章新华说下)
82
- - 5314
83
- - 5347
84
- - 5348
85
- - 5057
86
-
87
- 0.5.3
88
-
89
- - 4867
90
- - 4920
91
- - 5252
92
- - 5366
93
- - 5364
94
- - 5373
95
-
96
- 0.5.4
97
-
98
- - 5375
99
- - 4946
100
-
101
- 0.5.5
102
-
103
- - 4977
104
- - 5381
105
-
106
- 0.5.6
107
-
108
- - 5455
109
-
110
- 0.5.9
111
-
112
- - 5500
113
- - 5524
114
-
115
- 0.6.3
116
-
117
- - 5623
118
- - 5625
119
- - 5550
120
- - 5546
121
- - 5541
122
- - 5540
123
-
124
- 0.6.5
125
-
126
- - 5640
127
- - 5631
128
- - 5614
129
- - 5598
130
- - 5567
131
- - 5560
3
+ 1. Google 地址名称太长
4
+ 2. 企业微信如果关闭定位,会不停的跳 geoError 事件
5
+ 3. regeo 不应该阻塞 getRecommendPlace
6
+ 4. 手机缩放导致 onPlaceChange 触发,并且 getRecommendPlace 也被调用了