tg-map-vue3 3.3.1 → 3.3.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.
@@ -13,11 +13,14 @@ export declare const UnionIcon: {
13
13
  * */
14
14
  export interface Icon {
15
15
  readonly url: string;
16
+ /** 显示的图片区域大小 */
16
17
  readonly size: Size;
17
18
  /** 图片的显示区域的原点在图片中的坐标, 默认为(0, 0) */
18
19
  readonly origin?: Point;
19
20
  /** 图片显示到地图上的锚点, 默认为图标的底部中点 */
20
21
  readonly anchor?: Point;
22
+ /** 缩放后的图片大小, 不传则不缩放 */
23
+ readonly scaledSize?: Size;
21
24
  }
22
25
  export declare namespace Icon {
23
26
  function toGoogle(icon: Icon): google.maps.Icon;
package/dist/tg-map.js CHANGED
@@ -2,7 +2,7 @@
2
2
  var pr = Object.defineProperty;
3
3
  var ur = (i, e, t) => e in i ? pr(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
4
4
  var p = (i, e, t) => (ur(i, typeof e != "symbol" ? e + "" : e, t), t);
5
- import { createCommentVNode as Ge, computed as St, defineComponent as x, markRaw as gr, openBlock as Z, createElementBlock as W, mergeProps as le, createElementVNode as mr, normalizeClass as Se, renderSlot as R, normalizeStyle as fr, getCurrentInstance as yr, inject as vr, onMounted as _r, onBeforeUnmount as Mr, watch as br, withDirectives as Tr, vShow as Or } from "vue";
5
+ import { createCommentVNode as Ge, computed as Bt, defineComponent as x, markRaw as gr, openBlock as Z, createElementBlock as W, mergeProps as le, createElementVNode as mr, normalizeClass as Be, renderSlot as R, normalizeStyle as fr, getCurrentInstance as yr, inject as vr, onMounted as _r, onBeforeUnmount as Mr, watch as br, withDirectives as Tr, vShow as Or } from "vue";
6
6
  function U(i, e, t) {
7
7
  Object.keys(i).forEach((r) => {
8
8
  r.startsWith("update:") || t != null && t.includes(r) || e.addEventListener(r, i[r]);
@@ -317,17 +317,17 @@ function Lr(i) {
317
317
  }
318
318
  function kr(i) {
319
319
  var e = Object.prototype.toString.call(i);
320
- return e === "[object RegExp]" || e === "[object Date]" || Br(i);
320
+ return e === "[object RegExp]" || e === "[object Date]" || Sr(i);
321
321
  }
322
322
  var Pr = typeof Symbol == "function" && Symbol.for, Ir = Pr ? Symbol.for("react.element") : 60103;
323
- function Br(i) {
323
+ function Sr(i) {
324
324
  return i.$$typeof === Ir;
325
325
  }
326
- function Sr(i) {
326
+ function Br(i) {
327
327
  return Array.isArray(i) ? [] : {};
328
328
  }
329
329
  function ge(i, e) {
330
- return e.clone !== !1 && e.isMergeableObject(i) ? oe(Sr(i), i, e) : i;
330
+ return e.clone !== !1 && e.isMergeableObject(i) ? oe(Br(i), i, e) : i;
331
331
  }
332
332
  function Ar(i, e, t) {
333
333
  return i.concat(e).map(function(r) {
@@ -520,7 +520,7 @@ p(Q, "EVENT_TYPE_MAP", {
520
520
  "map-mouseup": "mouseup",
521
521
  "map-dblclick": "dblclick"
522
522
  });
523
- const Be = class extends Wt {
523
+ const Se = class extends Wt {
524
524
  addEventListener(e, t) {
525
525
  const r = we(e, t);
526
526
  if (this.eventMap.get(r)) {
@@ -535,14 +535,14 @@ const Be = class extends Wt {
535
535
  };
536
536
  n.point && (a.position = y.fromBaidu(n.point, this.coordTypeSupplier.coordType)), t.call(this.target, a);
537
537
  };
538
- this.inner.addEventListener(Be.EVENT_TYPE_MAP[e] || e, s), this.eventMap.set(r, s);
538
+ this.inner.addEventListener(Se.EVENT_TYPE_MAP[e] || e, s), this.eventMap.set(r, s);
539
539
  }
540
540
  removeEventListener(e, t) {
541
541
  const r = we(e, t), s = this.eventMap.get(r);
542
- s ? (this.inner.removeEventListener(Be.EVENT_TYPE_MAP[e] || e, s), this.eventMap.delete(r)) : console.warn("移除失败, 不存在该listener", r, t);
542
+ s ? (this.inner.removeEventListener(Se.EVENT_TYPE_MAP[e] || e, s), this.eventMap.delete(r)) : console.warn("移除失败, 不存在该listener", r, t);
543
543
  }
544
544
  };
545
- let ne = Be;
545
+ let ne = Se;
546
546
  // cSpell:words clickclose
547
547
  // 事件类型映射, tg => baidu
548
548
  p(ne, "EVENT_TYPE_MAP", {
@@ -628,7 +628,7 @@ class xt {
628
628
  return this.value === void 0 && (this.value = this.creator()), this.value;
629
629
  }
630
630
  }
631
- var k = /* @__PURE__ */ ((i) => (i.TOP_LEFT = "top-left", i.TOP_CENTER = "top-center", i.TOP_RIGHT = "top-right", i.BOTTOM_LEFT = "bottom-left", i.BOTTOM_CENTER = "bottom-center", i.BOTTOM_RIGHT = "bottom-right", i.LEFT_TOP = "left-top", i.LEFT_CENTER = "left-center", i.LEFT_BOTTOM = "left-bottom", i.RIGHT_TOP = "right-top", i.RIGHT_CENTER = "right-center", i.RIGHT_BOTTOM = "right-bottom", i))(k || {}), B;
631
+ var k = /* @__PURE__ */ ((i) => (i.TOP_LEFT = "top-left", i.TOP_CENTER = "top-center", i.TOP_RIGHT = "top-right", i.BOTTOM_LEFT = "bottom-left", i.BOTTOM_CENTER = "bottom-center", i.BOTTOM_RIGHT = "bottom-right", i.LEFT_TOP = "left-top", i.LEFT_CENTER = "left-center", i.LEFT_BOTTOM = "left-bottom", i.RIGHT_TOP = "right-top", i.RIGHT_CENTER = "right-center", i.RIGHT_BOTTOM = "right-bottom", i))(k || {}), S;
632
632
  ((i) => {
633
633
  let e, t;
634
634
  const r = [
@@ -693,7 +693,7 @@ var k = /* @__PURE__ */ ((i) => (i.TOP_LEFT = "top-left", i.TOP_CENTER = "top-ce
693
693
  ])), t;
694
694
  }
695
695
  i.getGoogle = n;
696
- })(B || (B = {}));
696
+ })(S || (S = {}));
697
697
  class Ur {
698
698
  constructor(e) {
699
699
  /** 实际添加到地图中的control对象 */
@@ -714,10 +714,10 @@ class Ye extends jt {
714
714
  e ? this.inner.show() : this.inner.hide();
715
715
  }
716
716
  getPosition() {
717
- return this.position ?? B.getBaidu().toKey(this.inner.getAnchor());
717
+ return this.position ?? S.getBaidu().toKey(this.inner.getAnchor());
718
718
  }
719
719
  setPosition(e) {
720
- this.position = e, this.inner.setAnchor(B.getBaidu().toValue(e));
720
+ this.position = e, this.inner.setAnchor(S.getBaidu().toValue(e));
721
721
  }
722
722
  addTo(e) {
723
723
  e.innerMap.addControl(this.inner);
@@ -753,7 +753,7 @@ class qe extends jt {
753
753
  }
754
754
  onCreateOptions() {
755
755
  return {
756
- position: B.getGoogle().toValue(this.position)
756
+ position: S.getGoogle().toValue(this.position)
757
757
  };
758
758
  }
759
759
  tryUpdateOptions() {
@@ -822,7 +822,7 @@ class Ke extends Ye {
822
822
  type: e.type && r[e.type],
823
823
  mapTypes: t.map((n) => n.asBaiduMapType())
824
824
  });
825
- return e.position && s.setAnchor(B.getBaidu().toValue(e.position)), new Ke(s, e.position);
825
+ return e.position && s.setAnchor(S.getBaidu().toValue(e.position)), new Ke(s, e.position);
826
826
  }
827
827
  }
828
828
  const ie = class extends qe {
@@ -851,7 +851,7 @@ p(Oe, "type2google");
851
851
  class Xe extends Ye {
852
852
  static create(e) {
853
853
  const t = new BMap.ScaleControl({
854
- anchor: e.position && B.getBaidu().toValue(e.position)
854
+ anchor: e.position && S.getBaidu().toValue(e.position)
855
855
  });
856
856
  return new Xe(t, e.position);
857
857
  }
@@ -869,7 +869,7 @@ class Qe extends Ye {
869
869
  const t = new BMap.NavigationControl({
870
870
  type: BMAP_NAVIGATION_CONTROL_ZOOM,
871
871
  // enableGeolocation: true,
872
- anchor: e.position && B.getBaidu().toValue(e.position)
872
+ anchor: e.position && S.getBaidu().toValue(e.position)
873
873
  });
874
874
  return new Qe(t, e.position);
875
875
  }
@@ -2000,7 +2000,7 @@ T.prototype._addToClosestCluster = function(i) {
2000
2000
  if (t && t.isMarkerInClusterBounds(i))
2001
2001
  t.addMarker(i);
2002
2002
  else {
2003
- var s = new S(this);
2003
+ var s = new B(this);
2004
2004
  s.addMarker(i), this._clusters.push(s);
2005
2005
  }
2006
2006
  };
@@ -2095,7 +2095,7 @@ T.prototype.setTextCalculator = function(i) {
2095
2095
  T.prototype.setStylesIndexCalculator = function(i) {
2096
2096
  this._stylesIndexCalculator = i;
2097
2097
  };
2098
- function S(i) {
2098
+ function B(i) {
2099
2099
  var e = this;
2100
2100
  this._markerClusterer = i, this._map = i.getMap(), this._minClusterSize = i.getMinClusterSize(), this._isAverageCenter = i.isAverageCenter(), this._center = null, this._markers = [], this._gridBounds = null, this._isReal = !1, this._clusterMarker = new Lt(this._center, this._markers.length, {
2101
2101
  styles: this._markerClusterer.getStyles(),
@@ -2110,7 +2110,7 @@ function S(i) {
2110
2110
  e._map.setViewport(e.getBounds());
2111
2111
  });
2112
2112
  }
2113
- S.prototype.addMarker = function(i) {
2113
+ B.prototype.addMarker = function(i) {
2114
2114
  if (this.isMarkerInCluster(i))
2115
2115
  return !1;
2116
2116
  if (!this._center)
@@ -2121,7 +2121,7 @@ S.prototype.addMarker = function(i) {
2121
2121
  }
2122
2122
  return i.isInCluster = !0, this._markers.push(i), !0;
2123
2123
  };
2124
- S.prototype.render = function() {
2124
+ B.prototype.render = function() {
2125
2125
  var i = this._markers.length;
2126
2126
  if (i < this._minClusterSize)
2127
2127
  for (var e = 0; e < i; e++)
@@ -2129,7 +2129,7 @@ S.prototype.render = function() {
2129
2129
  else
2130
2130
  this._map.addOverlay(this._clusterMarker), this._isReal = !0, this.updateClusterMarker();
2131
2131
  };
2132
- S.prototype.isMarkerInCluster = function(i) {
2132
+ B.prototype.isMarkerInCluster = function(i) {
2133
2133
  if (this._markers.indexOf)
2134
2134
  return this._markers.indexOf(i) != -1;
2135
2135
  for (var e = 0, t; t = this._markers[e]; e++)
@@ -2137,17 +2137,17 @@ S.prototype.isMarkerInCluster = function(i) {
2137
2137
  return !0;
2138
2138
  return !1;
2139
2139
  };
2140
- S.prototype.isMarkerInClusterBounds = function(i) {
2140
+ B.prototype.isMarkerInClusterBounds = function(i) {
2141
2141
  return this._gridBounds.containsPoint(i.getPosition());
2142
2142
  };
2143
- S.prototype.isReal = function(i) {
2143
+ B.prototype.isReal = function(i) {
2144
2144
  return this._isReal;
2145
2145
  };
2146
- S.prototype.updateGridBounds = function() {
2146
+ B.prototype.updateGridBounds = function() {
2147
2147
  var i = new BMap.Bounds(this._center, this._center);
2148
2148
  this._gridBounds = Jt(this._map, i, this._markerClusterer.getGridSize());
2149
2149
  };
2150
- S.prototype.updateClusterMarker = function() {
2150
+ B.prototype.updateClusterMarker = function() {
2151
2151
  if (this._map.getZoom() > this._markerClusterer.getMaxZoom()) {
2152
2152
  this._clusterMarker && this._map.removeOverlay(this._clusterMarker);
2153
2153
  for (var i = 0, e; e = this._markers[i]; i++)
@@ -2160,19 +2160,19 @@ S.prototype.updateClusterMarker = function() {
2160
2160
  }
2161
2161
  this._clusterMarker.setPosition(this._center), this._clusterMarker.setText(this._markerClusterer._textCalculator(this._markers));
2162
2162
  };
2163
- S.prototype.remove = function() {
2163
+ B.prototype.remove = function() {
2164
2164
  for (var i = 0, e; e = this._markers[i]; i++) {
2165
2165
  var t = this._markers[i].getLabel();
2166
2166
  this._markers[i].getMap() && this._map.removeOverlay(this._markers[i]), this._markers[i].setLabel(t);
2167
2167
  }
2168
2168
  this._map.removeOverlay(this._clusterMarker), this._markers.length = 0, delete this._markers;
2169
2169
  };
2170
- S.prototype.getBounds = function() {
2170
+ B.prototype.getBounds = function() {
2171
2171
  for (var i = new BMap.Bounds(this._center, this._center), e = 0, t; t = this._markers[e]; e++)
2172
2172
  i.extend(t.getPosition());
2173
2173
  return i;
2174
2174
  };
2175
- S.prototype.getCenter = function() {
2175
+ B.prototype.getCenter = function() {
2176
2176
  return this._center;
2177
2177
  };
2178
2178
  var Le;
@@ -3210,6 +3210,7 @@ var Pe;
3210
3210
  url: r.url,
3211
3211
  size: new google.maps.Size(r.size.width, r.size.height),
3212
3212
  origin: r.origin && new google.maps.Point(r.origin.x, r.origin.y),
3213
+ scaledSize: r.scaledSize && new google.maps.Size(r.scaledSize.width, r.scaledSize.height),
3213
3214
  // google的锚点默认就是图标的底部中点
3214
3215
  anchor: r.anchor && new google.maps.Point(r.anchor.x, r.anchor.y)
3215
3216
  };
@@ -3218,6 +3219,7 @@ var Pe;
3218
3219
  function t(r) {
3219
3220
  return new BMap.Icon(r.url, new BMap.Size(r.size.width, r.size.height), {
3220
3221
  imageOffset: r.origin && new BMap.Size(-r.origin.x, -r.origin.y),
3222
+ imageSize: r.scaledSize && new BMap.Size(r.scaledSize.width, r.scaledSize.height),
3221
3223
  // baidu的锚点默认为图标的中心点, 故需要和@tg/map统一, 改成图标的底部中点
3222
3224
  anchor: r.anchor ? new BMap.Size(r.anchor.x, r.anchor.y) : new BMap.Size(r.size.width / 2, r.size.height)
3223
3225
  // InfoWindow相对图标左上角的偏移量, 不指定则InfoWindow不会偏移, 直接指到marker的position上
@@ -3650,7 +3652,7 @@ class fi extends rt {
3650
3652
  const r = class extends BMap.Control {
3651
3653
  constructor() {
3652
3654
  super(...arguments);
3653
- p(this, "defaultAnchor", B.getBaidu().toValue(t.position));
3655
+ p(this, "defaultAnchor", S.getBaidu().toValue(t.position));
3654
3656
  p(this, "defaultOffset", new BMap.Size(0, 0));
3655
3657
  }
3656
3658
  initialize(n) {
@@ -3813,11 +3815,11 @@ class yi extends rt {
3813
3815
  t.innerOverlay.setMap(null);
3814
3816
  }
3815
3817
  addCustomControl(t) {
3816
- t.inner || (t.inner = t.onCreateElement(), this.map.controls[B.getGoogle().toValue(t.position)].push(t.inner));
3818
+ t.inner || (t.inner = t.onCreateElement(), this.map.controls[S.getGoogle().toValue(t.position)].push(t.inner));
3817
3819
  }
3818
3820
  removeCustomControl(t) {
3819
3821
  if (t.inner) {
3820
- const r = this.map.controls[B.getGoogle().toValue(t.position)];
3822
+ const r = this.map.controls[S.getGoogle().toValue(t.position)];
3821
3823
  Ee.remove(r, t.inner);
3822
3824
  }
3823
3825
  }
@@ -4145,7 +4147,7 @@ function wi(i, e) {
4145
4147
  };
4146
4148
  }
4147
4149
  function Y(i, e) {
4148
- return St(() => wi(i, e));
4150
+ return Bt(() => wi(i, e));
4149
4151
  }
4150
4152
  function N() {
4151
4153
  return Function;
@@ -4181,7 +4183,7 @@ const ys = {
4181
4183
  name: "tg-map",
4182
4184
  provide() {
4183
4185
  return {
4184
- [Mt]: St(() => this.map)
4186
+ [Mt]: Bt(() => this.map)
4185
4187
  };
4186
4188
  },
4187
4189
  inheritAttrs: !1,
@@ -4348,7 +4350,7 @@ function xi(i, e, t, r, s, n) {
4348
4350
  return Z(), W("div", le({ class: "tg-map" }, i.attrs.binds), [
4349
4351
  mr("div", {
4350
4352
  ref: "map",
4351
- class: Se({
4353
+ class: Be({
4352
4354
  "tg-map__map": !0,
4353
4355
  [`tg-map__map--hide-logo-${i.type}`]: i.hideLogo
4354
4356
  })
@@ -4401,7 +4403,7 @@ const ki = x({
4401
4403
  });
4402
4404
  function Pi(i, e, t, r, s, n) {
4403
4405
  return Z(), W("div", {
4404
- class: Se(i.$options.name),
4406
+ class: Be(i.$options.name),
4405
4407
  style: fr({ left: i.dimen(i.left), top: i.dimen(i.topValue), right: i.dimen(i.right), bottom: i.dimen(i.bottom) })
4406
4408
  }, [
4407
4409
  R(i.$slots, "default")
@@ -4436,14 +4438,14 @@ const vs = /* @__PURE__ */ j(ki, [["render", Pi]]), Ii = x({
4436
4438
  this.$map.removeCustomControl(this.control);
4437
4439
  }
4438
4440
  });
4439
- function Bi(i, e, t, r, s, n) {
4441
+ function Si(i, e, t, r, s, n) {
4440
4442
  return Z(), W("div", {
4441
- class: Se(i.$options.name)
4443
+ class: Be(i.$options.name)
4442
4444
  }, [
4443
4445
  R(i.$slots, "default")
4444
4446
  ], 2);
4445
4447
  }
4446
- const _s = /* @__PURE__ */ j(Ii, [["render", Bi]]), Ms = x({
4448
+ const _s = /* @__PURE__ */ j(Ii, [["render", Si]]), Ms = x({
4447
4449
  name: "tg-map-type-control",
4448
4450
  mixins: [L],
4449
4451
  props: {
@@ -4509,7 +4511,7 @@ function lr() {
4509
4511
  }
4510
4512
  return e;
4511
4513
  }
4512
- function Si() {
4514
+ function Bi() {
4513
4515
  const i = vr(Mt);
4514
4516
  let e, t;
4515
4517
  return i == null && C(`<${lr() || "unknown"}>必须作为<tg-map>的子代组件`), {
@@ -4539,7 +4541,7 @@ const Ts = x({
4539
4541
  },
4540
4542
  setup(i) {
4541
4543
  let e = void 0;
4542
- const { map: t, onCreate: r, onDestroy: s } = Si();
4544
+ const { map: t, onCreate: r, onDestroy: s } = Bi();
4543
4545
  return r(() => {
4544
4546
  e = t.createZoomControl(i), t.addControl(e);
4545
4547
  }), s(() => {
@@ -4614,7 +4616,7 @@ const Ts = x({
4614
4616
  });
4615
4617
  function $i(i, e, t, r, s, n) {
4616
4618
  return Z(), W("div", {
4617
- class: Se(i.$options.name)
4619
+ class: Be(i.$options.name)
4618
4620
  }, [
4619
4621
  R(i.$slots, "default")
4620
4622
  ], 2);
@@ -5321,7 +5323,7 @@ const Ls = /* @__PURE__ */ j(Ui, [["render", Yi]]), ks = x({
5321
5323
  function pe(i) {
5322
5324
  return i * Math.PI / 180;
5323
5325
  }
5324
- function Bt(i) {
5326
+ function St(i) {
5325
5327
  return i * 180 / Math.PI;
5326
5328
  }
5327
5329
  function Xi(i, e) {
@@ -5346,12 +5348,12 @@ function Ji(i, e, t) {
5346
5348
  d * E + h * O * o,
5347
5349
  (1 - n) * Math.sqrt(_ * _ + te * te)
5348
5350
  ), hr = Math.atan2(O * c, h * E - d * O * o), Re = n / 16 * b * (4 + n * (4 - 3 * b)), cr = hr - (1 - Re) * n * _ * (w + Re * O * (v + Re * E * (-1 + 2 * v * v)));
5349
- return { lng: i.lng + Bt(cr), lat: Bt($e) };
5351
+ return { lng: i.lng + St(cr), lat: St($e) };
5350
5352
  }
5351
- const Bs = {
5353
+ const Ss = {
5352
5354
  getDistance: Xi,
5353
5355
  getDestination: Ji
5354
- }, Ss = {
5356
+ }, Bs = {
5355
5357
  install(i, e) {
5356
5358
  Wr(e), i.config.unwrapInjectedRef = !0;
5357
5359
  const t = i.config.optionMergeStrategies;
@@ -5380,7 +5382,7 @@ export {
5380
5382
  Qe as BaiduZoomControl,
5381
5383
  xt as CachedValue,
5382
5384
  k as ControlPosition,
5383
- B as ControlPositionConverter,
5385
+ S as ControlPositionConverter,
5384
5386
  J as CoordType,
5385
5387
  Ur as CustomControl,
5386
5388
  Fr as FastFindValues,
@@ -5418,7 +5420,7 @@ export {
5418
5420
  rr as PlacesService,
5419
5421
  F as Point,
5420
5422
  ir as SearchBox,
5421
- Bs as SphericalUtils,
5423
+ Ss as SphericalUtils,
5422
5424
  fe as Strings,
5423
5425
  Ie as SymbolIcon,
5424
5426
  ps as SymbolPath,
@@ -5449,7 +5451,7 @@ export {
5449
5451
  Oi as createPropertyObject,
5450
5452
  gs as createPropertyObjectTyped,
5451
5453
  is as debug,
5452
- Ss as default,
5454
+ Bs as default,
5453
5455
  ys as eventLogMethods,
5454
5456
  N as eventProp,
5455
5457
  fs as extractVNodeFromSlotsByComponent,
@@ -5475,6 +5477,6 @@ export {
5475
5477
  je as typed,
5476
5478
  ls as unwrapStringEnumValue,
5477
5479
  Y as useSplittedAttrs,
5478
- Si as useTgMap
5480
+ Bi as useTgMap
5479
5481
  };
5480
5482
  //# sourceMappingURL=tg-map.js.map