tg-map-vue3 3.7.0 → 3.7.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.
@@ -202,16 +202,16 @@ declare const _default: import("vue").DefineComponent<{
202
202
  "onUpdate:last-center"?: ((event: LatLng) => any) | undefined;
203
203
  onClick?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
204
204
  onDblclick?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
205
- onRightclick?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
206
- onContextmenu?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
207
205
  onMousedown?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
208
206
  onMouseup?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
209
207
  onMouseout?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
210
208
  onMouseover?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
209
+ "onCenter-changed"?: ((event: import("../map/event").Tg.Event) => any) | undefined;
210
+ onRightclick?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
211
+ onContextmenu?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
211
212
  onDragstart?: ((event: import("../map/event").Tg.Event) => any) | undefined;
212
213
  onDrag?: ((event: import("../map/event").Tg.Event) => any) | undefined;
213
214
  onDragend?: ((event: import("../map/event").Tg.Event) => any) | undefined;
214
- "onCenter-changed"?: ((event: import("../map/event").Tg.Event) => any) | undefined;
215
215
  onMousemove?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
216
216
  onTilesloaded?: ((event: import("../map/event").Tg.Event) => any) | undefined;
217
217
  "onZoom-changed"?: ((event: import("../map/event").Tg.Event) => any) | undefined;
@@ -243,12 +243,12 @@ declare const TgMarker: import("vue").DefineComponent<{
243
243
  }>> & {
244
244
  onClick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
245
245
  onDblclick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
246
- onRightclick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
247
- onContextmenu?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
248
246
  onMousedown?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
249
247
  onMouseup?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
250
248
  onMouseout?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
251
249
  onMouseover?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
250
+ onRightclick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
251
+ onContextmenu?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
252
252
  onDragstart?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
253
253
  onDrag?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
254
254
  onDragend?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
@@ -5,7 +5,6 @@ import { CoordType, LatLng } from '../../lat-lng';
5
5
  import type { UnionBaiduIcon, UnionGoogleIcon } from '../../unions';
6
6
  import type { BaiduMap } from '../baidu-map';
7
7
  import type { GoogleMap } from '../google-map';
8
- import type { AbstractMap } from '../map';
9
8
  import type { BaiduInfoBox } from './baidu-info-box';
10
9
  import { UnionIcon } from './icon';
11
10
  import type { BaiduLabelOverlay, GoogleLabelOverlay, LabelOverlay } from './label';
@@ -86,12 +85,13 @@ export interface Marker extends Tg.EventTargetTyped<Marker, MarkerEventMap> {
86
85
  export type MarkerOverlay = Marker & Overlay;
87
86
  export type BMarker = BMap.Marker & {
88
87
  __info_box__?: BaiduInfoBox;
88
+ __create_by_tg__?: boolean;
89
89
  };
90
90
  export declare class BaiduMarker extends BaiduOverlay<BMarker> implements Marker {
91
91
  /** baidu的Marker不支持读/写clickable等属性, 故只能将创建临时的clickable保存在这个state中 */
92
92
  private state;
93
93
  static create(this: BaiduMap, options: MarkerOptions): BaiduMarker;
94
- constructor(innerOverlay: BMap.Marker, coordType: CoordType, map: AbstractMap,
94
+ constructor(innerOverlay: BMap.Marker, coordType: CoordType, map: BaiduMap,
95
95
  /** baidu的Marker不支持读/写clickable等属性, 故只能将创建临时的clickable保存在这个state中 */
96
96
  state: {
97
97
  clickable: boolean;
@@ -2,6 +2,8 @@ import type { Tg } from '../../event';
2
2
  import { type EventTargetDelegate } from '../../event-target';
3
3
  import type { CoordType } from '../../lat-lng';
4
4
  import type { UnionBaiduOverlay, UnionGoogleOverlay } from '../../unions';
5
+ import type { BaiduMap } from '../baidu-map';
6
+ import type { GoogleMap } from '../google-map';
5
7
  import type { AbstractMap } from '../map';
6
8
  export interface OverlayOptions {
7
9
  /** @default true */
@@ -11,10 +13,10 @@ export declare abstract class Overlay<T = unknown> implements Tg.EventTarget {
11
13
  innerOverlay: T;
12
14
  /** 用于保存Overlay内部点的坐标, 它的值有可能和map的不同 */
13
15
  protected coordType: CoordType;
14
- protected map: AbstractMap;
15
16
  constructor(innerOverlay: T,
16
17
  /** 用于保存Overlay内部点的坐标, 它的值有可能和map的不同 */
17
- coordType: CoordType, map: AbstractMap);
18
+ coordType: CoordType);
19
+ protected abstract map: AbstractMap;
18
20
  protected abstract createDelegate(): EventTargetDelegate;
19
21
  private _delegate;
20
22
  private get delegate();
@@ -25,13 +27,15 @@ export declare abstract class Overlay<T = unknown> implements Tg.EventTarget {
25
27
  abstract setVisible(visible: boolean): void;
26
28
  }
27
29
  export declare class GoogleOverlay<T extends UnionGoogleOverlay = UnionGoogleOverlay> extends Overlay<T> {
28
- constructor(innerOverlay: T, coordType: CoordType, map: AbstractMap);
30
+ protected map: GoogleMap;
31
+ constructor(innerOverlay: T, coordType: CoordType, map: GoogleMap);
29
32
  protected createDelegate(): EventTargetDelegate;
30
33
  isVisible(): boolean;
31
34
  setVisible(visible: boolean): void;
32
35
  }
33
36
  export declare class BaiduOverlay<T extends UnionBaiduOverlay = UnionBaiduOverlay> extends Overlay<T> {
34
- constructor(innerOverlay: T, coordType: CoordType, map: AbstractMap);
37
+ protected map: BaiduMap;
38
+ constructor(innerOverlay: T, coordType: CoordType, map: BaiduMap);
35
39
  protected createDelegate(): EventTargetDelegate;
36
40
  /** 仅限内部使用; 设为private时, 生成的d.ts文件中, 方法返回值会变成any, 故改成了public */
37
41
  get overlay(): Required<Pick<UnionBaiduOverlay, "isVisible" | "show" | "hide">>;
@@ -29,6 +29,11 @@ export type PolylineEventMap = {
29
29
  };
30
30
  export interface PolylineOptions extends NotFillableShapeOptions {
31
31
  path: LatLng[];
32
+ /**
33
+ * ## 不同行为
34
+ * - google: 功能正常
35
+ * - baidu: 百度地图在移除Polyline时, icons不会被移除, 导致错乱, 这里通过复写{@link BaiduPolyline.remove}, 规避了该bug
36
+ */
32
37
  icons?: IconSequence[];
33
38
  }
34
39
  export interface Polyline extends Tg.EventTargetTyped<Polyline, PolylineEventMap>, NotFillableShape {
@@ -52,6 +57,7 @@ export declare class BaiduPolyline extends BaiduPolyShape<BMap.Polyline> impleme
52
57
  protected pathEditedEventType: string;
53
58
  getPath(): LatLng[];
54
59
  setPath(path: LatLng[]): void;
60
+ remove(): void;
55
61
  }
56
62
  /**
57
63
  * Google地图的网页版不支持Advanced Polyline(纹理/渐变等效果), 详见: https://issuetracker.google.com/issues/267845944
@@ -1,12 +1,18 @@
1
1
  import type { CoordType } from '../../lat-lng';
2
2
  import type { UnionBaiduShape, UnionGoogleShape } from '../../unions';
3
3
  import type { BaiduMap } from '../baidu-map';
4
+ import type { SymbolIcon } from './icon';
4
5
  import { BaiduOverlay, GoogleOverlay, type OverlayOptions } from './overlay';
5
6
  export interface ShapeOptions extends OverlayOptions {
6
7
  clickable?: boolean;
7
8
  editable?: boolean;
8
9
  strokeColor?: string;
9
10
  strokeOpacity?: number;
11
+ /**
12
+ * ## 取值范围不同
13
+ * - google: 最大值约为32, 更大的值不影响线宽
14
+ * - baidu: 没有上限
15
+ */
10
16
  strokeWeight?: number;
11
17
  fillColor?: string;
12
18
  fillOpacity?: number;
@@ -27,6 +33,7 @@ export type NotFillableShapeOptions = Omit<ShapeOptions, 'fillColor' | 'fillOpac
27
33
  export declare abstract class BaiduShape<T extends UnionBaiduShape> extends BaiduOverlay<T> implements Shape {
28
34
  protected state: {
29
35
  editable: boolean;
36
+ symbolIcons?: SymbolIcon[];
30
37
  };
31
38
  /**
32
39
  * baidu地图的透明度属性有如下问题:
@@ -37,6 +44,7 @@ export declare abstract class BaiduShape<T extends UnionBaiduShape> extends Baid
37
44
  static OPACITY_DELTA: number;
38
45
  constructor(innerOverlay: T, coordType: CoordType, map: BaiduMap, state: {
39
46
  editable: boolean;
47
+ symbolIcons?: SymbolIcon[];
40
48
  });
41
49
  isEditable(): boolean;
42
50
  setEditable(editable: boolean): void;
package/dist/tg-map.js CHANGED
@@ -2871,9 +2871,9 @@ var j = /* @__PURE__ */ ((i) => (i.auto = "auto", i.none = "none", i.greedy = "g
2871
2871
  i.create = t;
2872
2872
  })(lt || (lt = {}));
2873
2873
  class Er {
2874
- constructor(t, e, r) {
2874
+ constructor(t, e) {
2875
2875
  c(this, "_delegate");
2876
- this.innerOverlay = t, this.coordType = e, this.map = r;
2876
+ this.innerOverlay = t, this.coordType = e;
2877
2877
  }
2878
2878
  get delegate() {
2879
2879
  return this._delegate ?? (this._delegate = this.createDelegate().setTarget(this)), this._delegate;
@@ -2890,7 +2890,7 @@ class Er {
2890
2890
  }
2891
2891
  class Mt extends Er {
2892
2892
  constructor(t, e, r) {
2893
- super(t, e, r);
2893
+ super(t, e), this.map = r;
2894
2894
  }
2895
2895
  createDelegate() {
2896
2896
  return new re(this.innerOverlay, this.map);
@@ -2904,7 +2904,7 @@ class Mt extends Er {
2904
2904
  }
2905
2905
  class Ye extends Er {
2906
2906
  constructor(t, e, r) {
2907
- super(t, e, r);
2907
+ super(t, e), this.map = r;
2908
2908
  }
2909
2909
  createDelegate() {
2910
2910
  return new ae(this.innerOverlay, this.map);
@@ -3777,7 +3777,7 @@ class Le extends Ye {
3777
3777
  raiseOnDrag: t.crossOnDrag === void 0 ? !0 : t.crossOnDrag,
3778
3778
  draggingCursor: t.cursor
3779
3779
  }, n = new BMap.Marker(t.position.toBaidu(e, t.normalizePositionForBaidu), s);
3780
- t.zIndex !== void 0 && n.setZIndex(t.zIndex);
3780
+ n.__create_by_tg__ = !0, t.zIndex !== void 0 && n.setZIndex(t.zIndex);
3781
3781
  const a = t.clickable === void 0 ? !0 : t.clickable, h = !!t.draggable;
3782
3782
  return new Le(n, e, this, { clickable: a, draggable: h, zIndex: t.zIndex, normalize: t.normalizePositionForBaidu }).visibleOptionInternal(t.visible);
3783
3783
  }
@@ -3948,8 +3948,8 @@ class At extends St {
3948
3948
  c(this, "pathEditedEventType", "path-edited");
3949
3949
  }
3950
3950
  static create(e) {
3951
- var n;
3952
- const r = this.coordType, s = new BMap.Polyline(e.path.map((a) => a.toBaidu(r)), {
3951
+ var n, a;
3952
+ const r = this.coordType, s = new BMap.Polyline(e.path.map((h) => h.toBaidu(r)), {
3953
3953
  enableClicking: e.clickable,
3954
3954
  enableEditing: e.editable,
3955
3955
  strokeColor: e.strokeColor,
@@ -3957,7 +3957,10 @@ class At extends St {
3957
3957
  strokeWeight: e.strokeWeight,
3958
3958
  icons: (n = e.icons) == null ? void 0 : n.map(Ze.toBaidu)
3959
3959
  });
3960
- return new At(s, r, this, { editable: !!e.editable }).visibleOptionInternal(e.visible);
3960
+ return new At(s, r, this, {
3961
+ editable: !!e.editable,
3962
+ symbolIcons: (a = e.icons) == null ? void 0 : a.map((h) => h.icon)
3963
+ }).visibleOptionInternal(e.visible);
3961
3964
  }
3962
3965
  getPath() {
3963
3966
  return this.innerOverlay.getPath().map((e) => y.fromBaidu(e, this.coordType));
@@ -3965,6 +3968,22 @@ class At extends St {
3965
3968
  setPath(e) {
3966
3969
  this.coordType = this.map.coordType, this.setPathInternal(e.map((r) => r.toBaidu(this.coordType)));
3967
3970
  }
3971
+ remove() {
3972
+ var e;
3973
+ super.remove(), (e = this.state.symbolIcons) != null && e.length && this.map.innerMap.getOverlays().filter((s) => {
3974
+ var o;
3975
+ if (!(s instanceof BMap.Marker))
3976
+ return !1;
3977
+ const n = s;
3978
+ if (n.__create_by_tg__)
3979
+ return !1;
3980
+ const a = n.getIcon();
3981
+ if (!(a instanceof BMap.Symbol))
3982
+ return !1;
3983
+ const h = a;
3984
+ return h.__icon__ ? (o = this.state.symbolIcons) == null ? void 0 : o.includes(h.__icon__) : !1;
3985
+ }).forEach((s) => this.map.innerMap.removeOverlay(s));
3986
+ }
3968
3987
  }
3969
3988
  class Rt extends qe {
3970
3989
  constructor() {
@@ -5922,7 +5941,7 @@ const Es = /* @__PURE__ */ K(Cs, [["render", ws]]), Ls = w({
5922
5941
  });
5923
5942
  },
5924
5943
  onDestroy() {
5925
- this.$map.removeOverlay(this.overlay);
5944
+ this.overlay.remove();
5926
5945
  }
5927
5946
  }), Ps = w({
5928
5947
  name: "tg-rectangle",