tg-map-vue3 3.4.5 → 3.4.7

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/CHANGELOG.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  - feat: 添加矩形[TgRectangle]
6
6
  - feat: 点/圆/矩形/多边形/多段线 在`editable`/`draggable`模式时支持双向绑定
7
+ - fix: 修复[TgCircle]在某些情况下半径会变成0的问题
7
8
  - ***BREAKING CHANGE***: [TgPolygon].polygon, [TgPolyline].polyline 属性, 统一改成`overlay`
8
9
  - ***BREAKING CHANGE***: 修复`setDisableDoubleClickZoom(type)`在google/baidu行为相反的问题, 并且重命名为`setDoubleClickZoom(enable)`
9
10
 
@@ -28,6 +29,7 @@
28
29
  - ***BREAKING CHANGE***: 迁移到Vue3
29
30
 
30
31
  [TgMap]: src/components/TgMap.vue
32
+ [TgCircle]: src/components/overlays/TgCircle.vue
31
33
  [TgRectangle]: src/components/overlays/TgRectangle.vue
32
34
  [TgPolygon]: src/components/overlays/TgPolygon.vue
33
35
  [TgPolyline]: src/components/overlays/TgPolyline.vue
@@ -74,6 +74,14 @@ export declare class LatLngBounds {
74
74
  ne: LatLng;
75
75
  static EMPTY: LatLngBounds;
76
76
  static isBetweenLng(minLng: number, maxLng: number, lng: number): boolean;
77
+ /**
78
+ * 从数组创建bounds
79
+ *
80
+ * 只有{@link positions}为空时, 才会返回`undefined`, 可以借助{@link Arrays.isNotEmpty}协助进行类型推断
81
+ */
82
+ static fromArray(positions: readonly []): undefined;
83
+ /** @see Arrays.isNotEmpty */
84
+ static fromArray(positions: readonly [LatLng, ...LatLng[]]): LatLngBounds;
77
85
  static fromArray(positions: readonly LatLng[]): LatLngBounds | undefined;
78
86
  static from(...positions: LatLng[]): LatLngBounds;
79
87
  static fromGoogle(bounds: google.maps.LatLngBounds, coord: CoordType): LatLngBounds;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="google.maps" />
2
- import type { AnyFunction, Constructor } from '../components';
2
+ import { type AnyFunction, type Constructor } from '../components';
3
3
  export declare namespace Arrays {
4
4
  /**
5
5
  * 浅层比较
@@ -14,6 +14,11 @@ export declare namespace Arrays {
14
14
  function at<T>(arr: T[], index: number, value: T): void;
15
15
  /** 获取 指定位置的值 */
16
16
  function at<T>(arr: T[], index: number): T | undefined;
17
+ /**
18
+ * 判断并推断数组非空
19
+ * @see https://stackoverflow.com/questions/56006111/is-it-possible-to-define-a-non-empty-array-type-in-typescript
20
+ */
21
+ function isNotEmpty<T>(arr: T[]): arr is [T, ...T[]];
17
22
  }
18
23
  export declare namespace MVCArrays {
19
24
  function indexOf<T>(arr: google.maps.MVCArray<T>, item: T): number;
package/dist/tg-map.js CHANGED
@@ -430,33 +430,37 @@ var Ve;
430
430
  })(Ve || (Ve = {}));
431
431
  var ae;
432
432
  ((i) => {
433
- function t(a, h) {
434
- return a.length === h.length && a.every((o, l) => o === h[l]);
433
+ function t(h, o) {
434
+ return h.length === o.length && h.every((l, d) => l === o[d]);
435
435
  }
436
436
  i.equals = t;
437
- function e(a, h) {
438
- const o = a.indexOf(h);
439
- if (o !== -1)
440
- return a.splice(o, 1)[0];
437
+ function e(h, o) {
438
+ const l = h.indexOf(o);
439
+ if (l !== -1)
440
+ return h.splice(l, 1)[0];
441
441
  }
442
442
  i.remove = e;
443
- function r(a, h) {
444
- for (const o of a)
445
- if (o instanceof h)
446
- return o;
443
+ function r(h, o) {
444
+ for (const l of h)
445
+ if (l instanceof o)
446
+ return l;
447
447
  }
448
448
  i.findByType = r;
449
- function s(a, h) {
450
- return a.includes(h);
449
+ function s(h, o) {
450
+ return h.includes(o);
451
451
  }
452
452
  i.includesTyped = s;
453
- function n(a, h, o) {
454
- const l = h >= 0 ? h : a.length + h;
455
- if (o === void 0)
456
- return a[l];
457
- a[l] = o;
453
+ function n(h, o, l) {
454
+ const d = o >= 0 ? o : h.length + o;
455
+ if (l === void 0)
456
+ return h[d];
457
+ h[d] = l;
458
458
  }
459
459
  i.at = n;
460
+ function a(h) {
461
+ return h.length > 0;
462
+ }
463
+ i.isNotEmpty = a;
460
464
  })(ae || (ae = {}));
461
465
  var le;
462
466
  ((i) => {
@@ -2766,14 +2770,18 @@ class at extends ur {
2766
2770
  static create(e) {
2767
2771
  const r = this.coordType, s = new BMap.Circle(e.center.toBaidu(r), e.radius, {
2768
2772
  enableClicking: e.clickable,
2769
- enableEditing: e.editable,
2773
+ // 详见: {@macros circle.baidu.radius_maybe_zero}
2774
+ enableEditing: !1,
2775
+ // options.editable,
2770
2776
  strokeColor: e.strokeColor,
2771
2777
  strokeOpacity: e.strokeOpacity,
2772
2778
  strokeWeight: e.strokeWeight,
2773
2779
  fillColor: e.fillColor,
2774
2780
  fillOpacity: e.fillOpacity
2775
- });
2776
- return new at(s, r, this, { editable: !!e.editable }).visibleOptionInternal(e.visible);
2781
+ }), n = new at(s, r, this, { editable: !!e.editable }).visibleOptionInternal(e.visible);
2782
+ return n.state.editable && setTimeout(() => {
2783
+ n.state.editable && s.enableEditing();
2784
+ }, 0), n;
2777
2785
  }
2778
2786
  createDelegate() {
2779
2787
  return this.eventHubDelegate = new Re(super.createDelegate(), {
@@ -3581,7 +3589,7 @@ class vt extends yt {
3581
3589
  strokeOpacity: e.strokeOpacity,
3582
3590
  strokeWeight: e.strokeWeight
3583
3591
  });
3584
- return new vt(s, r, this, { editable: e.editable === !0 }).visibleOptionInternal(e.visible);
3592
+ return new vt(s, r, this, { editable: !!e.editable }).visibleOptionInternal(e.visible);
3585
3593
  }
3586
3594
  getPath() {
3587
3595
  return this.innerOverlay.getPath().map((e) => y.fromBaidu(e, this.coordType));
@@ -5774,7 +5782,7 @@ const Gs = {
5774
5782
  getDestination: ns
5775
5783
  }, Zs = {
5776
5784
  install(i, t) {
5777
- qr(t), i.config.unwrapInjectedRef = !0;
5785
+ qr(t);
5778
5786
  const e = i.config.optionMergeStrategies;
5779
5787
  e[be] = e[Me] = (r, s) => r ? [...new Set([].concat(r, s))] : Array.isArray(s) ? s : [s];
5780
5788
  }