tg-map-vue3 3.0.6 → 3.0.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.
@@ -1,9 +1,8 @@
1
- import { type PropType } from 'vue';
1
+ import { type PropType, type Prop } from 'vue';
2
2
  import type { AbstractMap } from '../map/map/map';
3
3
  import { TgMapType } from '../map/map-factory';
4
4
  import { LatLng } from '../map/lat-lng';
5
5
  import { type InfoWindowMode, GestureHandlingOptions } from '../map/map/map-options';
6
- import type { Prop } from 'vue';
7
6
  declare const _default: import("vue").DefineComponent<{
8
7
  /** type没做响应式, 但外部可以把type作为tg-map的key, 让type修改时完全重建tg-map */
9
8
  type: {
@@ -3,7 +3,7 @@ import { Point } from '../../types';
3
3
  import type { BMarker } from './marker';
4
4
  import './baidu-info-box.scss';
5
5
  export type BaiduInfoBox = InstanceType<ReturnType<typeof createBaiduInfoBoxClass>>;
6
- export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: String): {
6
+ export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: string): {
7
7
  container: HTMLElement;
8
8
  border: HTMLElement;
9
9
  inner: HTMLElement;
@@ -44,7 +44,7 @@ export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap
44
44
  * 3. 和MarkerClusterer的配合并不好, 重建聚合时会使InfoWindow消失
45
45
  */
46
46
  declare function createBaiduInfoBoxClass(): {
47
- new (content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: String): {
47
+ new (content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: string): {
48
48
  container: HTMLElement;
49
49
  border: HTMLElement;
50
50
  inner: HTMLElement;
@@ -1,4 +1,4 @@
1
- import type { Component, ComponentPublicInstance } from "vue";
1
+ import type { Component, ComponentPublicInstance } from 'vue';
2
2
  /** deep版的 `Partial` */
3
3
  export type DeepPartial<T> = {
4
4
  [U in keyof T]?: T[U] extends object ? DeepPartial<T[U]> : T[U];
@@ -4,6 +4,7 @@ import type { AbstractConstructor, KeysMatching, StringEnumLike, Thing } from '.
4
4
  export type VueHookName = ExcludeSubtype<KeysMatching<OmitStartsWith<RemoveIndex<ComponentOptions>, '_'>, {
5
5
  (): void;
6
6
  } | undefined>, 'serverPrefetch' | 'emits' | 'computed' | 'extends' | 'methods' | 'call' | undefined>;
7
+ export type VueHookFunction = (this: ComponentPublicInstance) => void;
7
8
  /**
8
9
  * 模仿Vue的计算属性的写法
9
10
  * @see ComputedOptions
package/dist/tg-map.js CHANGED
@@ -314,7 +314,7 @@ const Ee = "wgs84", S = class {
314
314
  * @throws 若当前coord和targetCoord相同, 会抛异常, 故请在外部判断
315
315
  */
316
316
  // TODO: 2023/03/14 ipcjs 这里设成private, 有些地方会报类型错误...
317
- /*private*/
317
+ /* private */
318
318
  convert(e) {
319
319
  switch (this.coord) {
320
320
  case "bd09":
@@ -3656,7 +3656,7 @@ function Ar(i, e) {
3656
3656
  const t = window, r = zr(i);
3657
3657
  if (t[r])
3658
3658
  return Promise.resolve();
3659
- switch (i != $.here && !e.key && x(`请先配置${i}地图的key`), i) {
3659
+ switch (i !== $.here && !e.key && x(`请先配置${i}地图的key`), i) {
3660
3660
  case $.google:
3661
3661
  return Mt(`https://maps.googleapis.com/maps/api/js?key=${e.key}&language=${e.language}`);
3662
3662
  case $.baidu:
@@ -3700,8 +3700,13 @@ function ne(i) {
3700
3700
  });
3701
3701
  }
3702
3702
  const Rr = C({
3703
- inheritAttrs: !1,
3704
3703
  name: "tg-map",
3704
+ provide() {
3705
+ return {
3706
+ [bt]: Vt(() => this.map)
3707
+ };
3708
+ },
3709
+ inheritAttrs: !1,
3705
3710
  props: {
3706
3711
  /** type没做响应式, 但外部可以把type作为tg-map的key, 让type修改时完全重建tg-map */
3707
3712
  type: W($, $.google),
@@ -3742,18 +3747,18 @@ const Rr = C({
3742
3747
  /** 优先级比mapTypeId高 */
3743
3748
  mapType: m(Object)
3744
3749
  },
3745
- data() {
3746
- return {
3747
- map: void 0,
3748
- isDestroyed: !1
3749
- };
3750
- },
3751
3750
  setup(i, { attrs: e }) {
3752
3751
  return {
3753
3752
  attrs: V(e),
3754
3753
  centerSyncTimeoutId: 0
3755
3754
  };
3756
3755
  },
3756
+ data() {
3757
+ return {
3758
+ map: void 0,
3759
+ isDestroyed: !1
3760
+ };
3761
+ },
3757
3762
  computed: {
3758
3763
  propsJson() {
3759
3764
  return le.toJsonSafely(this.$props);
@@ -3794,11 +3799,6 @@ const Rr = C({
3794
3799
  (e = this.map) == null || e.setMapType(i ?? I.NORMAL);
3795
3800
  }
3796
3801
  },
3797
- provide() {
3798
- return {
3799
- [bt]: Vt(() => this.map)
3800
- };
3801
- },
3802
3802
  async created() {
3803
3803
  const { type: i } = this;
3804
3804
  try {
@@ -4123,9 +4123,9 @@ const Zt = /* @__PURE__ */ Z(Xr, [["render", Jr]]), Qr = C({
4123
4123
  this.$map.removeLayer(this.layer);
4124
4124
  }
4125
4125
  }), ei = C({
4126
- inheritAttrs: !1,
4127
4126
  name: "tg-circle",
4128
4127
  mixins: [w],
4128
+ inheritAttrs: !1,
4129
4129
  props: {
4130
4130
  center: z(y),
4131
4131
  radius: z(Number),
@@ -4319,11 +4319,6 @@ const ii = C({
4319
4319
  overlay: void 0
4320
4320
  };
4321
4321
  },
4322
- methods: {
4323
- content() {
4324
- return this.$el;
4325
- }
4326
- },
4327
4322
  watch: {
4328
4323
  position(i) {
4329
4324
  this.overlay.setPosition(i);
@@ -4332,6 +4327,11 @@ const ii = C({
4332
4327
  this.recreate();
4333
4328
  }
4334
4329
  },
4330
+ methods: {
4331
+ content() {
4332
+ return this.$el;
4333
+ }
4334
+ },
4335
4335
  onCreate() {
4336
4336
  this.overlay = new ri(this.$map, this, this.content(), this.position), this.$map.addElementOverlay(this.overlay);
4337
4337
  },
@@ -4347,9 +4347,9 @@ function si(i, e, t, r, s, n) {
4347
4347
  ], 16);
4348
4348
  }
4349
4349
  const ni = /* @__PURE__ */ Z(ii, [["render", si]]), oi = C({
4350
- inheritAttrs: !1,
4351
4350
  name: "tg-marker",
4352
4351
  mixins: [w],
4352
+ inheritAttrs: !1,
4353
4353
  props: {
4354
4354
  position: z(y),
4355
4355
  title: m(String),
@@ -4433,9 +4433,9 @@ function ai(i, e, t, r, s, n) {
4433
4433
  ], 16);
4434
4434
  }
4435
4435
  const we = /* @__PURE__ */ Z(oi, [["render", ai]]), li = C({
4436
- inheritAttrs: !1,
4437
4436
  name: "tg-info-box",
4438
4437
  mixins: [w],
4438
+ inheritAttrs: !1,
4439
4439
  props: {
4440
4440
  show: z(Boolean),
4441
4441
  position: m(y),
@@ -4511,9 +4511,9 @@ function hi(i, e, t, r, s, n) {
4511
4511
  ], 16);
4512
4512
  }
4513
4513
  const ci = /* @__PURE__ */ Z(li, [["render", hi]]), di = C({
4514
- inheritAttrs: !1,
4515
4514
  name: "tg-info-window",
4516
4515
  mixins: [w],
4516
+ inheritAttrs: !1,
4517
4517
  props: {
4518
4518
  show: z(Boolean),
4519
4519
  position: m(y),
@@ -4527,23 +4527,6 @@ const ci = /* @__PURE__ */ Z(li, [["render", hi]]), di = C({
4527
4527
  overlay: void 0
4528
4528
  };
4529
4529
  },
4530
- methods: {
4531
- content() {
4532
- return this.$el;
4533
- },
4534
- $marker() {
4535
- return de(this.$parent, we);
4536
- },
4537
- getOptions() {
4538
- return {
4539
- content: this.content(),
4540
- position: this.position,
4541
- maxWidth: this.maxWidth,
4542
- offset: this.offset,
4543
- disableAutoPan: this.disableAutoPan
4544
- };
4545
- }
4546
- },
4547
4530
  watch: {
4548
4531
  show(i) {
4549
4532
  this.$marker() ? this.$marker().onInfoShowChanged(this, i) : i ? this.overlay.open() : this.overlay.close();
@@ -4561,6 +4544,23 @@ const ci = /* @__PURE__ */ Z(li, [["render", hi]]), di = C({
4561
4544
  this.recreate();
4562
4545
  }
4563
4546
  },
4547
+ methods: {
4548
+ content() {
4549
+ return this.$el;
4550
+ },
4551
+ $marker() {
4552
+ return de(this.$parent, we);
4553
+ },
4554
+ getOptions() {
4555
+ return {
4556
+ content: this.content(),
4557
+ position: this.position,
4558
+ maxWidth: this.maxWidth,
4559
+ offset: this.offset,
4560
+ disableAutoPan: this.disableAutoPan
4561
+ };
4562
+ }
4563
+ },
4564
4564
  onCreate() {
4565
4565
  this.overlay = this.$map.createInfoWindow(this.getOptions()), this.$marker() ? this.$marker().onAddInfo(this) : this.show && this.overlay.open(), this.overlay.addEventListener("open", () => {
4566
4566
  this.$emit("update:show", !0);
@@ -4582,9 +4582,9 @@ function pi(i, e, t, r, s, n) {
4582
4582
  ]);
4583
4583
  }
4584
4584
  const ui = /* @__PURE__ */ Z(di, [["render", pi]]), gi = C({
4585
- inheritAttrs: !1,
4586
4585
  name: "tg-label",
4587
4586
  mixins: [w],
4587
+ inheritAttrs: !1,
4588
4588
  props: {
4589
4589
  position: m(y),
4590
4590
  offset: m(Object),
@@ -4596,6 +4596,20 @@ const ui = /* @__PURE__ */ Z(di, [["render", pi]]), gi = C({
4596
4596
  overlay: void 0
4597
4597
  };
4598
4598
  },
4599
+ watch: {
4600
+ position(i) {
4601
+ this.overlay.setPosition(i);
4602
+ },
4603
+ offset(i) {
4604
+ this.overlay.setOffset(i);
4605
+ },
4606
+ zIndex(i) {
4607
+ this.overlay.setZIndex(i);
4608
+ },
4609
+ visible(i) {
4610
+ this.overlay.setVisible(i);
4611
+ }
4612
+ },
4599
4613
  methods: {
4600
4614
  content() {
4601
4615
  return this.$el;
@@ -4616,20 +4630,6 @@ const ui = /* @__PURE__ */ Z(di, [["render", pi]]), gi = C({
4616
4630
  };
4617
4631
  }
4618
4632
  },
4619
- watch: {
4620
- position(i) {
4621
- this.overlay.setPosition(i);
4622
- },
4623
- offset(i) {
4624
- this.overlay.setOffset(i);
4625
- },
4626
- zIndex(i) {
4627
- this.overlay.setZIndex(i);
4628
- },
4629
- visible(i) {
4630
- this.overlay.setVisible(i);
4631
- }
4632
- },
4633
4633
  onCreate() {
4634
4634
  this.overlay = this.$map.createLabel(this.getOptions()), this.$marker() ? this.$marker().onAddLabel(this) : this.$map.addOverlay(this.overlay), F(this.attrs.listeners, this.overlay);
4635
4635
  },
@@ -4645,9 +4645,9 @@ function mi(i, e, t, r, s, n) {
4645
4645
  ], 16);
4646
4646
  }
4647
4647
  const fi = /* @__PURE__ */ Z(gi, [["render", mi]]), yi = C({
4648
- inheritAttrs: !1,
4649
4648
  name: "tg-polygon",
4650
4649
  mixins: [w],
4650
+ inheritAttrs: !1,
4651
4651
  props: {
4652
4652
  paths: z(Array),
4653
4653
  clickable: m(Boolean),
@@ -4704,9 +4704,9 @@ const fi = /* @__PURE__ */ Z(gi, [["render", mi]]), yi = C({
4704
4704
  this.$map.removeOverlay(this.polygon);
4705
4705
  }
4706
4706
  }), vi = C({
4707
- inheritAttrs: !1,
4708
4707
  name: "tg-polyline",
4709
4708
  mixins: [w],
4709
+ inheritAttrs: !1,
4710
4710
  props: {
4711
4711
  path: z(Array),
4712
4712
  clickable: m(Boolean),
@@ -4758,11 +4758,6 @@ const fi = /* @__PURE__ */ Z(gi, [["render", mi]]), yi = C({
4758
4758
  install(i, e = {}) {
4759
4759
  if (e.enable !== !1) {
4760
4760
  const t = C({
4761
- methods: {
4762
- __life(r) {
4763
- this.__life_impl(r);
4764
- }
4765
- },
4766
4761
  beforeCreate() {
4767
4762
  const r = this.$options.name || this.$options._componentTag || "", n = (e.nameRegex || /^[A-Z]/).test(r) ? (a) => {
4768
4763
  e.hookNames ? e.hookNames.includes(a) && console.debug("[lifecycle]", r, a) : _i.includes(a) || console.debug("[lifecycle]", r, a);
@@ -4778,12 +4773,6 @@ const fi = /* @__PURE__ */ Z(gi, [["render", mi]]), yi = C({
4778
4773
  mounted() {
4779
4774
  this.__life("mounted");
4780
4775
  },
4781
- onCreate() {
4782
- this.__life("onCreate");
4783
- },
4784
- onDestroy() {
4785
- this.__life("onDestroy");
4786
- },
4787
4776
  beforeUpdate() {
4788
4777
  this.__life("beforeUpdate");
4789
4778
  },
@@ -4795,6 +4784,17 @@ const fi = /* @__PURE__ */ Z(gi, [["render", mi]]), yi = C({
4795
4784
  },
4796
4785
  unmounted() {
4797
4786
  this.__life("unmounted");
4787
+ },
4788
+ methods: {
4789
+ __life(r) {
4790
+ this.__life_impl(r);
4791
+ }
4792
+ },
4793
+ onCreate() {
4794
+ this.__life("onCreate");
4795
+ },
4796
+ onDestroy() {
4797
+ this.__life("onDestroy");
4798
4798
  }
4799
4799
  });
4800
4800
  i.mixin(t);