tg-map-vue3 3.0.1

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.
Files changed (70) hide show
  1. package/README.md +109 -0
  2. package/dist/src/components/TgMap.vue.d.ts +45 -0
  3. package/dist/src/components/TgMapWidget.vue.d.ts +49 -0
  4. package/dist/src/components/controls/TgCustomControl.vue.d.ts +16 -0
  5. package/dist/src/components/controls/TgMapTypeControl.vue.d.ts +14 -0
  6. package/dist/src/components/controls/TgScaleControl.vue.d.ts +12 -0
  7. package/dist/src/components/controls/TgZoomControl.vue.d.ts +12 -0
  8. package/dist/src/components/extra/TgMarkerClusterer.vue.d.ts +48 -0
  9. package/dist/src/components/index.d.ts +36 -0
  10. package/dist/src/components/layers/TgTrafficLayer.vue.d.ts +15 -0
  11. package/dist/src/components/map-mixin.d.ts +22 -0
  12. package/dist/src/components/overlays/TgCircle.vue.d.ts +21 -0
  13. package/dist/src/components/overlays/TgElementOverlay.vue.d.ts +30 -0
  14. package/dist/src/components/overlays/TgInfoBox.vue.d.ts +29 -0
  15. package/dist/src/components/overlays/TgInfoWindow.vue.d.ts +25 -0
  16. package/dist/src/components/overlays/TgLabel.vue.d.ts +21 -0
  17. package/dist/src/components/overlays/TgMarker.vue.d.ts +60 -0
  18. package/dist/src/components/overlays/TgPolygon.vue.d.ts +20 -0
  19. package/dist/src/components/overlays/TgPolyline.vue.d.ts +18 -0
  20. package/dist/src/map/event-target.d.ts +35 -0
  21. package/dist/src/map/event.d.ts +47 -0
  22. package/dist/src/map/lat-lng.d.ts +89 -0
  23. package/dist/src/map/map/baidu-map.d.ts +66 -0
  24. package/dist/src/map/map/controls/control.d.ts +101 -0
  25. package/dist/src/map/map/controls/map-type.control.d.ts +30 -0
  26. package/dist/src/map/map/controls/scale.control.d.ts +15 -0
  27. package/dist/src/map/map/controls/zoom.control.d.ts +16 -0
  28. package/dist/src/map/map/extra/marker-clusterer.d.ts +69 -0
  29. package/dist/src/map/map/google-map.d.ts +68 -0
  30. package/dist/src/map/map/here-map.d.ts +49 -0
  31. package/dist/src/map/map/map-options.d.ts +46 -0
  32. package/dist/src/map/map/map-type.d.ts +113 -0
  33. package/dist/src/map/map/map.d.ts +129 -0
  34. package/dist/src/map/map/overlay/baidu-info-box.d.ts +81 -0
  35. package/dist/src/map/map/overlay/circle.d.ts +42 -0
  36. package/dist/src/map/map/overlay/element-overlay.d.ts +33 -0
  37. package/dist/src/map/map/overlay/google-label.d.ts +74 -0
  38. package/dist/src/map/map/overlay/icon.d.ts +16 -0
  39. package/dist/src/map/map/overlay/info-box.d.ts +58 -0
  40. package/dist/src/map/map/overlay/info-window.d.ts +112 -0
  41. package/dist/src/map/map/overlay/label.d.ts +89 -0
  42. package/dist/src/map/map/overlay/marker.d.ts +126 -0
  43. package/dist/src/map/map/overlay/overlay.d.ts +38 -0
  44. package/dist/src/map/map/overlay/polygon.d.ts +35 -0
  45. package/dist/src/map/map/overlay/polyline.d.ts +35 -0
  46. package/dist/src/map/map/overlay/shape.d.ts +48 -0
  47. package/dist/src/map/map-config.d.ts +14 -0
  48. package/dist/src/map/map-factory.d.ts +10 -0
  49. package/dist/src/map/map-loader.d.ts +5 -0
  50. package/dist/src/map/types.d.ts +17 -0
  51. package/dist/src/map/unions.d.ts +19 -0
  52. package/dist/src/utils/arrays.d.ts +10 -0
  53. package/dist/src/utils/assert.d.ts +9 -0
  54. package/dist/src/utils/baidu-utils.d.ts +5 -0
  55. package/dist/src/utils/elements.d.ts +4 -0
  56. package/dist/src/utils/formatter.d.ts +1 -0
  57. package/dist/src/utils/here-utils.d.ts +10 -0
  58. package/dist/src/utils/lifecycle-log.d.ts +14 -0
  59. package/dist/src/utils/mapped-types.d.ts +60 -0
  60. package/dist/src/utils/objects.d.ts +13 -0
  61. package/dist/src/utils/strings.d.ts +9 -0
  62. package/dist/src/utils/utils.d.ts +9 -0
  63. package/dist/src/utils/values.d.ts +34 -0
  64. package/dist/src/utils/vue-utils.d.ts +82 -0
  65. package/dist/style.css +1 -0
  66. package/dist/tg-map.js +4871 -0
  67. package/dist/tg-map.js.map +1 -0
  68. package/dist/tg-map.umd.cjs +14 -0
  69. package/dist/tg-map.umd.cjs.map +1 -0
  70. package/package.json +67 -0
package/dist/tg-map.js ADDED
@@ -0,0 +1,4871 @@
1
+ var Wt = Object.defineProperty;
2
+ var Vt = (i, e, t) => e in i ? Wt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var h = (i, e, t) => (Vt(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { defineComponent as C, computed as Ht, openBlock as D, createElementBlock as Z, createElementVNode as Ft, createCommentVNode as dt, renderSlot as A, normalizeClass as q, normalizeStyle as Ut, withDirectives as Yt, vShow as Kt, mergeProps as qt, toHandlers as Xt } from "vue";
5
+ function I(i) {
6
+ throw new Error(i);
7
+ }
8
+ function Jt(i) {
9
+ throw new Error(`Unsupported: ${i}`);
10
+ }
11
+ function Ci(i) {
12
+ throw new Error(`todo: ${i}`);
13
+ }
14
+ function wi(i) {
15
+ return i;
16
+ }
17
+ function fe(...i) {
18
+ }
19
+ function Qt(i) {
20
+ return i != null;
21
+ }
22
+ function V(i, e) {
23
+ return {
24
+ type: String,
25
+ default: e,
26
+ validator: (t) => Object.values(i).includes(t)
27
+ };
28
+ }
29
+ function er(i, e) {
30
+ return {
31
+ type: String,
32
+ default: e,
33
+ validator: (t) => i.includes(t)
34
+ };
35
+ }
36
+ function z(i) {
37
+ return {
38
+ type: i,
39
+ required: !0
40
+ };
41
+ }
42
+ function m(i, e) {
43
+ return {
44
+ type: i,
45
+ default: e
46
+ };
47
+ }
48
+ function xi(i) {
49
+ const e = {};
50
+ return Object.entries(i).forEach(([t, r]) => {
51
+ const s = `__${t}`;
52
+ e[t] = {
53
+ get() {
54
+ const o = this[s];
55
+ return o === void 0 ? r : o;
56
+ },
57
+ set(o) {
58
+ this[s] = o;
59
+ }
60
+ // Vue3已经不支持该属性
61
+ // cache: false
62
+ };
63
+ }), e;
64
+ }
65
+ const ie = {
66
+ enumerable: !0,
67
+ configurable: !0,
68
+ get: fe,
69
+ set: fe
70
+ };
71
+ function tr(i) {
72
+ return Object.keys(i).forEach((e) => {
73
+ const t = i[e];
74
+ let r = !1;
75
+ typeof t == "function" ? (ie.get = t, ie.set = fe, r = !0) : typeof t == "object" && typeof t.get == "function" && (ie.get = t.get, ie.set = t.set, r = !0), r && (i[e] = Object.defineProperty(i, e, ie));
76
+ }), i;
77
+ }
78
+ function Ei(i) {
79
+ return tr(i);
80
+ }
81
+ function rr(i, e) {
82
+ return e._e();
83
+ }
84
+ function ue(i, e) {
85
+ const t = i.$options[e];
86
+ if (t)
87
+ for (const r of t)
88
+ r.call(i);
89
+ }
90
+ function we(i, e) {
91
+ for (const t of i)
92
+ if (t.$options.name === e.name)
93
+ return t;
94
+ }
95
+ const ki = {
96
+ /**
97
+ * @event 一般来说传{@link Tg.Event}对象, 但传其他对象也不会报错
98
+ */
99
+ eventLog(i) {
100
+ console.log(i), this.$_prev_type = i && i.type, this.$_prev_time = Date.now();
101
+ },
102
+ /** @see eventLog */
103
+ eventLogLess(i) {
104
+ ((i && i.type) !== this.$_prev_type || Date.now() - (this.$_prev_time ?? 0) > 1e3) && this.eventLog(i);
105
+ }
106
+ };
107
+ var ye;
108
+ ((i) => {
109
+ function e(r, s) {
110
+ if (r !== void 0)
111
+ return Object.values(s).includes(r) ? r : void 0;
112
+ }
113
+ i.toEnumOrNull = e;
114
+ function t(r) {
115
+ return r.split(`
116
+ `).map((s) => s.trim()).join(`
117
+ `);
118
+ }
119
+ i.trimIndent = t;
120
+ })(ye || (ye = {}));
121
+ const _t = "$map", Ie = "onCreate", Pe = "onDestroy", w = C({
122
+ inject: [_t],
123
+ mounted() {
124
+ ue(this, Ie);
125
+ },
126
+ beforeDestroy() {
127
+ ue(this, Pe);
128
+ },
129
+ methods: {
130
+ recreate() {
131
+ ue(this, Pe), ue(this, Ie);
132
+ }
133
+ },
134
+ render(i) {
135
+ return rr(i, this);
136
+ }
137
+ });
138
+ var Mt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, j = {}, ir = {
139
+ get exports() {
140
+ return j;
141
+ },
142
+ set exports(i) {
143
+ j = i;
144
+ }
145
+ };
146
+ (function(i) {
147
+ (function(e, t) {
148
+ i.exports ? i.exports = t() : e.coordtransform = t();
149
+ })(Mt, function() {
150
+ var e = 52.35987755982988, t = 3.141592653589793, r = 6378245, s = 0.006693421622965943;
151
+ function o(p, f, v, O) {
152
+ this.west = Math.min(p, v), this.north = Math.max(f, O), this.east = Math.max(p, v), this.south = Math.min(f, O);
153
+ }
154
+ o.prototype.contain = function(p, f) {
155
+ return this.west <= p && this.east >= p && this.north >= f && this.south <= f;
156
+ };
157
+ var a = [
158
+ new o(79.4462, 49.2204, 96.33, 42.8899),
159
+ new o(109.6872, 54.1415, 135.0002, 39.3742),
160
+ new o(73.1246, 42.8899, 124.143255, 29.5297),
161
+ new o(82.9684, 29.5297, 97.0352, 26.7186),
162
+ new o(97.0253, 29.5297, 124.367395, 20.414096),
163
+ new o(107.975793, 20.414096, 111.744104, 17.871542)
164
+ ], g = [
165
+ new o(119.921265, 25.398623, 122.497559, 21.785006),
166
+ new o(101.8652, 22.284, 106.665, 20.0988),
167
+ new o(106.4525, 21.5422, 108.051, 20.4878),
168
+ new o(109.0323, 55.8175, 119.127, 50.3257),
169
+ new o(127.4568, 55.8175, 137.0227, 49.5574),
170
+ new o(131.2662, 44.8922, 137.0227, 42.5692),
171
+ new o(73.1246, 35.398637, 77.948114, 29.5297)
172
+ ];
173
+ function n(p, f) {
174
+ for (var v = 0; v < a.length; v++)
175
+ if (a[v].contain(p, f)) {
176
+ for (var O = 0; O < g.length; O++)
177
+ if (g[O].contain(p, f))
178
+ return !1;
179
+ return !0;
180
+ }
181
+ return !1;
182
+ }
183
+ function l(p, f) {
184
+ var v = p - 65e-4, O = f - 6e-3, F = Math.sqrt(v * v + O * O) - 2e-5 * Math.sin(O * e), B = Math.atan2(O, v) - 3e-6 * Math.cos(v * e), pe = F * Math.cos(B), Ce = F * Math.sin(B);
185
+ return [pe, Ce];
186
+ }
187
+ function c(p, f) {
188
+ var v = Math.sqrt(p * p + f * f) + 2e-5 * Math.sin(f * e), O = Math.atan2(f, p) + 3e-6 * Math.cos(p * e), F = v * Math.cos(O) + 65e-4, B = v * Math.sin(O) + 6e-3;
189
+ return [F, B];
190
+ }
191
+ function u(p, f) {
192
+ return n(p, f) ? b(p, f) : [p, f];
193
+ }
194
+ function d(p, f) {
195
+ if (!n(p, f))
196
+ return [p, f];
197
+ var v = b(p, f);
198
+ return [p * 2 - v[0], f * 2 - v[1]];
199
+ }
200
+ function b(p, f) {
201
+ var v = M(p - 105, f - 35), O = T(p - 105, f - 35), F = f / 180 * t, B = Math.sin(F);
202
+ B = 1 - s * B * B;
203
+ var pe = Math.sqrt(B);
204
+ v = v * 180 / (r * (1 - s) / (B * pe) * t), O = O * 180 / (r / pe * Math.cos(F) * t);
205
+ var Ce = f + v, jt = p + O;
206
+ return [jt, Ce];
207
+ }
208
+ function M(p, f) {
209
+ var v = -100 + 2 * p + 3 * f + 0.2 * f * f + 0.1 * p * f + 0.2 * Math.sqrt(Math.abs(p));
210
+ return v += (20 * Math.sin(6 * p * t) + 20 * Math.sin(2 * p * t)) * 2 / 3, v += (20 * Math.sin(f * t) + 40 * Math.sin(f / 3 * t)) * 2 / 3, v += (160 * Math.sin(f / 12 * t) + 320 * Math.sin(f * t / 30)) * 2 / 3, v;
211
+ }
212
+ function T(p, f) {
213
+ var v = 300 + p + 2 * f + 0.1 * p * p + 0.1 * p * f + 0.1 * Math.sqrt(Math.abs(p));
214
+ return v += (20 * Math.sin(6 * p * t) + 20 * Math.sin(2 * p * t)) * 2 / 3, v += (20 * Math.sin(p * t) + 40 * Math.sin(p / 3 * t)) * 2 / 3, v += (150 * Math.sin(p / 12 * t) + 300 * Math.sin(p / 30 * t)) * 2 / 3, v;
215
+ }
216
+ return {
217
+ // 向前兼容
218
+ bd09togcj02: l,
219
+ gcj02tobd09: c,
220
+ wgs84togcj02: u,
221
+ gcj02towgs84: d,
222
+ // 小驼峰命名风格
223
+ bd09ToGcj02: l,
224
+ gcj02ToBd09: c,
225
+ wgs84ToGcj02: u,
226
+ gcj02ToWgs84: d,
227
+ bd09ToWgs84: function(p, f) {
228
+ if (!n(p, f))
229
+ return [p, f];
230
+ var v = l(p, f);
231
+ return d(v[0], v[1]);
232
+ },
233
+ wgs84ToBd09: function(p, f) {
234
+ if (!n(p, f))
235
+ return [p, f];
236
+ var v = u(p, f);
237
+ return c(v[0], v[1]);
238
+ }
239
+ };
240
+ });
241
+ })(ir);
242
+ function ne(i, e) {
243
+ if (!i)
244
+ throw new Error(`AssertionError: ${e}`);
245
+ }
246
+ function pt(i) {
247
+ throw new Error(`Unexpected object: ${i}`);
248
+ }
249
+ var Y = /* @__PURE__ */ ((i) => (i.wgs84 = "wgs84", i.gcj02 = "gcj02", i.bd09 = "bd09", i))(Y || {});
250
+ const xe = "wgs84", S = class {
251
+ constructor(e, t, r) {
252
+ this.lat = e, this.lng = t, this.coord = r;
253
+ }
254
+ /** @param coord Baidu Map的坐标一般都是bd09 */
255
+ static fromBaidu(e, t) {
256
+ return new S(e.lat, e.lng, t);
257
+ }
258
+ /** @param coord Google Map的坐标依据地图类型不同是不一样的 */
259
+ static fromGoogle(e, t) {
260
+ return new S(e.lat(), e.lng(), t);
261
+ }
262
+ static fromHere(e, t) {
263
+ return new S(e.lat, e.lng, t);
264
+ }
265
+ static fromLiteral(e) {
266
+ return new S(e.lat, e.lng, e.coord || xe);
267
+ }
268
+ static fromLngLat(e, t, r = xe) {
269
+ return new S(t, e, r);
270
+ }
271
+ static create(e, t, r = xe) {
272
+ return new S(e, t, r);
273
+ }
274
+ to(e) {
275
+ if (this.coord === e)
276
+ return this;
277
+ const [t, r] = this.convert(e);
278
+ return new S(r, t, e);
279
+ }
280
+ toBaidu(e) {
281
+ let t = this.lat, r = this.lng;
282
+ return this.coord !== e && ([r, t] = this.convert(e)), new BMap.Point(r, t);
283
+ }
284
+ toGoogle(e) {
285
+ let t = this.lat, r = this.lng;
286
+ return this.coord !== e && ([r, t] = this.convert(e)), new google.maps.LatLng(t, r);
287
+ }
288
+ toHere(e) {
289
+ let t = this.lat, r = this.lng;
290
+ return this.coord !== e && ([r, t] = this.convert(e)), new H.geo.Point(t, r);
291
+ }
292
+ /**
293
+ * 该方法之所以设计的这么不友好, 是为了防止不必要的开销(大概有点影响😅)
294
+ *
295
+ * @returns `[lng, lat]` 注意不要取错顺序
296
+ * @throws 若当前coord和targetCoord相同, 会抛异常, 故请在外部判断
297
+ */
298
+ // TODO: 2023/03/14 ipcjs 这里设成private, 有些地方会报类型错误...
299
+ /*private*/
300
+ convert(e) {
301
+ switch (this.coord) {
302
+ case "bd09":
303
+ return e === "gcj02" ? j.bd09ToGcj02(this.lng, this.lat) : j.bd09ToWgs84(this.lng, this.lat);
304
+ case "gcj02":
305
+ return e === "wgs84" ? j.gcj02ToWgs84(this.lng, this.lat) : j.gcj02ToBd09(this.lng, this.lat);
306
+ case "wgs84":
307
+ return e === "bd09" ? j.wgs84ToBd09(this.lng, this.lat) : j.wgs84ToGcj02(this.lng, this.lat);
308
+ }
309
+ throw new Error(`不支持的坐标转换: ${this.coord}=>${e}`);
310
+ }
311
+ equals(e) {
312
+ return this === e ? !0 : this.lat === e.lat && this.lng === e.lng && this.coord === e.coord;
313
+ }
314
+ toString() {
315
+ return JSON.stringify(this);
316
+ }
317
+ };
318
+ let y = S;
319
+ h(y, "ZERO", S.create(0, 0));
320
+ const U = class {
321
+ /**
322
+ * 不推荐直接创建LatLngBounds, sw和ne的大小关系可能没法保证, 推荐用LatLngBounds.Builder或者LatLngBounds.from等静态方法来创建
323
+ * @param sw 西南, lat/lng更小
324
+ * @param ne 东北, lat/lng更大
325
+ */
326
+ constructor(e, t) {
327
+ h(this, "coord");
328
+ this.sw = e, this.ne = t, ne(e.coord === t.coord, "sw和ne的coord应该相同"), ne(Number.isFinite(e.lat) && Number.isFinite(e.lng) && Number.isFinite(t.lat) && Number.isFinite(t.lng), `sw(${e})和ne(${t})不能包含NaN或Infinite`), ne(e.lat <= t.lat, `sw.lat(${e.lat})应该比ne.lat(${t.lat})小`), this.coord = e.coord;
329
+ }
330
+ static isBetweenLng(e, t, r) {
331
+ return e <= t ? e <= r && r <= t : e <= r || r <= t;
332
+ }
333
+ static fromArray(e) {
334
+ if (e.length === 0)
335
+ return;
336
+ const t = new U.Builder(e[0]);
337
+ for (let r = 1; r < e.length; r++)
338
+ t.include(e[r]);
339
+ return t.build();
340
+ }
341
+ static from(...e) {
342
+ return this.fromArray(e) ?? I("positions中没有点");
343
+ }
344
+ static fromGoogle(e, t) {
345
+ return new U(
346
+ y.fromGoogle(e.getSouthWest(), t),
347
+ y.fromGoogle(e.getNorthEast(), t)
348
+ );
349
+ }
350
+ static fromBaidu(e, t) {
351
+ return new U(
352
+ y.fromBaidu(e.getSouthWest(), t),
353
+ y.fromBaidu(e.getNorthEast(), t)
354
+ );
355
+ }
356
+ static create(e, t) {
357
+ return this.from(e, t);
358
+ }
359
+ isEmpty() {
360
+ return this.sw.equals(this.ne);
361
+ }
362
+ contains(e) {
363
+ const { lat: t, lng: r } = e.to(this.coord);
364
+ return this.sw.lat <= t && t <= this.ne.lat && U.isBetweenLng(this.sw.lng, this.ne.lng, r);
365
+ }
366
+ getCenter() {
367
+ const e = (this.sw.lat + this.ne.lat) / 2, t = (this.sw.lng + this.ne.lng + (this.sw.lng < this.ne.lng ? 0 : 360)) / 2;
368
+ return y.create(e, t, this.coord);
369
+ }
370
+ toString() {
371
+ return JSON.stringify(this);
372
+ }
373
+ equals(e) {
374
+ return this.sw.equals(e.sw) && this.ne.equals(e.ne);
375
+ }
376
+ toGoogle(e) {
377
+ return new google.maps.LatLngBounds(this.sw.toGoogle(e), this.ne.toGoogle(e));
378
+ }
379
+ toBaidu(e) {
380
+ return new BMap.Bounds(this.sw.toBaidu(e), this.ne.toBaidu(e));
381
+ }
382
+ toBaiduArray(e) {
383
+ return [this.sw.toBaidu(e), this.ne.toBaidu(e)];
384
+ }
385
+ };
386
+ let W = U;
387
+ h(W, "EMPTY", new U(y.ZERO, y.ZERO));
388
+ ((i) => {
389
+ class e {
390
+ constructor(r) {
391
+ h(this, "coord");
392
+ h(this, "minLat");
393
+ h(this, "minLng");
394
+ h(this, "maxLat");
395
+ h(this, "maxLng");
396
+ this.coord = r.coord, this.minLat = this.maxLat = r.lat, this.minLng = this.maxLng = r.lng;
397
+ }
398
+ build() {
399
+ return new i(
400
+ // sw对应min
401
+ y.create(this.minLat, this.minLng, this.coord),
402
+ // ne对应max
403
+ y.create(this.maxLat, this.maxLng, this.coord)
404
+ );
405
+ }
406
+ include(r) {
407
+ const { lat: s, lng: o } = r.to(this.coord);
408
+ return this.minLat = Math.min(this.minLat, s), this.maxLat = Math.max(this.maxLat, s), i.isBetweenLng(this.minLng, this.maxLng, o) || (this.delta(this.minLng, o) < this.delta(o, this.maxLng) ? this.minLng = o : this.maxLng = o), this;
409
+ }
410
+ delta(r, s) {
411
+ return (r - s + 360) % 360;
412
+ }
413
+ }
414
+ i.Builder = e;
415
+ })(W || (W = {}));
416
+ function Ii() {
417
+ }
418
+ function Pi(i) {
419
+ return i;
420
+ }
421
+ function Li(i, e) {
422
+ return i instanceof e;
423
+ }
424
+ function Bi(i, e) {
425
+ if (i instanceof e)
426
+ return i;
427
+ }
428
+ function re(i, e) {
429
+ if ((i == null ? void 0 : i.$options.name) === e.name)
430
+ return i;
431
+ }
432
+ class Re {
433
+ constructor(e) {
434
+ h(this, "latestInfoWindow");
435
+ /** 使用{@link setEventTargetDelegate}初始化 */
436
+ h(this, "delegate", void 0);
437
+ this.element = e, {}.NODE_ENV !== "production" && setTimeout(() => {
438
+ this.delegate || console.warn(`${this.constructor.name}继承了AbstractMap, 但未调用setEventTargetDelegate(delegate)`);
439
+ });
440
+ }
441
+ setEventTargetDelegate(e) {
442
+ this.delegate = e.setTarget(this);
443
+ }
444
+ addEventListener(e, t) {
445
+ this.delegate.addEventListener(e, t);
446
+ }
447
+ removeEventListener(e, t) {
448
+ this.delegate.removeEventListener(e, t);
449
+ }
450
+ /** 最后一次显示的InfoWindow, 不保证当前它仍然是打开状态 */
451
+ getLatestInfoWindow() {
452
+ return this.latestInfoWindow;
453
+ }
454
+ /** 仅用于@tg/map内部使用, 外部不要调用 */
455
+ setLatestInfoWindowInternal(e) {
456
+ this.latestInfoWindow = e;
457
+ }
458
+ addOverlayMapType(e) {
459
+ this.addLayer(e);
460
+ }
461
+ removeOverlayMapType(e) {
462
+ this.removeLayer(e);
463
+ }
464
+ addControl(e) {
465
+ e.addTo(this);
466
+ }
467
+ removeControl(e) {
468
+ e.removeFrom(this);
469
+ }
470
+ // 同名方法
471
+ getZoom() {
472
+ return this.innerMap.getZoom();
473
+ }
474
+ setZoom(e) {
475
+ this.innerMap.setZoom(e);
476
+ }
477
+ }
478
+ var sr = function(e) {
479
+ return or(e) && !nr(e);
480
+ };
481
+ function or(i) {
482
+ return !!i && typeof i == "object";
483
+ }
484
+ function nr(i) {
485
+ var e = Object.prototype.toString.call(i);
486
+ return e === "[object RegExp]" || e === "[object Date]" || hr(i);
487
+ }
488
+ var ar = typeof Symbol == "function" && Symbol.for, lr = ar ? Symbol.for("react.element") : 60103;
489
+ function hr(i) {
490
+ return i.$$typeof === lr;
491
+ }
492
+ function cr(i) {
493
+ return Array.isArray(i) ? [] : {};
494
+ }
495
+ function ae(i, e) {
496
+ return e.clone !== !1 && e.isMergeableObject(i) ? Q(cr(i), i, e) : i;
497
+ }
498
+ function dr(i, e, t) {
499
+ return i.concat(e).map(function(r) {
500
+ return ae(r, t);
501
+ });
502
+ }
503
+ function pr(i, e) {
504
+ if (!e.customMerge)
505
+ return Q;
506
+ var t = e.customMerge(i);
507
+ return typeof t == "function" ? t : Q;
508
+ }
509
+ function ur(i) {
510
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(i).filter(function(e) {
511
+ return Object.propertyIsEnumerable.call(i, e);
512
+ }) : [];
513
+ }
514
+ function ut(i) {
515
+ return Object.keys(i).concat(ur(i));
516
+ }
517
+ function bt(i, e) {
518
+ try {
519
+ return e in i;
520
+ } catch {
521
+ return !1;
522
+ }
523
+ }
524
+ function gr(i, e) {
525
+ return bt(i, e) && !(Object.hasOwnProperty.call(i, e) && Object.propertyIsEnumerable.call(i, e));
526
+ }
527
+ function mr(i, e, t) {
528
+ var r = {};
529
+ return t.isMergeableObject(i) && ut(i).forEach(function(s) {
530
+ r[s] = ae(i[s], t);
531
+ }), ut(e).forEach(function(s) {
532
+ gr(i, s) || (bt(i, s) && t.isMergeableObject(e[s]) ? r[s] = pr(s, t)(i[s], e[s], t) : r[s] = ae(e[s], t));
533
+ }), r;
534
+ }
535
+ function Q(i, e, t) {
536
+ t = t || {}, t.arrayMerge = t.arrayMerge || dr, t.isMergeableObject = t.isMergeableObject || sr, t.cloneUnlessOtherwiseSpecified = ae;
537
+ var r = Array.isArray(e), s = Array.isArray(i), o = r === s;
538
+ return o ? r ? t.arrayMerge(i, e, t) : mr(i, e, t) : ae(e, t);
539
+ }
540
+ Q.all = function(e, t) {
541
+ if (!Array.isArray(e))
542
+ throw new Error("first argument should be an array");
543
+ return e.reduce(function(r, s) {
544
+ return Q(r, s, t);
545
+ }, {});
546
+ };
547
+ var fr = Q, Tt = fr;
548
+ /*!
549
+ * isobject <https://github.com/jonschlinkert/isobject>
550
+ *
551
+ * Copyright (c) 2014-2017, Jon Schlinkert.
552
+ * Released under the MIT License.
553
+ */
554
+ function yr(i) {
555
+ return i != null && typeof i == "object" && Array.isArray(i) === !1;
556
+ }
557
+ /*!
558
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
559
+ *
560
+ * Copyright (c) 2014-2017, Jon Schlinkert.
561
+ * Released under the MIT License.
562
+ */
563
+ function gt(i) {
564
+ return yr(i) === !0 && Object.prototype.toString.call(i) === "[object Object]";
565
+ }
566
+ function Ot(i) {
567
+ var e, t;
568
+ return !(gt(i) === !1 || (e = i.constructor, typeof e != "function") || (t = e.prototype, gt(t) === !1) || t.hasOwnProperty("isPrototypeOf") === !1);
569
+ }
570
+ var le;
571
+ ((i) => {
572
+ function e(o, a) {
573
+ return o.reduce((g, n) => (g[a(n)] = n, g), {});
574
+ }
575
+ i.fromArray = e;
576
+ function t(o) {
577
+ return o.reduce((a, g) => (a[g[0]] = g[1], a), {});
578
+ }
579
+ i.fromEntries = t;
580
+ function r(o) {
581
+ return JSON.stringify(o, (a, g) => typeof g == "object" && Object.getPrototypeOf(g) !== Object.prototype ? g.toString !== Object.prototype.toString ? g.toString() : `[object ${Object.getPrototypeOf(g).constructor.name}]` : g);
582
+ }
583
+ i.toJsonSafely = r;
584
+ function s(o) {
585
+ Ot(o) && Object.keys(o).forEach((a) => {
586
+ o[a] === void 0 ? delete o[a] : s(o[a]);
587
+ });
588
+ }
589
+ i.deleteUndefinedPropertyOnPlainObjectDeeply = s;
590
+ })(le || (le = {}));
591
+ le.toJsonSafely;
592
+ var N = /* @__PURE__ */ ((i) => (i.auto = "auto", i.none = "none", i.greedy = "greedy", i.cooperative = "cooperative", i))(N || {}), Le;
593
+ ((i) => {
594
+ function e(t) {
595
+ le.deleteUndefinedPropertyOnPlainObjectDeeply(t);
596
+ const r = { center: y.ZERO, zoom: 5 };
597
+ return Tt(r, t || {}, {
598
+ isMergeableObject: Ot
599
+ });
600
+ }
601
+ i.create = e;
602
+ })(Le || (Le = {}));
603
+ var Be = {}, vr = {
604
+ get exports() {
605
+ return Be;
606
+ },
607
+ set exports(i) {
608
+ Be = i;
609
+ }
610
+ };
611
+ (function(i, e) {
612
+ (function(t, r) {
613
+ i.exports = r();
614
+ })(Mt, function() {
615
+ var t, r = t = r || { version: "1.3.8" }, s = {};
616
+ r.guid = "$BAIDU$", s[r.guid] = s[r.guid] || {}, r.dom = r.dom || {}, r.dom.g = function(n) {
617
+ return typeof n == "string" || n instanceof String ? document.getElementById(n) : n && n.nodeName && (n.nodeType == 1 || n.nodeType == 9) ? n : null;
618
+ }, r.g = r.G = r.dom.g, r.dom.getDocument = function(n) {
619
+ return n = r.dom.g(n), n.nodeType == 9 ? n : n.ownerDocument || n.document;
620
+ }, r.lang = r.lang || {}, r.lang.isString = function(n) {
621
+ return Object.prototype.toString.call(n) == "[object String]";
622
+ }, r.isString = r.lang.isString, r.dom._g = function(n) {
623
+ return r.lang.isString(n) ? document.getElementById(n) : n;
624
+ }, r._g = r.dom._g, r.browser = r.browser || {}, /msie (\d+\.\d)/i.test(navigator.userAgent) && (r.browser.ie = r.ie = document.documentMode || +RegExp.$1), r.dom.getComputedStyle = function(n, l) {
625
+ n = r.dom._g(n);
626
+ var c = r.dom.getDocument(n), u;
627
+ return c.defaultView && c.defaultView.getComputedStyle && (u = c.defaultView.getComputedStyle(n, null), u) ? u[l] || u.getPropertyValue(l) : "";
628
+ }, r.dom._styleFixer = r.dom._styleFixer || {}, r.dom._styleFilter = r.dom._styleFilter || [], r.dom._styleFilter.filter = function(n, l, c) {
629
+ for (var u = 0, d = r.dom._styleFilter, b; b = d[u]; u++)
630
+ (b = b[c]) && (l = b(n, l));
631
+ return l;
632
+ }, r.string = r.string || {}, r.string.toCamelCase = function(n) {
633
+ return n.indexOf("-") < 0 && n.indexOf("_") < 0 ? n : n.replace(/[-_][^-_]/g, function(l) {
634
+ return l.charAt(1).toUpperCase();
635
+ });
636
+ }, r.dom.getStyle = function(n, l) {
637
+ var c = r.dom;
638
+ n = c.g(n), l = r.string.toCamelCase(l);
639
+ var u = n.style[l] || (n.currentStyle ? n.currentStyle[l] : "") || c.getComputedStyle(n, l);
640
+ if (!u) {
641
+ var d = c._styleFixer[l];
642
+ d && (u = d.get ? d.get(n) : r.dom.getStyle(n, d));
643
+ }
644
+ return (d = c._styleFilter) && (u = d.filter(l, u, "get")), u;
645
+ }, r.getStyle = r.dom.getStyle, /opera\/(\d+\.\d)/i.test(navigator.userAgent) && (r.browser.opera = +RegExp.$1), r.browser.isWebkit = /webkit/i.test(navigator.userAgent), r.browser.isGecko = /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent), r.browser.isStrict = document.compatMode == "CSS1Compat", r.dom.getPosition = function(n) {
646
+ n = r.dom.g(n);
647
+ var l = r.dom.getDocument(n), c = r.browser, u = r.dom.getStyle;
648
+ c.isGecko > 0 && l.getBoxObjectFor && u(n, "position") == "absolute" && (n.style.top === "" || n.style.left);
649
+ var d = { left: 0, top: 0 }, b = c.ie && !c.isStrict ? l.body : l.documentElement, M, T;
650
+ if (n == b)
651
+ return d;
652
+ if (n.getBoundingClientRect) {
653
+ T = n.getBoundingClientRect(), d.left = Math.floor(T.left) + Math.max(l.documentElement.scrollLeft, l.body.scrollLeft), d.top = Math.floor(T.top) + Math.max(l.documentElement.scrollTop, l.body.scrollTop), d.left -= l.documentElement.clientLeft, d.top -= l.documentElement.clientTop;
654
+ var p = l.body, f = parseInt(u(p, "borderLeftWidth")), v = parseInt(u(p, "borderTopWidth"));
655
+ c.ie && !c.isStrict && (d.left -= isNaN(f) ? 2 : f, d.top -= isNaN(v) ? 2 : v);
656
+ } else {
657
+ M = n;
658
+ do {
659
+ if (d.left += M.offsetLeft, d.top += M.offsetTop, c.isWebkit > 0 && u(M, "position") == "fixed") {
660
+ d.left += l.body.scrollLeft, d.top += l.body.scrollTop;
661
+ break;
662
+ }
663
+ M = M.offsetParent;
664
+ } while (M && M != n);
665
+ for ((c.opera > 0 || c.isWebkit > 0 && u(n, "position") == "absolute") && (d.top -= l.body.offsetTop), M = n.offsetParent; M && M != l.body; )
666
+ d.left -= M.scrollLeft, (!c.opera || M.tagName != "TR") && (d.top -= M.scrollTop), M = M.offsetParent;
667
+ }
668
+ return d;
669
+ }, r.event = r.event || {}, r.event._listeners = r.event._listeners || [], r.event.on = function(n, l, c) {
670
+ l = l.replace(/^on/i, ""), n = r.dom._g(n);
671
+ var u = function(p) {
672
+ c.call(n, p);
673
+ }, d = r.event._listeners, b = r.event._eventFilter, M, T = l;
674
+ return l = l.toLowerCase(), b && b[l] && (M = b[l](n, l, u), T = M.type, u = M.listener), n.addEventListener ? n.addEventListener(T, u, !1) : n.attachEvent && n.attachEvent("on" + T, u), d[d.length] = [n, l, c, u, T], n;
675
+ }, r.on = r.event.on, function() {
676
+ var n = s[r.guid];
677
+ r.lang.guid = function() {
678
+ return "TANGRAM__" + (n._counter++).toString(36);
679
+ }, n._counter = n._counter || 1;
680
+ }(), s[r.guid]._instances = s[r.guid]._instances || {}, r.lang.isFunction = function(n) {
681
+ return Object.prototype.toString.call(n) == "[object Function]";
682
+ }, r.lang.Class = function(n) {
683
+ this.guid = n || r.lang.guid(), s[r.guid]._instances[this.guid] = this;
684
+ }, s[r.guid]._instances = s[r.guid]._instances || {}, r.lang.Class.prototype.dispose = function() {
685
+ delete s[r.guid]._instances[this.guid];
686
+ for (var n in this)
687
+ r.lang.isFunction(this[n]) || delete this[n];
688
+ this.disposed = !0;
689
+ }, r.lang.Class.prototype.toString = function() {
690
+ return "[object " + (this._className || "Object") + "]";
691
+ }, r.lang.Event = function(n, l) {
692
+ this.type = n, this.returnValue = !0, this.target = l || null, this.currentTarget = null;
693
+ }, r.lang.Class.prototype.addEventListener = function(n, l, c) {
694
+ if (r.lang.isFunction(l)) {
695
+ !this.__listeners && (this.__listeners = {});
696
+ var u = this.__listeners, d;
697
+ if (typeof c == "string" && c) {
698
+ if (/[^\w\-]/.test(c))
699
+ throw "nonstandard key:" + c;
700
+ l.hashCode = c, d = c;
701
+ }
702
+ n.indexOf("on") != 0 && (n = "on" + n), typeof u[n] != "object" && (u[n] = {}), d = d || r.lang.guid(), l.hashCode = d, u[n][d] = l;
703
+ }
704
+ }, r.lang.Class.prototype.removeEventListener = function(n, l) {
705
+ if (!(typeof l < "u" && (r.lang.isFunction(l) && !(l = l.hashCode) || !r.lang.isString(l)))) {
706
+ !this.__listeners && (this.__listeners = {}), n.indexOf("on") != 0 && (n = "on" + n);
707
+ var c = this.__listeners;
708
+ if (c[n])
709
+ if (typeof l < "u")
710
+ c[n][l] && delete c[n][l];
711
+ else
712
+ for (var u in c[n])
713
+ delete c[n][u];
714
+ }
715
+ }, r.lang.Class.prototype.dispatchEvent = function(n, l) {
716
+ r.lang.isString(n) && (n = new r.lang.Event(n)), !this.__listeners && (this.__listeners = {}), l = l || {};
717
+ for (var c in l)
718
+ n[c] = l[c];
719
+ var c, u = this.__listeners, d = n.type;
720
+ if (n.target = n.target || this, n.currentTarget = this, d.indexOf("on") != 0 && (d = "on" + d), r.lang.isFunction(this[d]) && this[d].apply(this, arguments), typeof u[d] == "object")
721
+ for (c in u[d])
722
+ u[d][c].apply(this, arguments);
723
+ return n.returnValue;
724
+ }, r.lang.inherits = function(n, l, c) {
725
+ var u, d, b = n.prototype, M = new Function();
726
+ M.prototype = l.prototype, d = n.prototype = new M();
727
+ for (u in b)
728
+ d[u] = b[u];
729
+ n.prototype.constructor = n, n.superClass = l.prototype, typeof c == "string" && (d._className = c);
730
+ }, r.inherits = r.lang.inherits;
731
+ var o = "http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m", a = "png", g = function(n, l, c) {
732
+ try {
733
+ BMap;
734
+ } catch {
735
+ throw Error("Baidu Map JS API is not ready yet!");
736
+ }
737
+ t.lang.inherits(g, BMap.Overlay, "TextIconOverlay"), this._position = n, this._text = l, this._options = c || {}, this._styles = this._options.styles || [], this._zIndex = this._options.zIndex, !this._styles.length && this._setupDefaultStyles();
738
+ };
739
+ return g.prototype._setupDefaultStyles = function() {
740
+ for (var n = [53, 56, 66, 78, 90], l = 0, c; c = n[l]; l++)
741
+ this._styles.push({
742
+ url: o + l + "." + a,
743
+ size: new BMap.Size(c, c)
744
+ });
745
+ }, g.prototype.initialize = function(n) {
746
+ return this._map = n, this._domElement = document.createElement("div"), this._updateCss(), this._updateText(), this._updatePosition(), this._bind(), this._map.getPanes().markerMouseTarget.appendChild(this._domElement), this._domElement;
747
+ }, g.prototype.draw = function() {
748
+ this._map && this._updatePosition();
749
+ }, g.prototype.getText = function() {
750
+ return this._text;
751
+ }, g.prototype.setText = function(n) {
752
+ n && (!this._text || this._text.toString() != n.toString()) && (this._text = n, this._updateText(), this._updateCss(), this._updatePosition());
753
+ }, g.prototype.getPosition = function() {
754
+ return this._position;
755
+ }, g.prototype.setPosition = function(n) {
756
+ n && (!this._position || !this._position.equals(n)) && (this._position = n, this._updatePosition());
757
+ }, g.prototype.getStyleByText = function(n, l) {
758
+ var c = parseInt(n), u = parseInt(c / 10);
759
+ return u = Math.max(0, u), u = Math.min(u, l.length - 1), l[u];
760
+ }, g.prototype._updateCss = function() {
761
+ if (this._domElement) {
762
+ var n = this.getStyleByText(this._text, this._styles);
763
+ this._domElement.style.cssText = this._buildCssText(n);
764
+ }
765
+ }, g.prototype._updateText = function() {
766
+ this._domElement && (this._domElement.innerHTML = this._text);
767
+ }, g.prototype._updatePosition = function() {
768
+ if (this._domElement && this._position) {
769
+ var n = this._domElement.style, l = this._map.pointToOverlayPixel(this._position);
770
+ l.x -= Math.ceil(parseInt(n.width) / 2), l.y -= Math.ceil(parseInt(n.height) / 2), n.left = l.x + "px", n.top = l.y + "px";
771
+ }
772
+ }, g.prototype._buildCssText = function(n) {
773
+ var l = n.url, c = n.size, u = n.anchor, d = n.offset, b = n.textColor || "black", M = n.textSize || 10, T = [];
774
+ if (this._zIndex && T.push("z-index:" + this._zIndex + ";"), t.browser.ie < 7)
775
+ T.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="' + l + '");');
776
+ else {
777
+ T.push("background-image:url(" + l + ");");
778
+ var p = "0 0";
779
+ d instanceof BMap.Size && (p = d.width + "px " + d.height + "px"), T.push("background-position:" + p + ";");
780
+ }
781
+ return c instanceof BMap.Size && (u instanceof BMap.Size ? (u.height > 0 && u.height < c.height && T.push("height:" + (c.height - u.height) + "px; padding-top:" + u.height + "px;"), u.width > 0 && u.width < c.width && T.push("width:" + (c.width - u.width) + "px; padding-left:" + u.width + "px;")) : (T.push("height:" + c.height + "px; line-height:" + c.height + "px;"), T.push("width:" + c.width + "px; text-align:center;"))), T.push("cursor:pointer; color:" + b + "; position:absolute; font-size:" + M + "px; font-family:Arial,sans-serif; font-weight:bold"), T.join("");
782
+ }, g.prototype._bind = function() {
783
+ if (!this._domElement)
784
+ return;
785
+ var n = this, l = this._map, c = t.lang.Event;
786
+ function u(d, b) {
787
+ var M = d.srcElement || d.target, T = d.clientX || d.pageX, p = d.clientY || d.pageY;
788
+ if (d && b && T && p && M) {
789
+ var f = t.dom.getPosition(l.getContainer());
790
+ b.pixel = new BMap.Pixel(T - f.left, p - f.top), b.point = l.pixelToPoint(b.pixel);
791
+ }
792
+ return b;
793
+ }
794
+ t.event.on(this._domElement, "mouseover", function(d) {
795
+ n.dispatchEvent(u(d, new c("onmouseover")));
796
+ }), t.event.on(this._domElement, "mouseout", function(d) {
797
+ n.dispatchEvent(u(d, new c("onmouseout")));
798
+ }), t.event.on(this._domElement, "click", function(d) {
799
+ n.dispatchEvent(u(d, new c("onclick")));
800
+ });
801
+ }, g;
802
+ });
803
+ })(vr);
804
+ const mt = Be;
805
+ var Ct = function(i, e, t) {
806
+ e = _r(e);
807
+ var r = i.pointToPixel(e.getNorthEast()), s = i.pointToPixel(e.getSouthWest());
808
+ r.x += t, r.y -= t, s.x -= t, s.y += t;
809
+ var o = i.pixelToPoint(r), a = i.pixelToPoint(s);
810
+ return new BMap.Bounds(a, o);
811
+ }, _r = function(i) {
812
+ var e = ge(i.getNorthEast().lng, -180, 180), t = ge(i.getSouthWest().lng, -180, 180), r = ge(i.getNorthEast().lat, -74, 74), s = ge(i.getSouthWest().lat, -74, 74);
813
+ return new BMap.Bounds(new BMap.Point(t, s), new BMap.Point(e, r));
814
+ }, ge = function(i, e, t) {
815
+ return e && (i = Math.max(i, e)), t && (i = Math.min(i, t)), i;
816
+ }, wt = function(i) {
817
+ return Object.prototype.toString.call(i) === "[object Array]";
818
+ }, xt = function(i, e) {
819
+ var t = -1;
820
+ if (wt(e)) {
821
+ if (e.indexOf)
822
+ t = e.indexOf(i);
823
+ else
824
+ for (var r = 0, s; s = e[r]; r++)
825
+ if (s === i) {
826
+ t = r;
827
+ break;
828
+ }
829
+ }
830
+ return t;
831
+ }, _ = function(i, e) {
832
+ try {
833
+ BMap;
834
+ } catch {
835
+ throw Error("Baidu Map JS API is not ready yet!");
836
+ }
837
+ if (i) {
838
+ this._map = i, this._markers = [], this._clusters = [];
839
+ var t = e || {};
840
+ this._zIndex = t.zIndex, this._gridSize = t.gridSize || 60, this._maxZoom = t.maxZoom || 18, this._minClusterSize = t.minClusterSize || 2, this._isAverageCenter = !1, t.isAverageCenter != null && (this._isAverageCenter = t.isAverageCenter), this._styles = t.styles || [];
841
+ var r = this;
842
+ this._map.addEventListener("zoomend", function() {
843
+ r._redraw();
844
+ }), this._map.addEventListener("moveend", function() {
845
+ r._redraw();
846
+ });
847
+ var s = t.markers;
848
+ wt(s) && this.addMarkers(s);
849
+ }
850
+ };
851
+ _.prototype.addMarkers = function(i) {
852
+ if (i.length) {
853
+ for (var e = 0, t = i.length; e < t; e++)
854
+ this._pushMarkerTo(i[e]);
855
+ this._createClusters();
856
+ }
857
+ };
858
+ _.prototype._pushMarkerTo = function(i) {
859
+ var e = xt(i, this._markers);
860
+ e === -1 && (i.isInCluster = !1, this._markers.push(i));
861
+ };
862
+ _.prototype.addMarker = function(i) {
863
+ this._pushMarkerTo(i), this._createClusters();
864
+ };
865
+ _.prototype._createClusters = function() {
866
+ var i = this._map.getBounds();
867
+ if (i.getCenter()) {
868
+ for (var e = Ct(this._map, i, this._gridSize), t = 0, r; r = this._markers[t]; t++)
869
+ !r.isInCluster && e.containsPoint(r.getPosition()) && this._addToClosestCluster(r);
870
+ for (var s = this._markers.length, t = 0; t < s; t++)
871
+ this._clusters[t] && this._clusters[t].render();
872
+ }
873
+ };
874
+ _.prototype._addToClosestCluster = function(i) {
875
+ var e = 4e6, t = null;
876
+ i.getPosition();
877
+ for (var r = 0, s; s = this._clusters[r]; r++) {
878
+ var o = s.getCenter();
879
+ if (o) {
880
+ var a = this._map.getDistance(o, i.getPosition());
881
+ a < e && (e = a, t = s);
882
+ }
883
+ }
884
+ if (t && t.isMarkerInClusterBounds(i))
885
+ t.addMarker(i);
886
+ else {
887
+ var s = new L(this);
888
+ s.addMarker(i), this._clusters.push(s);
889
+ }
890
+ };
891
+ _.prototype._clearLastClusters = function() {
892
+ for (var i = 0, e; e = this._clusters[i]; i++)
893
+ e.remove();
894
+ this._clusters = [], this._removeMarkersFromCluster();
895
+ };
896
+ _.prototype._removeMarkersFromCluster = function() {
897
+ for (var i = 0, e; e = this._markers[i]; i++)
898
+ e.isInCluster = !1;
899
+ };
900
+ _.prototype._removeMarkersFromMap = function() {
901
+ for (var i = 0, e; e = this._markers[i]; i++) {
902
+ e.isInCluster = !1;
903
+ var t = e.getLabel();
904
+ this._map.removeOverlay(e), e.setLabel(t);
905
+ }
906
+ };
907
+ _.prototype._removeMarker = function(i) {
908
+ var e = xt(i, this._markers);
909
+ return e === -1 ? !1 : (this._map.removeOverlay(i), this._markers.splice(e, 1), !0);
910
+ };
911
+ _.prototype.removeMarker = function(i) {
912
+ var e = this._removeMarker(i);
913
+ return e && (this._clearLastClusters(), this._createClusters()), e;
914
+ };
915
+ _.prototype.removeMarkers = function(i) {
916
+ for (var e = !1, t = 0; t < i.length; t++) {
917
+ var r = this._removeMarker(i[t]);
918
+ e = e || r;
919
+ }
920
+ return e && (this._clearLastClusters(), this._createClusters()), e;
921
+ };
922
+ _.prototype.clearMarkers = function() {
923
+ this._clearLastClusters(), this._removeMarkersFromMap(), this._markers = [];
924
+ };
925
+ _.prototype._redraw = function() {
926
+ this._clearLastClusters(), this._createClusters();
927
+ };
928
+ _.prototype.getGridSize = function() {
929
+ return this._gridSize;
930
+ };
931
+ _.prototype.setGridSize = function(i) {
932
+ this._gridSize = i, this._redraw();
933
+ };
934
+ _.prototype.getMaxZoom = function() {
935
+ return this._maxZoom;
936
+ };
937
+ _.prototype.setMaxZoom = function(i) {
938
+ this._maxZoom = i, this._redraw();
939
+ };
940
+ _.prototype.getZIndex = function() {
941
+ return this._zIndex;
942
+ };
943
+ _.prototype.setZIndex = function(i) {
944
+ this._zIndex != i && (this.zIndex = i, this._redraw());
945
+ };
946
+ _.prototype.getStyles = function() {
947
+ return this._styles;
948
+ };
949
+ _.prototype.setStyles = function(i) {
950
+ this._styles = i, this._redraw();
951
+ };
952
+ _.prototype.getMinClusterSize = function() {
953
+ return this._minClusterSize;
954
+ };
955
+ _.prototype.setMinClusterSize = function(i) {
956
+ this._minClusterSize = i, this._redraw();
957
+ };
958
+ _.prototype.isAverageCenter = function() {
959
+ return this._isAverageCenter;
960
+ };
961
+ _.prototype.getMap = function() {
962
+ return this._map;
963
+ };
964
+ _.prototype.getMarkers = function() {
965
+ return this._markers;
966
+ };
967
+ _.prototype.getClustersCount = function() {
968
+ for (var i = 0, e = 0, t; t = this._clusters[e]; e++)
969
+ t.isReal() && i++;
970
+ return i;
971
+ };
972
+ _.prototype._textCalculator = function(i) {
973
+ return i.length.toString();
974
+ };
975
+ _.prototype._stylesIndexCalculator = null;
976
+ _.prototype.setTextCalculator = function(i) {
977
+ this._textCalculator = i;
978
+ };
979
+ _.prototype.setStylesIndexCalculator = function(i) {
980
+ this._stylesIndexCalculator = i;
981
+ };
982
+ function L(i) {
983
+ var e = this;
984
+ 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 mt(this._center, this._markers.length, {
985
+ styles: this._markerClusterer.getStyles(),
986
+ zIndex: i._zIndex
987
+ }), this._clusterMarker.getStyleByText = function(t, r) {
988
+ if (e._markerClusterer._stylesIndexCalculator) {
989
+ var s = e._markerClusterer._stylesIndexCalculator(e._markers, r.length);
990
+ return r[s];
991
+ }
992
+ return mt.prototype.getStyleByText.call(this, t, r);
993
+ }, this._clusterMarker.addEventListener && this._clusterMarker.addEventListener("click", function(t) {
994
+ e._map.setViewport(e.getBounds());
995
+ });
996
+ }
997
+ L.prototype.addMarker = function(i) {
998
+ if (this.isMarkerInCluster(i))
999
+ return !1;
1000
+ if (!this._center)
1001
+ this._center = i.getPosition(), this.updateGridBounds();
1002
+ else if (this._isAverageCenter) {
1003
+ var e = this._markers.length + 1, t = (this._center.lat * (e - 1) + i.getPosition().lat) / e, r = (this._center.lng * (e - 1) + i.getPosition().lng) / e;
1004
+ this._center = new BMap.Point(r, t), this.updateGridBounds();
1005
+ }
1006
+ return i.isInCluster = !0, this._markers.push(i), !0;
1007
+ };
1008
+ L.prototype.render = function() {
1009
+ var i = this._markers.length;
1010
+ if (i < this._minClusterSize)
1011
+ for (var e = 0; e < i; e++)
1012
+ this._map.addOverlay(this._markers[e]);
1013
+ else
1014
+ this._map.addOverlay(this._clusterMarker), this._isReal = !0, this.updateClusterMarker();
1015
+ };
1016
+ L.prototype.isMarkerInCluster = function(i) {
1017
+ if (this._markers.indexOf)
1018
+ return this._markers.indexOf(i) != -1;
1019
+ for (var e = 0, t; t = this._markers[e]; e++)
1020
+ if (t === i)
1021
+ return !0;
1022
+ return !1;
1023
+ };
1024
+ L.prototype.isMarkerInClusterBounds = function(i) {
1025
+ return this._gridBounds.containsPoint(i.getPosition());
1026
+ };
1027
+ L.prototype.isReal = function(i) {
1028
+ return this._isReal;
1029
+ };
1030
+ L.prototype.updateGridBounds = function() {
1031
+ var i = new BMap.Bounds(this._center, this._center);
1032
+ this._gridBounds = Ct(this._map, i, this._markerClusterer.getGridSize());
1033
+ };
1034
+ L.prototype.updateClusterMarker = function() {
1035
+ if (this._map.getZoom() > this._markerClusterer.getMaxZoom()) {
1036
+ this._clusterMarker && this._map.removeOverlay(this._clusterMarker);
1037
+ for (var i = 0, e; e = this._markers[i]; i++)
1038
+ this._map.addOverlay(e);
1039
+ return;
1040
+ }
1041
+ if (this._markers.length < this._minClusterSize) {
1042
+ this._clusterMarker.hide();
1043
+ return;
1044
+ }
1045
+ this._clusterMarker.setPosition(this._center), this._clusterMarker.setText(this._markerClusterer._textCalculator(this._markers));
1046
+ };
1047
+ L.prototype.remove = function() {
1048
+ for (var i = 0, e; e = this._markers[i]; i++) {
1049
+ var t = this._markers[i].getLabel();
1050
+ this._markers[i].getMap() && this._map.removeOverlay(this._markers[i]), this._markers[i].setLabel(t);
1051
+ }
1052
+ this._map.removeOverlay(this._clusterMarker), this._markers.length = 0, delete this._markers;
1053
+ };
1054
+ L.prototype.getBounds = function() {
1055
+ for (var i = new BMap.Bounds(this._center, this._center), e = 0, t; t = this._markers[e]; e++)
1056
+ i.extend(t.getPosition());
1057
+ return i;
1058
+ };
1059
+ L.prototype.getCenter = function() {
1060
+ return this._center;
1061
+ };
1062
+ let Mr = class Et {
1063
+ constructor(e, t, r) {
1064
+ this.extend(Et, google.maps.OverlayView), this.map_ = e, this.MARKER_CLUSTER_IMAGE_PATH_ = "../images/m", this.MARKER_CLUSTER_IMAGE_EXTENSION_ = "png", this.markers_ = [], this.clusters_ = [], this.sizes = [53, 56, 66, 78, 90], this.styles_ = [], this.ready_ = !1;
1065
+ var s = r || {};
1066
+ this.zIndex_ = s.zIndex || google.maps.Marker.MAX_ZINDEX + 1, this.gridSize_ = s.gridSize || 60, this.minClusterSize_ = s.minimumClusterSize || 2, this.maxZoom_ = s.maxZoom || null, this.styles_ = s.styles || [], this.imagePath_ = s.imagePath || this.MARKER_CLUSTER_IMAGE_PATH_, this.imageExtension_ = s.imageExtension || this.MARKER_CLUSTER_IMAGE_EXTENSION_, this.zoomOnClick_ = !0, s.zoomOnClick != null && (this.zoomOnClick_ = s.zoomOnClick), this.averageCenter_ = !1, s.averageCenter != null && (this.averageCenter_ = s.averageCenter), this.setupStyles_(), this.setMap(e), this.prevZoom_ = this.map_.getZoom();
1067
+ var o = this;
1068
+ google.maps.event.addListener(this.map_, "zoom_changed", function() {
1069
+ var a = o.map_.getZoom(), g = o.map_.minZoom || 0, n = Math.min(
1070
+ o.map_.maxZoom || 100,
1071
+ o.map_.mapTypes[o.map_.getMapTypeId()].maxZoom
1072
+ );
1073
+ a = Math.min(Math.max(a, g), n), o.prevZoom_ != a && (o.prevZoom_ = a, o.resetViewport());
1074
+ }), google.maps.event.addListener(this.map_, "idle", function() {
1075
+ o.redraw();
1076
+ }), t && (t.length || Object.keys(t).length) && this.addMarkers(t, !1);
1077
+ }
1078
+ /**
1079
+ * Extends a objects prototype by anothers.
1080
+ *
1081
+ * @param {Object} obj1 The object to be extended.
1082
+ * @param {Object} obj2 The object to extend with.
1083
+ * @return {Object} The new extended object.
1084
+ * @ignore
1085
+ */
1086
+ extend(e, t) {
1087
+ return function(r) {
1088
+ for (var s in r.prototype)
1089
+ this.prototype[s] = r.prototype[s];
1090
+ return this;
1091
+ }.apply(e, [t]);
1092
+ }
1093
+ /**
1094
+ * Implementaion of the interface method.
1095
+ * @ignore
1096
+ */
1097
+ onAdd() {
1098
+ this.setReady_(!0);
1099
+ }
1100
+ /**
1101
+ * Implementaion of the interface method.
1102
+ * @ignore
1103
+ */
1104
+ draw() {
1105
+ }
1106
+ /**
1107
+ * Sets up the styles object.
1108
+ *
1109
+ * @private
1110
+ */
1111
+ setupStyles_() {
1112
+ if (!this.styles_.length)
1113
+ for (var e = 0, t; t = this.sizes[e]; e++)
1114
+ this.styles_.push({
1115
+ url: this.imagePath_ + (e + 1) + "." + this.imageExtension_,
1116
+ height: t,
1117
+ width: t
1118
+ });
1119
+ }
1120
+ /**
1121
+ * Fit the map to the bounds of the markers in the clusterer.
1122
+ */
1123
+ fitMapToMarkers() {
1124
+ for (var e = this.getMarkers(), t = new google.maps.LatLngBounds(), r = 0, s; s = e[r]; r++)
1125
+ t.extend(s.getPosition());
1126
+ this.map_.fitBounds(t);
1127
+ }
1128
+ /**
1129
+ * @param {number} zIndex
1130
+ */
1131
+ setZIndex(e) {
1132
+ this.zIndex_ = e;
1133
+ }
1134
+ /**
1135
+ * @return {number}
1136
+ */
1137
+ getZIndex() {
1138
+ return this.zIndex_;
1139
+ }
1140
+ /**
1141
+ * Sets the styles.
1142
+ *
1143
+ * @param {Object} styles The style to set.
1144
+ */
1145
+ setStyles(e) {
1146
+ this.styles_ = e;
1147
+ }
1148
+ /**
1149
+ * Gets the styles.
1150
+ *
1151
+ * @return {Object} The styles object.
1152
+ */
1153
+ getStyles() {
1154
+ return this.styles_;
1155
+ }
1156
+ /**
1157
+ * Whether zoom on click is set.
1158
+ *
1159
+ * @return {boolean} True if zoomOnClick_ is set.
1160
+ */
1161
+ isZoomOnClick() {
1162
+ return this.zoomOnClick_;
1163
+ }
1164
+ /**
1165
+ * Whether average center is set.
1166
+ *
1167
+ * @return {boolean} True if averageCenter_ is set.
1168
+ */
1169
+ isAverageCenter() {
1170
+ return this.averageCenter_;
1171
+ }
1172
+ /**
1173
+ * Returns the array of markers in the clusterer.
1174
+ *
1175
+ * @return {Array.<google.maps.Marker>} The markers.
1176
+ */
1177
+ getMarkers() {
1178
+ return this.markers_;
1179
+ }
1180
+ /**
1181
+ * Returns the number of markers in the clusterer
1182
+ *
1183
+ * @return {Number} The number of markers.
1184
+ */
1185
+ getTotalMarkers() {
1186
+ return this.markers_.length;
1187
+ }
1188
+ /**
1189
+ * Sets the max zoom for the clusterer.
1190
+ *
1191
+ * @param {number} maxZoom The max zoom level.
1192
+ */
1193
+ setMaxZoom(e) {
1194
+ this.maxZoom_ = e;
1195
+ }
1196
+ /**
1197
+ * Gets the max zoom for the clusterer.
1198
+ *
1199
+ * @return {number} The max zoom level.
1200
+ */
1201
+ getMaxZoom() {
1202
+ return this.maxZoom_;
1203
+ }
1204
+ /**
1205
+ * The function for calculating the cluster icon image.
1206
+ *
1207
+ * @param {Array.<google.maps.Marker>} markers The markers in the clusterer.
1208
+ * @param {number} numStyles The number of styles available.
1209
+ * @return {Object} A object properties: 'text' (string) and 'index' (number).
1210
+ * @private
1211
+ */
1212
+ calculator_(e, t) {
1213
+ for (var r = 0, s = e.length, o = s; o !== 0; )
1214
+ o = parseInt(o / 10, 10), r++;
1215
+ return r = Math.min(r, t), {
1216
+ text: s,
1217
+ index: r
1218
+ };
1219
+ }
1220
+ /**
1221
+ * Set the calculator function.
1222
+ *
1223
+ * @param {function(Array, number)} calculator The function to set as the
1224
+ * calculator. The function should return a object properties:
1225
+ * 'text' (string) and 'index' (number).
1226
+ *
1227
+ */
1228
+ setCalculator(e) {
1229
+ this.calculator_ = e;
1230
+ }
1231
+ /**
1232
+ * Get the calculator function.
1233
+ *
1234
+ * @return {function(Array, number)} the calculator function.
1235
+ */
1236
+ getCalculator() {
1237
+ return this.calculator_;
1238
+ }
1239
+ /**
1240
+ * Add an array of markers to the clusterer.
1241
+ *
1242
+ * @param {Array.<google.maps.Marker>} markers The markers to add.
1243
+ * @param {boolean=} opt_nodraw Whether to redraw the clusters.
1244
+ */
1245
+ addMarkers(e, t) {
1246
+ if (e.length)
1247
+ for (let r = 0, s; s = e[r]; r++)
1248
+ this.pushMarkerTo_(s);
1249
+ else if (Object.keys(e).length)
1250
+ for (let r in e)
1251
+ this.pushMarkerTo_(e[r]);
1252
+ t || this.redraw();
1253
+ }
1254
+ /**
1255
+ * Pushes a marker to the clusterer.
1256
+ *
1257
+ * @param {google.maps.Marker} marker The marker to add.
1258
+ * @private
1259
+ */
1260
+ pushMarkerTo_(e) {
1261
+ if (e.isAdded = !1, e.draggable) {
1262
+ var t = this;
1263
+ google.maps.event.addListener(e, "dragend", function() {
1264
+ e.isAdded = !1, t.repaint();
1265
+ });
1266
+ }
1267
+ this.markers_.push(e);
1268
+ }
1269
+ /**
1270
+ * Adds a marker to the clusterer and redraws if needed.
1271
+ *
1272
+ * @param {google.maps.Marker} marker The marker to add.
1273
+ * @param {boolean=} opt_nodraw Whether to redraw the clusters.
1274
+ */
1275
+ addMarker(e, t) {
1276
+ this.pushMarkerTo_(e), t || this.redraw();
1277
+ }
1278
+ /**
1279
+ * Removes a marker and returns true if removed, false if not
1280
+ *
1281
+ * @param {google.maps.Marker} marker The marker to remove
1282
+ * @return {boolean} Whether the marker was removed or not
1283
+ * @private
1284
+ */
1285
+ removeMarker_(e) {
1286
+ var t = -1;
1287
+ if (this.markers_.indexOf)
1288
+ t = this.markers_.indexOf(e);
1289
+ else
1290
+ for (var r = 0, s; s = this.markers_[r]; r++)
1291
+ if (s == e) {
1292
+ t = r;
1293
+ break;
1294
+ }
1295
+ return t == -1 ? !1 : (e.setMap(null), this.markers_.splice(t, 1), !0);
1296
+ }
1297
+ /**
1298
+ * Remove a marker from the cluster.
1299
+ *
1300
+ * @param {google.maps.Marker} marker The marker to remove.
1301
+ * @param {boolean=} opt_nodraw Optional boolean to force no redraw.
1302
+ * @return {boolean} True if the marker was removed.
1303
+ */
1304
+ removeMarker(e, t) {
1305
+ var r = this.removeMarker_(e);
1306
+ return !t && r ? (this.resetViewport(), this.redraw(), !0) : !1;
1307
+ }
1308
+ /**
1309
+ * Removes an array of markers from the cluster.
1310
+ *
1311
+ * @param {Array.<google.maps.Marker>} markers The markers to remove.
1312
+ * @param {boolean=} opt_nodraw Optional boolean to force no redraw.
1313
+ */
1314
+ removeMarkers(e, t) {
1315
+ for (var r = e === this.getMarkers() ? e.slice() : e, s = !1, o = 0, a; a = r[o]; o++) {
1316
+ var g = this.removeMarker_(a);
1317
+ s = s || g;
1318
+ }
1319
+ if (!t && s)
1320
+ return this.resetViewport(), this.redraw(), !0;
1321
+ }
1322
+ /**
1323
+ * Sets the clusterer's ready state.
1324
+ *
1325
+ * @param {boolean} ready The state.
1326
+ * @private
1327
+ */
1328
+ setReady_(e) {
1329
+ this.ready_ || (this.ready_ = e, this.createClusters_());
1330
+ }
1331
+ /**
1332
+ * Returns the number of clusters in the clusterer.
1333
+ *
1334
+ * @return {number} The number of clusters.
1335
+ */
1336
+ getTotalClusters() {
1337
+ return this.clusters_.length;
1338
+ }
1339
+ /**
1340
+ * Returns the google map that the clusterer is associated with.
1341
+ *
1342
+ * @return {google.maps.Map} The map.
1343
+ */
1344
+ getMap() {
1345
+ return this.map_;
1346
+ }
1347
+ /**
1348
+ * Sets the google map that the clusterer is associated with.
1349
+ *
1350
+ * @param {google.maps.Map} map The map.
1351
+ */
1352
+ setMap(e) {
1353
+ this.map_ = e;
1354
+ }
1355
+ /**
1356
+ * Returns the size of the grid.
1357
+ *
1358
+ * @return {number} The grid size.
1359
+ */
1360
+ getGridSize() {
1361
+ return this.gridSize_;
1362
+ }
1363
+ /**
1364
+ * Sets the size of the grid.
1365
+ *
1366
+ * @param {number} size The grid size.
1367
+ */
1368
+ setGridSize(e) {
1369
+ this.gridSize_ = e;
1370
+ }
1371
+ /**
1372
+ * Returns the min cluster size.
1373
+ *
1374
+ * @return {number} The grid size.
1375
+ */
1376
+ getMinClusterSize() {
1377
+ return this.minClusterSize_;
1378
+ }
1379
+ /**
1380
+ * Sets the min cluster size.
1381
+ *
1382
+ * @param {number} size The grid size.
1383
+ */
1384
+ setMinClusterSize(e) {
1385
+ this.minClusterSize_ = e;
1386
+ }
1387
+ /**
1388
+ * Extends a bounds object by the grid size.
1389
+ *
1390
+ * @param {google.maps.LatLngBounds} bounds The bounds to extend.
1391
+ * @return {google.maps.LatLngBounds} The extended bounds.
1392
+ */
1393
+ getExtendedBounds(e) {
1394
+ var t = this.getProjection(), r = new google.maps.LatLng(
1395
+ e.getNorthEast().lat(),
1396
+ e.getNorthEast().lng()
1397
+ ), s = new google.maps.LatLng(
1398
+ e.getSouthWest().lat(),
1399
+ e.getSouthWest().lng()
1400
+ ), o = t.fromLatLngToDivPixel(r);
1401
+ o.x += this.gridSize_, o.y -= this.gridSize_;
1402
+ var a = t.fromLatLngToDivPixel(s);
1403
+ a.x -= this.gridSize_, a.y += this.gridSize_;
1404
+ var g = t.fromDivPixelToLatLng(o), n = t.fromDivPixelToLatLng(a);
1405
+ return e.extend(g), e.extend(n), e;
1406
+ }
1407
+ /**
1408
+ * Determins if a marker is contained in a bounds.
1409
+ *
1410
+ * @param {google.maps.Marker} marker The marker to check.
1411
+ * @param {google.maps.LatLngBounds} bounds The bounds to check against.
1412
+ * @return {boolean} True if the marker is in the bounds.
1413
+ * @private
1414
+ */
1415
+ isMarkerInBounds_(e, t) {
1416
+ return t.contains(e.getPosition());
1417
+ }
1418
+ /**
1419
+ * Clears all clusters and markers from the clusterer.
1420
+ */
1421
+ clearMarkers() {
1422
+ this.resetViewport(!0), this.markers_ = [];
1423
+ }
1424
+ /**
1425
+ * Clears all existing clusters and recreates them.
1426
+ * @param {boolean} opt_hide To also hide the marker.
1427
+ */
1428
+ resetViewport(e) {
1429
+ for (let t = 0, r; r = this.clusters_[t]; t++)
1430
+ r.remove();
1431
+ for (let t = 0, r; r = this.markers_[t]; t++)
1432
+ r.isAdded = !1, e && r.setMap(null);
1433
+ this.clusters_ = [];
1434
+ }
1435
+ /**
1436
+ *
1437
+ */
1438
+ repaint() {
1439
+ var e = this.clusters_.slice();
1440
+ this.clusters_.length = 0, this.resetViewport(), this.redraw(), setTimeout(function() {
1441
+ for (var t = 0, r; r = e[t]; t++)
1442
+ r.remove();
1443
+ }, 0);
1444
+ }
1445
+ /**
1446
+ * Redraws the clusters.
1447
+ */
1448
+ redraw() {
1449
+ this.createClusters_();
1450
+ }
1451
+ /**
1452
+ * Calculates the distance between two latlng locations in km.
1453
+ * @see http://www.movable-type.co.uk/scripts/latlong.html
1454
+ *
1455
+ * @param {google.maps.LatLng} p1 The first lat lng point.
1456
+ * @param {google.maps.LatLng} p2 The second lat lng point.
1457
+ * @return {number} The distance between the two points in km.
1458
+ * @private
1459
+ */
1460
+ distanceBetweenPoints_(e, t) {
1461
+ if (!e || !t)
1462
+ return 0;
1463
+ var r = 6371, s = (t.lat() - e.lat()) * Math.PI / 180, o = (t.lng() - e.lng()) * Math.PI / 180, a = Math.sin(s / 2) * Math.sin(s / 2) + Math.cos(e.lat() * Math.PI / 180) * Math.cos(t.lat() * Math.PI / 180) * Math.sin(o / 2) * Math.sin(o / 2), g = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), n = r * g;
1464
+ return n;
1465
+ }
1466
+ /**
1467
+ * Add a marker to a cluster, or creates a new cluster.
1468
+ *
1469
+ * @param {google.maps.Marker} marker The marker to add.
1470
+ * @private
1471
+ */
1472
+ addToClosestCluster_(e) {
1473
+ for (var t = 4e4, r = null, s = 0, o; o = this.clusters_[s]; s++) {
1474
+ var a = o.getCenter();
1475
+ if (a) {
1476
+ var g = this.distanceBetweenPoints_(a, e.getPosition());
1477
+ g < t && (t = g, r = o);
1478
+ }
1479
+ }
1480
+ if (r && r.isMarkerInClusterBounds(e))
1481
+ r.addMarker(e);
1482
+ else {
1483
+ var n = new br(this);
1484
+ n.addMarker(e), this.clusters_.push(n);
1485
+ }
1486
+ }
1487
+ /**
1488
+ * Creates the clusters.
1489
+ *
1490
+ * @private
1491
+ */
1492
+ createClusters_() {
1493
+ if (this.ready_)
1494
+ for (var e = new google.maps.LatLngBounds(
1495
+ this.map_.getBounds().getSouthWest(),
1496
+ this.map_.getBounds().getNorthEast()
1497
+ ), t = this.getExtendedBounds(e), r = 0, s; s = this.markers_[r]; r++)
1498
+ !s.isAdded && this.isMarkerInBounds_(s, t) && this.addToClosestCluster_(s);
1499
+ }
1500
+ };
1501
+ class br {
1502
+ constructor(e) {
1503
+ this.markerClusterer_ = e, this.map_ = e.getMap(), this.gridSize_ = e.getGridSize(), this.minClusterSize_ = e.getMinClusterSize(), this.averageCenter_ = e.isAverageCenter(), this.center_ = null, this.markers_ = [], this.bounds_ = null, this.clusterIcon_ = new De(
1504
+ this,
1505
+ e.getStyles(),
1506
+ e.getGridSize()
1507
+ );
1508
+ }
1509
+ /**
1510
+ * Determins if a marker is already added to the cluster.
1511
+ *
1512
+ * @param {google.maps.Marker} marker The marker to check.
1513
+ * @return {boolean} True if the marker is already added.
1514
+ */
1515
+ isMarkerAlreadyAdded(e) {
1516
+ if (this.markers_.indexOf)
1517
+ return this.markers_.indexOf(e) != -1;
1518
+ for (var t = 0, r; r = this.markers_[t]; t++)
1519
+ if (r == e)
1520
+ return !0;
1521
+ return !1;
1522
+ }
1523
+ /**
1524
+ * Add a marker the cluster.
1525
+ *
1526
+ * @param {google.maps.Marker} marker The marker to add.
1527
+ * @return {boolean} True if the marker was added.
1528
+ */
1529
+ addMarker(e) {
1530
+ if (this.isMarkerAlreadyAdded(e))
1531
+ return !1;
1532
+ if (!this.center_)
1533
+ this.center_ = e.getPosition(), this.calculateBounds_();
1534
+ else if (this.averageCenter_) {
1535
+ var t = this.markers_.length + 1, r = (this.center_.lat() * (t - 1) + e.getPosition().lat()) / t, s = (this.center_.lng() * (t - 1) + e.getPosition().lng()) / t;
1536
+ this.center_ = new google.maps.LatLng(r, s), this.calculateBounds_();
1537
+ }
1538
+ e.isAdded = !0, this.markers_.push(e);
1539
+ var o = this.markers_.length;
1540
+ if (o < this.minClusterSize_ && e.getMap() != this.map_ && e.setMap(this.map_), o == this.minClusterSize_)
1541
+ for (var a = 0; a < o; a++)
1542
+ this.markers_[a].setMap(null);
1543
+ return o >= this.minClusterSize_ && e.setMap(null), this.updateIcon(), !0;
1544
+ }
1545
+ /**
1546
+ * Returns the marker clusterer that the cluster is associated with.
1547
+ *
1548
+ * @return {MarkerClusterer} The associated marker clusterer.
1549
+ */
1550
+ getMarkerClusterer() {
1551
+ return this.markerClusterer_;
1552
+ }
1553
+ /**
1554
+ * Returns the bounds of the cluster.
1555
+ *
1556
+ * @return {google.maps.LatLngBounds} the cluster bounds.
1557
+ */
1558
+ getBounds() {
1559
+ for (var e = new google.maps.LatLngBounds(this.center_, this.center_), t = this.getMarkers(), r = 0, s; s = t[r]; r++)
1560
+ e.extend(s.getPosition());
1561
+ return e;
1562
+ }
1563
+ /**
1564
+ * Removes the cluster
1565
+ */
1566
+ remove() {
1567
+ this.clusterIcon_.remove(), this.markers_.length = 0, delete this.markers_;
1568
+ }
1569
+ /**
1570
+ * Returns the number of markers in the cluster.
1571
+ *
1572
+ * @return {number} The number of markers in the cluster.
1573
+ */
1574
+ getSize() {
1575
+ return this.markers_.length;
1576
+ }
1577
+ /**
1578
+ * Returns a list of the markers in the cluster.
1579
+ *
1580
+ * @return {Array.<google.maps.Marker>} The markers in the cluster.
1581
+ */
1582
+ getMarkers() {
1583
+ return this.markers_;
1584
+ }
1585
+ /**
1586
+ * Returns the center of the cluster.
1587
+ *
1588
+ * @return {google.maps.LatLng} The cluster center.
1589
+ */
1590
+ getCenter() {
1591
+ return this.center_;
1592
+ }
1593
+ /**
1594
+ * Calculated the extended bounds of the cluster with the grid.
1595
+ *
1596
+ * @private
1597
+ */
1598
+ calculateBounds_() {
1599
+ var e = new google.maps.LatLngBounds(this.center_, this.center_);
1600
+ this.bounds_ = this.markerClusterer_.getExtendedBounds(e);
1601
+ }
1602
+ /**
1603
+ * Determines if a marker lies in the clusters bounds.
1604
+ *
1605
+ * @param {google.maps.Marker} marker The marker to check.
1606
+ * @return {boolean} True if the marker lies in the bounds.
1607
+ */
1608
+ isMarkerInClusterBounds(e) {
1609
+ return this.bounds_.contains(e.getPosition());
1610
+ }
1611
+ /**
1612
+ * Returns the map that the cluster is associated with.
1613
+ *
1614
+ * @return {google.maps.Map} The map.
1615
+ */
1616
+ getMap() {
1617
+ return this.map_;
1618
+ }
1619
+ /**
1620
+ * Updates the cluster icon
1621
+ */
1622
+ updateIcon() {
1623
+ var e = this.map_.getZoom(), t = this.markerClusterer_.getMaxZoom();
1624
+ if (t && e > t) {
1625
+ for (var r = 0, s; s = this.markers_[r]; r++)
1626
+ s.setMap(this.map_);
1627
+ return;
1628
+ }
1629
+ if (this.markers_.length < this.minClusterSize_) {
1630
+ this.clusterIcon_.hide();
1631
+ return;
1632
+ }
1633
+ var o = this.markerClusterer_.getStyles().length, a = this.markerClusterer_.getCalculator()(this.markers_, o);
1634
+ this.clusterIcon_.setCenter(this.center_), this.clusterIcon_.setSums(a), this.clusterIcon_.show();
1635
+ }
1636
+ }
1637
+ class De {
1638
+ constructor(e, t, r) {
1639
+ e.getMarkerClusterer().extend(De, google.maps.OverlayView), this.styles_ = t, this.padding_ = r || 0, this.cluster_ = e, this.center_ = null, this.map_ = e.getMap(), this.div_ = null, this.sums_ = null, this.visible_ = !1, this.setMap(this.map_);
1640
+ }
1641
+ /**
1642
+ * Triggers the clusterclick event and zoom's if the option is set.
1643
+ */
1644
+ triggerClusterClick() {
1645
+ var e = this.cluster_.getBounds(), t = this.cluster_.getMarkerClusterer();
1646
+ google.maps.event.trigger(
1647
+ t.map_,
1648
+ "clusterclick",
1649
+ this.cluster_
1650
+ ), t.isZoomOnClick() && (this.map_.fitBounds(e), this.map_.setCenter(e.getCenter()));
1651
+ }
1652
+ /**
1653
+ * Adding the cluster icon to the dom.
1654
+ * @ignore
1655
+ */
1656
+ onAdd() {
1657
+ if (this.div_ = document.createElement("DIV"), this.visible_) {
1658
+ var e = this.getPosFromLatLng_(this.center_);
1659
+ this.div_.style.cssText = this.createCss(e), this.div_.innerHTML = this.sums_.text;
1660
+ }
1661
+ var t = this.getPanes();
1662
+ t.overlayMouseTarget.appendChild(this.div_);
1663
+ var r = this;
1664
+ google.maps.event.addDomListener(this.div_, "click", function() {
1665
+ r.triggerClusterClick();
1666
+ });
1667
+ }
1668
+ /**
1669
+ * Returns the position to place the div dending on the latlng.
1670
+ *
1671
+ * @param {google.maps.LatLng} latlng The position in latlng.
1672
+ * @return {google.maps.Point} The position in pixels.
1673
+ * @private
1674
+ */
1675
+ getPosFromLatLng_(e) {
1676
+ var t = this.getProjection().fromLatLngToDivPixel(e);
1677
+ return t.x -= parseInt(this.width_ / 2, 10), t.y -= parseInt(this.height_ / 2, 10), t;
1678
+ }
1679
+ /**
1680
+ * Draw the icon.
1681
+ * @ignore
1682
+ */
1683
+ draw() {
1684
+ if (this.visible_) {
1685
+ var e = this.getPosFromLatLng_(this.center_);
1686
+ this.div_.style.top = e.y + "px", this.div_.style.left = e.x + "px";
1687
+ }
1688
+ }
1689
+ /**
1690
+ * Hide the icon.
1691
+ */
1692
+ hide() {
1693
+ this.div_ && (this.div_.style.display = "none"), this.visible_ = !1;
1694
+ }
1695
+ /**
1696
+ * Position and show the icon.
1697
+ */
1698
+ show() {
1699
+ if (this.div_) {
1700
+ var e = this.getPosFromLatLng_(this.center_);
1701
+ this.div_.style.cssText = this.createCss(e), this.div_.style.display = "";
1702
+ }
1703
+ this.visible_ = !0;
1704
+ }
1705
+ /**
1706
+ * Remove the icon from the map
1707
+ */
1708
+ remove() {
1709
+ this.setMap(null);
1710
+ }
1711
+ /**
1712
+ * Implementation of the onRemove interface.
1713
+ * @ignore
1714
+ */
1715
+ onRemove() {
1716
+ this.div_ && this.div_.parentNode && (this.hide(), this.div_.parentNode.removeChild(this.div_), this.div_ = null);
1717
+ }
1718
+ /**
1719
+ * Set the sums of the icon.
1720
+ *
1721
+ * @param {Object} sums The sums containing:
1722
+ * 'text': (string) The text to display in the icon.
1723
+ * 'index': (number) The style index of the icon.
1724
+ */
1725
+ setSums(e) {
1726
+ this.sums_ = e, this.text_ = e.text, this.index_ = e.index, this.div_ && (this.div_.innerHTML = e.text), this.useStyle();
1727
+ }
1728
+ /**
1729
+ * Sets the icon to the the styles.
1730
+ */
1731
+ useStyle() {
1732
+ var e = Math.max(0, this.sums_.index - 1);
1733
+ e = Math.min(this.styles_.length - 1, e);
1734
+ var t = this.styles_[e];
1735
+ this.url_ = t.url, this.height_ = t.height, this.width_ = t.width, this.textColor_ = t.textColor, this.anchor_ = t.anchor, this.textSize_ = t.textSize, this.backgroundPosition_ = t.backgroundPosition;
1736
+ }
1737
+ /**
1738
+ * Sets the center of the icon.
1739
+ *
1740
+ * @param {google.maps.LatLng} center The latlng to set as the center.
1741
+ */
1742
+ setCenter(e) {
1743
+ this.center_ = e;
1744
+ }
1745
+ /**
1746
+ * Create the css text based on the position of the icon.
1747
+ *
1748
+ * @param {google.maps.Point} pos The position.
1749
+ * @return {string} The css style text.
1750
+ */
1751
+ createCss(e) {
1752
+ var t = [];
1753
+ t.push("z-index:" + this.cluster_.markerClusterer_.getZIndex() + ";"), t.push("background-image:url(" + this.url_ + ");");
1754
+ var r = this.backgroundPosition_ ? this.backgroundPosition_ : "0 0";
1755
+ t.push("background-position:" + r + ";"), typeof this.anchor_ == "object" ? (typeof this.anchor_[0] == "number" && this.anchor_[0] > 0 && this.anchor_[0] < this.height_ ? t.push(
1756
+ "height:" + (this.height_ - this.anchor_[0]) + "px; padding-top:" + this.anchor_[0] + "px;"
1757
+ ) : t.push(
1758
+ "height:" + this.height_ + "px; line-height:" + this.height_ + "px;"
1759
+ ), typeof this.anchor_[1] == "number" && this.anchor_[1] > 0 && this.anchor_[1] < this.width_ ? t.push(
1760
+ "width:" + (this.width_ - this.anchor_[1]) + "px; padding-left:" + this.anchor_[1] + "px;"
1761
+ ) : t.push("width:" + this.width_ + "px; text-align:center;")) : t.push(
1762
+ "height:" + this.height_ + "px; line-height:" + this.height_ + "px; width:" + this.width_ + "px; text-align:center;"
1763
+ );
1764
+ var s = this.textColor_ ? this.textColor_ : "black", o = this.textSize_ ? this.textSize_ : 11;
1765
+ return t.push(
1766
+ "cursor:pointer; top:" + e.y + "px; left:" + e.x + "px; color:" + s + "; position:absolute; font-size:" + o + "px; font-family:Arial,sans-serif; font-weight:bold"
1767
+ ), t.join("");
1768
+ }
1769
+ }
1770
+ var ve;
1771
+ ((i) => {
1772
+ function e(r) {
1773
+ return {
1774
+ url: r.url,
1775
+ size: new BMap.Size(r.size.width, r.size.height),
1776
+ anchor: r.anchor && new BMap.Size(r.anchor.x, r.anchor.y),
1777
+ offset: r.offset && new BMap.Size(r.offset.x, r.offset.y),
1778
+ textColor: r.textColor,
1779
+ textSize: r.textSize
1780
+ };
1781
+ }
1782
+ i.toBaidu = e;
1783
+ function t(r) {
1784
+ return {
1785
+ url: r.url,
1786
+ width: r.size.width,
1787
+ height: r.size.height,
1788
+ anchor: r.anchor && [r.anchor.y, r.anchor.x],
1789
+ backgroundPosition: r.offset && `${r.offset.x} ${r.offset.y}`,
1790
+ textColor: r.textColor,
1791
+ textSize: r.textSize
1792
+ };
1793
+ }
1794
+ i.toGoogle = t;
1795
+ })(ve || (ve = {}));
1796
+ class kt {
1797
+ constructor(e) {
1798
+ h(this, "inner");
1799
+ this.map = e;
1800
+ }
1801
+ /** baidu/google 拥有相同的函数名 */
1802
+ clearMarkers() {
1803
+ this.inner.clearMarkers();
1804
+ }
1805
+ /** @see clearMarkers */
1806
+ addMarker(e) {
1807
+ this.inner.addMarker(e.innerOverlay);
1808
+ }
1809
+ /** @see clearMarkers */
1810
+ removeMarker(e) {
1811
+ return this.inner.removeMarker(e.innerOverlay);
1812
+ }
1813
+ /** @see clearMarkers */
1814
+ addMarkers(e) {
1815
+ this.inner.addMarkers(e.map((t) => t.innerOverlay));
1816
+ }
1817
+ /** @see clearMarkers */
1818
+ removeMarkers(e) {
1819
+ return this.inner.removeMarkers(e.map((t) => t.innerOverlay));
1820
+ }
1821
+ }
1822
+ class Tr extends kt {
1823
+ constructor(e, t) {
1824
+ var s;
1825
+ super(e), this.inner = new _(e.innerMap, {
1826
+ // baidu的构造器中的markers, 会触发重绘, 会导致使用旧的calculator计算cluster
1827
+ // markers: options.markers?.map(it => (it as BaiduMarker).innerOverlay),
1828
+ gridSize: t.gridSize,
1829
+ maxZoom: t.maxZoom,
1830
+ minClusterSize: t.minClusterSize,
1831
+ isAverageCenter: t.averageCenter,
1832
+ styles: (s = t.styles) == null ? void 0 : s.map((o) => ve.toBaidu(o)),
1833
+ zIndex: t.zIndex
1834
+ });
1835
+ const r = t.stylesIndexCalculator;
1836
+ r && this.inner.setStylesIndexCalculator((o, a) => r(o.length, a)), t.markers && this.addMarkers(t.markers);
1837
+ }
1838
+ recreate() {
1839
+ this.inner._redraw();
1840
+ }
1841
+ }
1842
+ class Or extends kt {
1843
+ constructor(e, t) {
1844
+ var s, o;
1845
+ super(e), this.inner = new Mr(
1846
+ e.innerMap,
1847
+ // google的构造器中的markers,不会触发重绘, 第一次绘制通过监听地图的'idle'事件触发, 可以直接设置
1848
+ (s = t.markers) == null ? void 0 : s.map((a) => a.innerOverlay),
1849
+ {
1850
+ gridSize: t.gridSize,
1851
+ maxZoom: t.maxZoom,
1852
+ minimumClusterSize: t.minClusterSize,
1853
+ averageCenter: t.averageCenter,
1854
+ styles: (o = t.styles) == null ? void 0 : o.map((a) => ve.toGoogle(a)),
1855
+ zIndex: t.zIndex
1856
+ }
1857
+ );
1858
+ const r = t.stylesIndexCalculator;
1859
+ r && this.inner.setCalculator((a, g) => ({
1860
+ text: a.length,
1861
+ // google内部, 取index时, 会`-1`...故我们这里`+1`, 抵消掉它
1862
+ index: r(a.length, g) + 1
1863
+ }));
1864
+ }
1865
+ recreate() {
1866
+ this.inner.repaint();
1867
+ }
1868
+ }
1869
+ function R(i, e) {
1870
+ Object.keys(this.$listeners).forEach((t) => {
1871
+ t.startsWith("update:") || e != null && e.includes(t) || i.addEventListener(t, this.$listeners[t]);
1872
+ });
1873
+ }
1874
+ let Cr = 1;
1875
+ function wr() {
1876
+ return Cr++;
1877
+ }
1878
+ function _e(i, e) {
1879
+ return e.__id__ || (e.__id__ = wr()), `${i}::${e.__id__}`;
1880
+ }
1881
+ var Se;
1882
+ ((i) => {
1883
+ function e(r, s) {
1884
+ const o = r.indexOf(s);
1885
+ if (o !== -1)
1886
+ return r.splice(o, 1)[0];
1887
+ }
1888
+ i.remove = e;
1889
+ function t(r, s) {
1890
+ for (const o of r)
1891
+ if (o instanceof s)
1892
+ return o;
1893
+ }
1894
+ i.findByType = t;
1895
+ })(Se || (Se = {}));
1896
+ var Me;
1897
+ ((i) => {
1898
+ function e(r, s) {
1899
+ const o = r.getLength();
1900
+ for (let a = 0; a < o; a++)
1901
+ if (r.getAt(a) === s)
1902
+ return a;
1903
+ return -1;
1904
+ }
1905
+ i.indexOf = e;
1906
+ function t(r, s) {
1907
+ const o = e(r, s);
1908
+ if (o !== -1)
1909
+ return r.removeAt(o);
1910
+ }
1911
+ i.remove = t;
1912
+ })(Me || (Me = {}));
1913
+ class It {
1914
+ constructor(e, t) {
1915
+ h(this, "eventMap", /* @__PURE__ */ new Map());
1916
+ h(this, "target", void 0);
1917
+ this.inner = e, this.coordTypeSupplier = t, this.addEventListener = this.addEventListener.bind(this), this.removeEventListener = this.removeEventListener.bind(this);
1918
+ }
1919
+ setTarget(e) {
1920
+ return this.target = e, this;
1921
+ }
1922
+ }
1923
+ const ct = class extends It {
1924
+ addEventListener(e, t) {
1925
+ const r = _e(e, t);
1926
+ if (this.eventMap.get(r)) {
1927
+ console.warn("listener已经添加过了", r, t);
1928
+ return;
1929
+ }
1930
+ const s = this.inner.addListener(ct.EVENT_TYPE_MAP[e] || e, (o) => {
1931
+ const a = {
1932
+ type: e,
1933
+ target: this.target,
1934
+ originalEvent: o
1935
+ };
1936
+ o != null && o.latLng && (a.position = y.fromGoogle(o.latLng, this.coordTypeSupplier.coordType)), t.call(this.target, a);
1937
+ });
1938
+ this.eventMap.set(r, s);
1939
+ }
1940
+ removeEventListener(e, t) {
1941
+ const r = _e(e, t), s = this.eventMap.get(r);
1942
+ s ? (s.remove(), this.eventMap.delete(r)) : console.warn("移除失败, 不存在该listener", r, t);
1943
+ }
1944
+ };
1945
+ let K = ct;
1946
+ // 事件类型映射: tg => google
1947
+ h(K, "EVENT_TYPE_MAP", {
1948
+ "center-changed": "center_changed",
1949
+ "zoom-changed": "zoom_changed",
1950
+ "map-type-changed": "maptypeid_changed",
1951
+ // TODO: google地图的overlay会拦截地图的事件, 导致在map上设置的监听缺少一部分事件, 或许和事件监听的机制有关?
1952
+ // 目前只能同时在map和overlay上监听这些事件...
1953
+ "map-mousedown": "mousedown",
1954
+ "map-mousemove": "mousemove",
1955
+ "map-mouseup": "mouseup",
1956
+ "map-dblclick": "dblclick"
1957
+ });
1958
+ const Te = class extends It {
1959
+ addEventListener(e, t) {
1960
+ const r = _e(e, t);
1961
+ if (this.eventMap.get(r)) {
1962
+ console.warn("listener已经添加过了", r, t);
1963
+ return;
1964
+ }
1965
+ const s = (o) => {
1966
+ const a = {
1967
+ type: e,
1968
+ target: this.target,
1969
+ originalEvent: o
1970
+ };
1971
+ o.point && (a.position = y.fromBaidu(o.point, this.coordTypeSupplier.coordType)), t.call(this.target, a);
1972
+ };
1973
+ this.inner.addEventListener(Te.EVENT_TYPE_MAP[e] || e, s), this.eventMap.set(r, s);
1974
+ }
1975
+ removeEventListener(e, t) {
1976
+ const r = _e(e, t), s = this.eventMap.get(r);
1977
+ s ? (this.inner.removeEventListener(Te.EVENT_TYPE_MAP[e] || e, s), this.eventMap.delete(r)) : console.warn("移除失败, 不存在该listener", r, t);
1978
+ }
1979
+ };
1980
+ let J = Te;
1981
+ // cSpell:words clickclose
1982
+ // 事件类型映射, tg => baidu
1983
+ h(J, "EVENT_TYPE_MAP", {
1984
+ drag: "dragging",
1985
+ closeclick: "clickclose",
1986
+ "zoom-changed": "zoomend",
1987
+ "map-type-changed": "maptypechange"
1988
+ });
1989
+ class xr {
1990
+ constructor() {
1991
+ h(this, "typeMap", /* @__PURE__ */ new Map());
1992
+ }
1993
+ addEventListener(e, t) {
1994
+ let r = this.typeMap.get(e);
1995
+ r || (r = [], this.typeMap.set(e, r)), !r.includes(t) && r.push(t);
1996
+ }
1997
+ removeEventListener(e, t) {
1998
+ const r = this.typeMap.get(e);
1999
+ r && Se.remove(r, t);
2000
+ }
2001
+ hasListener(e) {
2002
+ const t = this.typeMap.get(e);
2003
+ return t != null && t.length > 0;
2004
+ }
2005
+ notify(e) {
2006
+ const t = this.typeMap.get(e.type);
2007
+ t && t.forEach((r) => r.call(e.target, e));
2008
+ }
2009
+ }
2010
+ class Pt {
2011
+ constructor(e, t, r, s) {
2012
+ h(this, "addEventListener");
2013
+ h(this, "removeEventListener");
2014
+ this.innerOverlay = e, this.coordType = t, this.map = r, this.delegate = s, this.delegate.setTarget(this), this.addEventListener = this.delegate.addEventListener, this.removeEventListener = this.delegate.removeEventListener;
2015
+ }
2016
+ remove() {
2017
+ this.map.removeOverlay(this);
2018
+ }
2019
+ }
2020
+ class Ze extends Pt {
2021
+ constructor(e, t, r) {
2022
+ super(e, t, r, new K(e, r));
2023
+ }
2024
+ isVisible() {
2025
+ return this.innerOverlay.getVisible();
2026
+ }
2027
+ setVisible(e) {
2028
+ this.innerOverlay.setVisible(e);
2029
+ }
2030
+ }
2031
+ class Oe extends Pt {
2032
+ constructor(e, t, r) {
2033
+ super(e, t, r, new J(e, r));
2034
+ }
2035
+ /** 仅限内部使用; 设为private时, 生成的d.ts文件中, 方法返回值会变成any, 故改成了public */
2036
+ get overlay() {
2037
+ return this.innerOverlay;
2038
+ }
2039
+ isVisible() {
2040
+ return this.overlay.isVisible();
2041
+ }
2042
+ setVisible(e) {
2043
+ e ? this.overlay.show() : this.overlay.hide();
2044
+ }
2045
+ /** 在创建BaiduOverlay时, 设置options.visible, 仅内部使用 */
2046
+ visibleOptionInternal(e) {
2047
+ return e !== void 0 && (e || this.setVisible(!1)), this;
2048
+ }
2049
+ }
2050
+ class Ge extends Oe {
2051
+ constructor(e, t, r, s) {
2052
+ super(e, t, r), this.state = s;
2053
+ }
2054
+ isEditable() {
2055
+ return this.state.editable;
2056
+ }
2057
+ setEditable(e) {
2058
+ this.state.editable = e, e ? this.innerOverlay.enableEditing() : this.innerOverlay.disableEditing();
2059
+ }
2060
+ setStrokeColor(e) {
2061
+ this.innerOverlay.setStrokeColor(e);
2062
+ }
2063
+ setStrokeOpacity(e) {
2064
+ this.innerOverlay.setStrokeOpacity(e);
2065
+ }
2066
+ setStrokeWeight(e) {
2067
+ this.innerOverlay.setStrokeWeight(e);
2068
+ }
2069
+ setFillColor(e) {
2070
+ this.innerOverlay.setFillColor(e);
2071
+ }
2072
+ setFillOpacity(e) {
2073
+ this.innerOverlay.setFillOpacity(e);
2074
+ }
2075
+ }
2076
+ class je extends Ze {
2077
+ isEditable() {
2078
+ return this.innerOverlay.getEditable();
2079
+ }
2080
+ setEditable(e) {
2081
+ this.innerOverlay.setEditable(e);
2082
+ }
2083
+ setStrokeColor(e) {
2084
+ this.innerOverlay.setOptions({ strokeColor: e });
2085
+ }
2086
+ setStrokeOpacity(e) {
2087
+ this.innerOverlay.setOptions({ strokeOpacity: e });
2088
+ }
2089
+ setStrokeWeight(e) {
2090
+ this.innerOverlay.setOptions({ strokeWeight: e });
2091
+ }
2092
+ setFillColor(e) {
2093
+ this.innerOverlay.setOptions({ fillColor: e });
2094
+ }
2095
+ setFillOpacity(e) {
2096
+ this.innerOverlay.setOptions({ fillOpacity: e });
2097
+ }
2098
+ }
2099
+ class We extends Ge {
2100
+ static create(e) {
2101
+ const t = this.coordType, r = new BMap.Polyline(e.path.map((s) => s.toBaidu(t)), {
2102
+ enableClicking: e.clickable,
2103
+ enableEditing: e.editable,
2104
+ strokeColor: e.strokeColor,
2105
+ strokeOpacity: e.strokeOpacity,
2106
+ strokeWeight: e.strokeWeight
2107
+ });
2108
+ return new We(r, t, this, { editable: e.editable === !0 }).visibleOptionInternal(e.visible);
2109
+ }
2110
+ getPath() {
2111
+ return this.innerOverlay.getPath().map((e) => y.fromBaidu(e, this.coordType));
2112
+ }
2113
+ setPath(e) {
2114
+ this.coordType = this.map.coordType, this.innerOverlay.setPath(e.map((t) => t.toBaidu(this.coordType)));
2115
+ }
2116
+ }
2117
+ class Ve extends je {
2118
+ static create(e) {
2119
+ const t = this.coordType, r = new google.maps.Polyline({
2120
+ path: e.path.map((s) => s.toGoogle(t)),
2121
+ clickable: e.clickable,
2122
+ editable: e.editable,
2123
+ strokeColor: e.strokeColor,
2124
+ strokeOpacity: e.strokeOpacity,
2125
+ strokeWeight: e.strokeWeight,
2126
+ visible: e.visible
2127
+ });
2128
+ return new Ve(r, t, this);
2129
+ }
2130
+ getPath() {
2131
+ const e = [];
2132
+ return this.innerOverlay.getPath().forEach((t) => {
2133
+ e.push(y.fromGoogle(t, this.coordType));
2134
+ }), e;
2135
+ }
2136
+ setPath(e) {
2137
+ this.coordType = this.map.coordType, this.innerOverlay.setPath(e.map((t) => t.toGoogle(this.coordType)));
2138
+ }
2139
+ }
2140
+ class He extends Ge {
2141
+ static create(e) {
2142
+ const t = this.coordType;
2143
+ e.paths.length > 1 && console.warn("baidu不支持多path, 只会显示paths[0]");
2144
+ const r = e.paths[0] || [], s = new BMap.Polygon(r.map((o) => o.toBaidu(t)), {
2145
+ enableClicking: e.clickable,
2146
+ enableEditing: e.editable,
2147
+ strokeColor: e.strokeColor,
2148
+ strokeOpacity: e.strokeOpacity,
2149
+ strokeWeight: e.strokeWeight,
2150
+ fillColor: e.fillColor,
2151
+ fillOpacity: e.fillOpacity
2152
+ });
2153
+ return new He(s, t, this, { editable: !!e.editable }).visibleOptionInternal(e.visible);
2154
+ }
2155
+ getPaths() {
2156
+ return [this.innerOverlay.getPath().map((e) => y.fromBaidu(e, this.coordType))];
2157
+ }
2158
+ setPaths(e) {
2159
+ e.length > 1 && console.warn("baidu不支持多path, 只会显示paths[0]"), this.coordType = this.map.coordType, this.innerOverlay.setPath((e[0] || []).map((t) => t.toBaidu(this.coordType)));
2160
+ }
2161
+ }
2162
+ class Fe extends je {
2163
+ static create(e) {
2164
+ const t = this.coordType, r = new google.maps.Polygon({
2165
+ paths: e.paths.map((s) => s.map((o) => o.toGoogle(t))),
2166
+ clickable: e.clickable,
2167
+ editable: e.editable,
2168
+ strokeColor: e.strokeColor,
2169
+ strokeOpacity: e.strokeOpacity,
2170
+ strokeWeight: e.strokeWeight,
2171
+ fillColor: e.fillColor,
2172
+ fillOpacity: e.fillOpacity,
2173
+ visible: e.visible
2174
+ });
2175
+ return new Fe(r, t, this);
2176
+ }
2177
+ getPaths() {
2178
+ const e = this.innerOverlay.getPaths(), t = [];
2179
+ return e.forEach((r) => {
2180
+ const s = [];
2181
+ t.push(s), r.forEach((o) => {
2182
+ s.push(y.fromGoogle(o, this.coordType));
2183
+ });
2184
+ }), t;
2185
+ }
2186
+ setPaths(e) {
2187
+ this.coordType = this.map.coordType, this.innerOverlay.setPaths(e.map((t) => t.map((r) => r.toGoogle(this.coordType))));
2188
+ }
2189
+ }
2190
+ class Ue extends Ge {
2191
+ static create(e) {
2192
+ const t = this.coordType, r = new BMap.Circle(e.center.toBaidu(t), e.radius, {
2193
+ enableClicking: e.clickable,
2194
+ enableEditing: e.editable,
2195
+ strokeColor: e.strokeColor,
2196
+ strokeOpacity: e.strokeOpacity,
2197
+ strokeWeight: e.strokeWeight,
2198
+ fillColor: e.fillColor,
2199
+ fillOpacity: e.fillOpacity
2200
+ });
2201
+ return new Ue(r, t, this, { editable: !!e.editable }).visibleOptionInternal(e.visible);
2202
+ }
2203
+ setCenter(e) {
2204
+ this.coordType = this.map.coordType, this.innerOverlay.setCenter(e.toBaidu(this.coordType));
2205
+ }
2206
+ getCenter() {
2207
+ return y.fromBaidu(this.innerOverlay.getCenter(), this.coordType);
2208
+ }
2209
+ setRadius(e) {
2210
+ this.innerOverlay.setRadius(e);
2211
+ }
2212
+ getRadius() {
2213
+ return this.innerOverlay.getRadius();
2214
+ }
2215
+ }
2216
+ class Ye extends je {
2217
+ static create(e) {
2218
+ const t = this.coordType, r = new google.maps.Circle({
2219
+ center: e.center.toGoogle(t),
2220
+ radius: e.radius,
2221
+ clickable: e.clickable,
2222
+ editable: e.editable,
2223
+ strokeColor: e.strokeColor,
2224
+ strokeOpacity: e.strokeOpacity,
2225
+ strokeWeight: e.strokeWeight,
2226
+ fillColor: e.fillColor,
2227
+ fillOpacity: e.fillOpacity,
2228
+ visible: e.visible
2229
+ });
2230
+ return new Ye(r, t, this);
2231
+ }
2232
+ setCenter(e) {
2233
+ this.coordType = this.map.coordType, this.innerOverlay.setCenter(e.toGoogle(this.coordType));
2234
+ }
2235
+ getCenter() {
2236
+ return y.fromGoogle(this.innerOverlay.getCenter(), this.coordType);
2237
+ }
2238
+ setRadius(e) {
2239
+ this.innerOverlay.setRadius(e);
2240
+ }
2241
+ getRadius() {
2242
+ return this.innerOverlay.getRadius();
2243
+ }
2244
+ }
2245
+ class ft {
2246
+ /**
2247
+ * `keys`和`values`数组中可以有相同的值, 若存在相同值, 则index越小的优先级越高
2248
+ */
2249
+ constructor(e, t) {
2250
+ h(this, "keyToValue", /* @__PURE__ */ new Map());
2251
+ h(this, "valueToKey", /* @__PURE__ */ new Map());
2252
+ ne(e.length === t.length);
2253
+ for (let r = e.length - 1; r >= 0; r--)
2254
+ this.keyToValue.set(e[r], t[r]), this.valueToKey.set(t[r], e[r]);
2255
+ }
2256
+ toKey(e) {
2257
+ return this.valueToKey.get(e) ?? I();
2258
+ }
2259
+ toValue(e) {
2260
+ return this.keyToValue.get(e) ?? I();
2261
+ }
2262
+ }
2263
+ class Er {
2264
+ constructor(e, t = 10) {
2265
+ h(this, "map", /* @__PURE__ */ new Map());
2266
+ this.values = e, this.maxSize4Debug = t;
2267
+ }
2268
+ /** 获取保存key-value映射的Map */
2269
+ getValueMap(e) {
2270
+ let t = this.map.get(e);
2271
+ if (!t) {
2272
+ t = /* @__PURE__ */ new Map();
2273
+ for (let r = this.values.length - 1; r >= 0; r--) {
2274
+ const s = this.values[r];
2275
+ t.set(e.call(s), s);
2276
+ }
2277
+ this.map.set(e, t), {}.NODE_ENV !== "production" && this.map.size > this.maxSize4Debug && console.warn(`this.map的大小(${this.map.size})超过了设置的最大大小(${this.maxSize4Debug}), 这可能是由于你每次都创建新的keySelector造成的, 请保证相同功能的keySelector只创建一个对象`);
2278
+ }
2279
+ return t;
2280
+ }
2281
+ /**
2282
+ * 直接用key获取value
2283
+ * @param keySelector 从T中读取key的方法, 会用它当key, 缓存结果, 故多次调用需要使用相同的keySelector对象, 不要每次创建新的, 推荐直接使用T.prototype.getXxx作为keySelector
2284
+ */
2285
+ getOrNull(e, t) {
2286
+ return this.getValueMap(e).get(t);
2287
+ }
2288
+ get(e, t) {
2289
+ return this.getOrNull(e, t) ?? I(`key(${t})不存在与valueMap(${this.getValueMap(e)})中`);
2290
+ }
2291
+ }
2292
+ class yt {
2293
+ constructor(e) {
2294
+ h(this, "value");
2295
+ this.creator = e;
2296
+ }
2297
+ get() {
2298
+ return this.value === void 0 && (this.value = this.creator()), this.value;
2299
+ }
2300
+ }
2301
+ var x = /* @__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))(x || {}), P;
2302
+ ((i) => {
2303
+ let e, t;
2304
+ const r = [
2305
+ "top-left",
2306
+ "top-center",
2307
+ "top-right",
2308
+ "bottom-left",
2309
+ "bottom-center",
2310
+ "bottom-right",
2311
+ "left-top",
2312
+ "left-center",
2313
+ "left-bottom",
2314
+ "right-top",
2315
+ "right-center",
2316
+ "right-bottom"
2317
+ /* RIGHT_BOTTOM */
2318
+ ];
2319
+ function s() {
2320
+ return e || (e = new ft(r, [
2321
+ /* | @tg/map |名字相同| baidu | */
2322
+ /* TOP_LEFT = */
2323
+ BMAP_ANCHOR_TOP_LEFT,
2324
+ /* TOP_CENTER */
2325
+ BMAP_ANCHOR_TOP_LEFT,
2326
+ /* TOP_RIGHT = */
2327
+ BMAP_ANCHOR_TOP_RIGHT,
2328
+ /* BOTTOM_LEFT = */
2329
+ BMAP_ANCHOR_BOTTOM_LEFT,
2330
+ /* BOTTOM_CENTER */
2331
+ BMAP_ANCHOR_BOTTOM_LEFT,
2332
+ /* BOTTOM_RIGHT = */
2333
+ BMAP_ANCHOR_BOTTOM_RIGHT,
2334
+ /* LEFT_TOP */
2335
+ BMAP_ANCHOR_TOP_LEFT,
2336
+ /* LEFT_CENTER */
2337
+ BMAP_ANCHOR_BOTTOM_LEFT,
2338
+ /* LEFT_BOTTOM */
2339
+ BMAP_ANCHOR_BOTTOM_LEFT,
2340
+ /* RIGHT_TOP */
2341
+ BMAP_ANCHOR_TOP_RIGHT,
2342
+ /* RIGHT_CENTER */
2343
+ BMAP_ANCHOR_BOTTOM_RIGHT,
2344
+ /* RIGHT_BOTTOM */
2345
+ BMAP_ANCHOR_BOTTOM_RIGHT
2346
+ ])), e;
2347
+ }
2348
+ i.getBaidu = s;
2349
+ function o() {
2350
+ return t || (t = new ft(r, [
2351
+ google.maps.ControlPosition.TOP_LEFT,
2352
+ google.maps.ControlPosition.TOP_CENTER,
2353
+ google.maps.ControlPosition.TOP_RIGHT,
2354
+ google.maps.ControlPosition.BOTTOM_LEFT,
2355
+ google.maps.ControlPosition.BOTTOM_CENTER,
2356
+ google.maps.ControlPosition.BOTTOM_RIGHT,
2357
+ google.maps.ControlPosition.LEFT_TOP,
2358
+ google.maps.ControlPosition.LEFT_CENTER,
2359
+ google.maps.ControlPosition.LEFT_BOTTOM,
2360
+ google.maps.ControlPosition.RIGHT_TOP,
2361
+ google.maps.ControlPosition.RIGHT_CENTER,
2362
+ google.maps.ControlPosition.RIGHT_BOTTOM
2363
+ ])), t;
2364
+ }
2365
+ i.getGoogle = o;
2366
+ })(P || (P = {}));
2367
+ class kr {
2368
+ constructor(e) {
2369
+ /** 实际添加到地图中的control对象 */
2370
+ h(this, "inner");
2371
+ this.position = e;
2372
+ }
2373
+ }
2374
+ class Lt {
2375
+ }
2376
+ class Ke extends Lt {
2377
+ constructor(e, t) {
2378
+ super(), this.inner = e, this.position = t;
2379
+ }
2380
+ isVisible() {
2381
+ return this.inner.isVisible();
2382
+ }
2383
+ setVisible(e) {
2384
+ e ? this.inner.show() : this.inner.hide();
2385
+ }
2386
+ getPosition() {
2387
+ return this.position ?? P.getBaidu().toKey(this.inner.getAnchor());
2388
+ }
2389
+ setPosition(e) {
2390
+ this.position = e, this.inner.setAnchor(P.getBaidu().toValue(e));
2391
+ }
2392
+ addTo(e) {
2393
+ e.innerMap.addControl(this.inner);
2394
+ }
2395
+ removeFrom(e) {
2396
+ e.innerMap.removeControl(this.inner);
2397
+ }
2398
+ }
2399
+ class qe extends Lt {
2400
+ constructor(t, r) {
2401
+ super();
2402
+ h(this, "visible", !1);
2403
+ h(this, "map");
2404
+ this._type = t, this.position = r;
2405
+ }
2406
+ isVisible() {
2407
+ return this.visible;
2408
+ }
2409
+ setVisible(t) {
2410
+ this.visible = t, this.tryUpdateOptions();
2411
+ }
2412
+ getPosition() {
2413
+ return this.position;
2414
+ }
2415
+ setPosition(t) {
2416
+ this.position = t, this.tryUpdateOptions();
2417
+ }
2418
+ addTo(t) {
2419
+ this.map || (this.map = t, this.setVisible(!0));
2420
+ }
2421
+ removeFrom() {
2422
+ this.map && (this.setVisible(!1), this.map = void 0);
2423
+ }
2424
+ onCreateOptions() {
2425
+ return {
2426
+ position: P.getGoogle().toValue(this.position)
2427
+ };
2428
+ }
2429
+ tryUpdateOptions() {
2430
+ this.map && this.map.innerMap.setOptions({
2431
+ [`${this._type}Control`]: this.visible,
2432
+ [`${this._type}ControlOptions`]: this.onCreateOptions()
2433
+ });
2434
+ }
2435
+ }
2436
+ var $e = /* @__PURE__ */ ((i) => (i.normal = "normal", i.satellite = "satellite", i.hybrid = "hybrid", i))($e || {});
2437
+ class E {
2438
+ constructor(e, t, r, s) {
2439
+ this.id = e, this.baidu = t, this.google = r, this.googleCoordType = s;
2440
+ }
2441
+ getId() {
2442
+ return this.id;
2443
+ }
2444
+ getBaiduCoordType() {
2445
+ return Y.bd09;
2446
+ }
2447
+ asBaiduMapType() {
2448
+ return this.baidu();
2449
+ }
2450
+ getGoogleCoordType() {
2451
+ return this.googleCoordType;
2452
+ }
2453
+ /** 内置地图的id和google的id是不一样的 */
2454
+ getGoogleMapTypeId() {
2455
+ return this.google();
2456
+ }
2457
+ asGoogleMapType() {
2458
+ Jt("google的内置地图没有对应的实例");
2459
+ }
2460
+ }
2461
+ class Ir {
2462
+ constructor() {
2463
+ h(this, "baiduCache", new yt(() => new BMap.TrafficLayer()));
2464
+ h(this, "googleCache", new yt(() => new google.maps.TrafficLayer()));
2465
+ }
2466
+ asBaiduLayer() {
2467
+ return this.baiduCache.get();
2468
+ }
2469
+ asGoogleLayer() {
2470
+ return this.googleCache.get();
2471
+ }
2472
+ }
2473
+ var k;
2474
+ ((i) => {
2475
+ i.NORMAL = new E("normal", () => BMAP_NORMAL_MAP, () => google.maps.MapTypeId.ROADMAP, Y.gcj02), i.SATELLITE = new E("satellite", () => BMAP_SATELLITE_MAP, () => google.maps.MapTypeId.SATELLITE, Y.wgs84), i.HYBRID = new E("hybrid", () => BMAP_HYBRID_MAP, () => google.maps.MapTypeId.HYBRID, Y.gcj02), i.TERRAIN = new E("terrain", () => (
2476
+ /* 三维 */
2477
+ BMAP_PERSPECTIVE_MAP
2478
+ ), () => (
2479
+ /* 地形 */
2480
+ google.maps.MapTypeId.TERRAIN
2481
+ ), Y.wgs84), i.BUILD_IN_MAP_TYPES = new Er([i.NORMAL, i.SATELLITE, i.HYBRID, i.TERRAIN]);
2482
+ })(k || (k = {}));
2483
+ var Bt = /* @__PURE__ */ ((i) => (i.DEFAULT = "default", i.HORIZONTAL = "horizontal", i.DROPDOWN = "dropdown", i))(Bt || {});
2484
+ const St = [k.NORMAL, k.SATELLITE, k.HYBRID];
2485
+ class Xe extends Ke {
2486
+ static create(e) {
2487
+ const t = e.mapTypes ?? St, r = {
2488
+ default: BMAP_MAPTYPE_CONTROL_HORIZONTAL,
2489
+ horizontal: BMAP_MAPTYPE_CONTROL_HORIZONTAL,
2490
+ dropdown: BMAP_MAPTYPE_CONTROL_DROPDOWN
2491
+ }, s = new BMap.MapTypeControl({
2492
+ type: e.type && r[e.type],
2493
+ mapTypes: t.map((o) => o.asBaiduMapType())
2494
+ });
2495
+ return e.position && s.setAnchor(P.getBaidu().toValue(e.position)), new Xe(s, e.position);
2496
+ }
2497
+ }
2498
+ const X = class extends qe {
2499
+ constructor(e = "default", t = x.TOP_LEFT, r = St) {
2500
+ super("mapType", t), this.type = e, this.mapTypes = r, X.type2google || (X.type2google = {
2501
+ default: google.maps.MapTypeControlStyle.DEFAULT,
2502
+ horizontal: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
2503
+ dropdown: google.maps.MapTypeControlStyle.DROPDOWN_MENU
2504
+ });
2505
+ }
2506
+ static create(e) {
2507
+ return new X(e.type, e.position, e.mapTypes);
2508
+ }
2509
+ onCreateOptions() {
2510
+ const e = super.onCreateOptions();
2511
+ return e.style = X.type2google[this.type], e.mapTypeIds = this.mapTypes.map((t) => t instanceof E ? t.getGoogleMapTypeId() : t.id), e;
2512
+ }
2513
+ addTo(e) {
2514
+ super.addTo(e), this.mapTypes.forEach((t) => {
2515
+ t instanceof E || e.innerMap.mapTypes.set(t.id, t.asGoogleMapType());
2516
+ });
2517
+ }
2518
+ };
2519
+ let me = X;
2520
+ h(me, "type2google");
2521
+ class Je extends Ke {
2522
+ static create(e) {
2523
+ const t = new BMap.NavigationControl({
2524
+ type: BMAP_NAVIGATION_CONTROL_ZOOM,
2525
+ // enableGeolocation: true,
2526
+ anchor: e.position && P.getBaidu().toValue(e.position)
2527
+ });
2528
+ return new Je(t, e.position);
2529
+ }
2530
+ }
2531
+ class Qe extends qe {
2532
+ static create(e) {
2533
+ return new Qe(e.position);
2534
+ }
2535
+ constructor(e = x.RIGHT_BOTTOM) {
2536
+ super("zoom", e);
2537
+ }
2538
+ }
2539
+ class et extends Ke {
2540
+ static create(e) {
2541
+ const t = new BMap.ScaleControl({
2542
+ anchor: e.position && P.getBaidu().toValue(e.position)
2543
+ });
2544
+ return new et(t, e.position);
2545
+ }
2546
+ }
2547
+ class tt extends qe {
2548
+ static create(e) {
2549
+ return new tt(e.position);
2550
+ }
2551
+ constructor(e = x.BOTTOM_RIGHT) {
2552
+ super("scale", e);
2553
+ }
2554
+ }
2555
+ var Ae;
2556
+ ((i) => {
2557
+ function e(t) {
2558
+ return t.scrollWidth > t.clientWidth || t.scrollHeight > t.clientHeight;
2559
+ }
2560
+ i.isScrollable = e;
2561
+ })(Ae || (Ae = {}));
2562
+ var ee;
2563
+ ((i) => {
2564
+ function e(r) {
2565
+ return {
2566
+ url: r.url,
2567
+ size: new google.maps.Size(r.size.width, r.size.height),
2568
+ origin: r.origin && new google.maps.Point(r.origin.x, r.origin.y),
2569
+ // google的锚点默认就是图标的底部中点
2570
+ anchor: r.anchor && new google.maps.Point(r.anchor.x, r.anchor.y)
2571
+ };
2572
+ }
2573
+ i.toGoogle = e;
2574
+ function t(r) {
2575
+ return new BMap.Icon(r.url, new BMap.Size(r.size.width, r.size.height), {
2576
+ imageOffset: r.origin && new BMap.Size(-r.origin.x, -r.origin.y),
2577
+ // baidu的锚点默认为图标的中心点, 故需要和@tg/map统一, 改成图标的底部中点
2578
+ anchor: r.anchor ? new BMap.Size(r.anchor.x, r.anchor.y) : new BMap.Size(r.size.width / 2, r.size.height)
2579
+ // InfoWindow相对图标左上角的偏移量, 不指定则InfoWindow不会偏移, 直接指到marker的position上
2580
+ // infoWindowAnchor: new BMap.Size(0, 0),
2581
+ });
2582
+ }
2583
+ i.toBaidu = t;
2584
+ })(ee || (ee = {}));
2585
+ class he extends Oe {
2586
+ constructor(e, t, r, s) {
2587
+ super(e, t, r), this.state = s;
2588
+ }
2589
+ static create(e) {
2590
+ const t = this.coordType, r = e.icon, s = {
2591
+ title: e.title,
2592
+ icon: r && ee.toBaidu(r),
2593
+ enableClicking: e.clickable,
2594
+ enableDragging: e.draggable,
2595
+ // baidu的raiseOnDrag属性, 默认为false, 而我们的options.crossOnDrag默认为true, 故这里需要转换下
2596
+ raiseOnDrag: e.crossOnDrag === void 0 ? !0 : e.crossOnDrag,
2597
+ draggingCursor: e.cursor
2598
+ }, o = new BMap.Marker(e.position.toBaidu(t), s);
2599
+ e.zIndex !== void 0 && o.setZIndex(e.zIndex);
2600
+ const a = e.clickable === void 0 ? !0 : e.clickable, g = !!e.draggable;
2601
+ return new he(o, t, this, { clickable: a, draggable: g, zIndex: e.zIndex }).visibleOptionInternal(e.visible);
2602
+ }
2603
+ getPosition() {
2604
+ return y.fromBaidu(this.innerOverlay.getPosition(), this.coordType);
2605
+ }
2606
+ setPosition(e) {
2607
+ var t;
2608
+ this.coordType = this.map.coordType, this.innerOverlay.setPosition(e.toBaidu(this.coordType)), (t = this.innerOverlay.__info_box__) == null || t.onMarkerPositionChanged();
2609
+ }
2610
+ setTitle(e) {
2611
+ this.innerOverlay.setTitle(e);
2612
+ }
2613
+ getTitle() {
2614
+ return this.innerOverlay.getTitle();
2615
+ }
2616
+ setIcon(e) {
2617
+ const t = ee.toBaidu(e);
2618
+ this.innerOverlay.setIcon(t);
2619
+ const r = this.getLabel();
2620
+ r && r.attachIcon(t);
2621
+ }
2622
+ getIcon() {
2623
+ return this.innerOverlay.getIcon();
2624
+ }
2625
+ setClickable(e) {
2626
+ this.state.clickable = e;
2627
+ }
2628
+ isClickable() {
2629
+ return this.state.clickable;
2630
+ }
2631
+ setDraggable(e) {
2632
+ this.state.draggable = e, e ? this.innerOverlay.enableDragging() : this.innerOverlay.disableDragging();
2633
+ }
2634
+ isDraggable() {
2635
+ return this.state.draggable;
2636
+ }
2637
+ setZIndex(e) {
2638
+ this.state.zIndex = e, this.innerOverlay.setZIndex(e || 0);
2639
+ }
2640
+ getZIndex() {
2641
+ return this.state.zIndex;
2642
+ }
2643
+ setLabel(e) {
2644
+ const t = this.getLabel();
2645
+ t && t.attachIcon(void 0), e && e.attachIcon(this.innerOverlay.getIcon()), this.innerOverlay.setLabel(e == null ? void 0 : e.innerOverlay);
2646
+ }
2647
+ getLabel() {
2648
+ var e;
2649
+ return (e = this.innerOverlay.getLabel()) == null ? void 0 : e.__label__;
2650
+ }
2651
+ }
2652
+ class rt extends Ze {
2653
+ constructor() {
2654
+ super(...arguments);
2655
+ h(this, "label");
2656
+ h(this, "labelPositionListener");
2657
+ h(this, "labelVisibleListener");
2658
+ h(this, "labelMapChangedListener");
2659
+ }
2660
+ static create(t) {
2661
+ const r = this.coordType, s = t.icon, o = {
2662
+ position: t.position.toGoogle(r),
2663
+ title: t.title,
2664
+ zIndex: t.zIndex,
2665
+ visible: t.visible,
2666
+ icon: s && ee.toGoogle(s),
2667
+ clickable: t.clickable,
2668
+ draggable: t.draggable,
2669
+ // google的crossOnDrag和我们的crossOnDrag是匹配的, 不需要转换
2670
+ crossOnDrag: t.crossOnDrag,
2671
+ cursor: t.cursor,
2672
+ // InfoWindow相对marker的position的偏移量, 若不指定, 则偏移到marker的icon的上部中央
2673
+ anchorPoint: new google.maps.Point(0, 0)
2674
+ };
2675
+ return new rt(new google.maps.Marker(o), r, this);
2676
+ }
2677
+ getPosition() {
2678
+ return y.fromGoogle(this.innerOverlay.getPosition(), this.coordType);
2679
+ }
2680
+ setPosition(t) {
2681
+ this.coordType = this.map.coordType, this.innerOverlay.setPosition(t.toGoogle(this.coordType));
2682
+ }
2683
+ setTitle(t) {
2684
+ this.innerOverlay.setTitle(t);
2685
+ }
2686
+ getTitle() {
2687
+ return this.innerOverlay.getTitle() || "";
2688
+ }
2689
+ setIcon(t) {
2690
+ this.innerOverlay.setIcon(ee.toGoogle(t));
2691
+ }
2692
+ getIcon() {
2693
+ return this.innerOverlay.getIcon();
2694
+ }
2695
+ setClickable(t) {
2696
+ this.innerOverlay.setClickable(t);
2697
+ }
2698
+ isClickable() {
2699
+ return this.innerOverlay.getClickable();
2700
+ }
2701
+ setDraggable(t) {
2702
+ this.innerOverlay.setDraggable(t);
2703
+ }
2704
+ isDraggable() {
2705
+ return !!this.innerOverlay.getDraggable();
2706
+ }
2707
+ setZIndex(t) {
2708
+ this.innerOverlay.setZIndex(t === void 0 ? null : t);
2709
+ }
2710
+ getZIndex() {
2711
+ const t = this.innerOverlay.getZIndex();
2712
+ return t === null ? void 0 : t;
2713
+ }
2714
+ setLabel(t) {
2715
+ if (this.label && this.map.removeOverlay(this.label), this.labelPositionListener && this.labelPositionListener.remove(), this.labelVisibleListener && this.labelVisibleListener.remove(), this.labelMapChangedListener && this.labelMapChangedListener.remove(), t) {
2716
+ const r = () => {
2717
+ t.innerOverlay.setPosition(this.innerOverlay.getPosition());
2718
+ }, s = () => {
2719
+ t.innerOverlay.setVisible(this.innerOverlay.getVisible());
2720
+ }, o = () => {
2721
+ this.innerOverlay.getMap() ? this.map.addOverlay(t) : this.map.removeOverlay(t);
2722
+ };
2723
+ o(), r(), s(), this.label = t, this.labelMapChangedListener = this.innerOverlay.addListener("map_changed", o), this.labelPositionListener = this.innerOverlay.addListener("position_changed", r), this.labelVisibleListener = this.innerOverlay.addListener("visible_changed", s);
2724
+ } else
2725
+ this.label = void 0, this.labelPositionListener = void 0, this.labelVisibleListener = void 0, this.labelMapChangedListener = void 0;
2726
+ }
2727
+ }
2728
+ class it {
2729
+ constructor(e) {
2730
+ this.delegate = e, this.delegate.setTarget(this);
2731
+ }
2732
+ addEventListener(e, t) {
2733
+ this.delegate.addEventListener(e, t);
2734
+ }
2735
+ removeEventListener(e, t) {
2736
+ this.delegate.removeEventListener(e, t);
2737
+ }
2738
+ }
2739
+ class st extends it {
2740
+ constructor(e, t, r) {
2741
+ super(new J(e, t)), this.inner = e, this.map = t, this.state = r;
2742
+ }
2743
+ static create(e) {
2744
+ const t = e.position || y.ZERO, r = new BMap.InfoWindow(e.content, {
2745
+ maxWidth: e.maxWidth,
2746
+ offset: e.offset && new BMap.Size(e.offset.x, e.offset.y),
2747
+ enableAutoPan: !e.disableAutoPan
2748
+ });
2749
+ return new st(r, this, { position: t });
2750
+ }
2751
+ isOpen() {
2752
+ return this.inner.isOpen();
2753
+ }
2754
+ open(e) {
2755
+ e ? e.innerOverlay.openInfoWindow(this.inner) : this.map.innerMap.openInfoWindow(this.inner, (this.state.position || y.ZERO).toBaidu(this.map.coordType)), this.map.setLatestInfoWindowInternal(this);
2756
+ }
2757
+ close() {
2758
+ this.inner.isOpen() && this.map.innerMap.closeInfoWindow();
2759
+ }
2760
+ getPosition() {
2761
+ const e = this.inner.getPosition();
2762
+ return e && y.fromBaidu(e, this.map.coordType) || this.state.position || y.ZERO;
2763
+ }
2764
+ setPosition(e) {
2765
+ this.state.position = e, this.inner.isOpen() && this.open();
2766
+ }
2767
+ }
2768
+ class ot extends it {
2769
+ constructor(t, r) {
2770
+ super(new K(t, r));
2771
+ h(this, "eventHub", new xr());
2772
+ h(this, "isOpened", !1);
2773
+ this.inner = t, this.map = r, t.addListener("closeclick", () => {
2774
+ this.isOpened = !1, this.eventHub.hasListener("close") && this.eventHub.notify({ type: "close", target: this });
2775
+ }), t.addListener("map_changed", () => {
2776
+ const s = this.isOpened;
2777
+ this.isOpened = !!t.getMap(), s && !this.isOpened && this.eventHub.hasListener("close") && this.eventHub.notify({ type: "close", target: this });
2778
+ });
2779
+ }
2780
+ static create(t) {
2781
+ const r = t.position || y.ZERO, s = new google.maps.InfoWindow({
2782
+ content: t.content,
2783
+ maxWidth: t.maxWidth,
2784
+ pixelOffset: t.offset && new google.maps.Size(t.offset.x, t.offset.y),
2785
+ position: r.toGoogle(this.coordType),
2786
+ disableAutoPan: t.disableAutoPan
2787
+ });
2788
+ return new ot(s, this);
2789
+ }
2790
+ isOpen() {
2791
+ return this.isOpened;
2792
+ }
2793
+ addEventListener(t, r) {
2794
+ if (t === "open" || t === "close") {
2795
+ this.eventHub.addEventListener(t, r);
2796
+ return;
2797
+ }
2798
+ super.addEventListener(t, r);
2799
+ }
2800
+ removeEventListener(t, r) {
2801
+ if (t === "open" || t === "close") {
2802
+ this.eventHub.removeEventListener(t, r);
2803
+ return;
2804
+ }
2805
+ super.removeEventListener(t, r);
2806
+ }
2807
+ open(t) {
2808
+ if (!this.isOpened) {
2809
+ if (this.map.mapOptions.infoWindowMode === "single") {
2810
+ const r = this.map.getLatestInfoWindow();
2811
+ r && r.close();
2812
+ }
2813
+ this.inner.open(this.map.innerMap, t == null ? void 0 : t.innerOverlay), this.isOpened = !0, this.map.setLatestInfoWindowInternal(this), this.eventHub.notify({ type: "open", target: this });
2814
+ }
2815
+ }
2816
+ close() {
2817
+ this.isOpened && (this.isOpened = !1, this.inner.close(), this.eventHub.notify({ type: "close", target: this }));
2818
+ }
2819
+ getPosition() {
2820
+ return y.fromGoogle(this.inner.getPosition(), this.map.coordType);
2821
+ }
2822
+ setPosition(t) {
2823
+ this.inner.setPosition(t.toGoogle(this.map.coordType));
2824
+ }
2825
+ }
2826
+ var ce;
2827
+ ((i) => {
2828
+ i.ZERO = { x: 0, y: 0 };
2829
+ })(ce || (ce = {}));
2830
+ let Ee;
2831
+ function Pr(i, e, t, r) {
2832
+ return Ee || (Ee = Lr()), new Ee(i, e, t, r);
2833
+ }
2834
+ function Lr() {
2835
+ return class extends google.maps.OverlayView {
2836
+ constructor(t, r, s, o) {
2837
+ super();
2838
+ h(this, "container");
2839
+ this.position = r, this.offset = s, this.zIndex = o, this.container = document.createElement("div"), this.container.className = "label-container", this.container.style.position = "absolute", o && this.setZIndex(o), this.container.addEventListener("click", () => {
2840
+ google.maps.event.trigger(this, "click");
2841
+ }), this.setElement(t);
2842
+ }
2843
+ setZIndex(t) {
2844
+ this.container.style.zIndex = `${t}`;
2845
+ }
2846
+ setElement(t) {
2847
+ const r = this.container.firstChild;
2848
+ r !== t && (r ? this.container.replaceChild(r, t) : this.container.appendChild(t));
2849
+ }
2850
+ /** @override */
2851
+ onAdd() {
2852
+ this.zIndex ? this.getPanes().overlayMouseTarget.appendChild(this.container) : this.getPanes().overlayLayer.appendChild(this.container);
2853
+ }
2854
+ /** @override */
2855
+ draw() {
2856
+ var t, r;
2857
+ if (this.container.style.display = this.position ? "block" : "none", this.position) {
2858
+ const s = this.getProjection();
2859
+ if (s) {
2860
+ const o = s.fromLatLngToDivPixel(this.position);
2861
+ this.container.style.left = `${o.x + (((t = this.offset) == null ? void 0 : t.x) ?? 0)}px`, this.container.style.top = `${o.y + (((r = this.offset) == null ? void 0 : r.y) ?? 0)}px`;
2862
+ }
2863
+ }
2864
+ }
2865
+ /** @override */
2866
+ onRemove() {
2867
+ var t;
2868
+ (t = this.container.parentNode) == null || t.removeChild(this.container);
2869
+ }
2870
+ setPosition(t) {
2871
+ this.position = t, this.draw();
2872
+ }
2873
+ getPosition() {
2874
+ return this.position;
2875
+ }
2876
+ setOffset(t) {
2877
+ this.offset = t, this.draw();
2878
+ }
2879
+ getOffset() {
2880
+ return this.offset;
2881
+ }
2882
+ getVisible() {
2883
+ return this.container.style.visibility !== "hidden";
2884
+ }
2885
+ setVisible(t) {
2886
+ this.container.style.visibility = t ? "visible" : "hidden";
2887
+ }
2888
+ };
2889
+ }
2890
+ var te;
2891
+ ((i) => {
2892
+ function e(r) {
2893
+ return typeof r == "string" ? r : r.outerHTML;
2894
+ }
2895
+ i.toString = e;
2896
+ function t(r) {
2897
+ if (typeof r == "string") {
2898
+ const s = document.createElement("div");
2899
+ return s.innerHTML = r, s;
2900
+ }
2901
+ return r;
2902
+ }
2903
+ i.toElement = t;
2904
+ })(te || (te = {}));
2905
+ class nt extends Oe {
2906
+ constructor(t, r, s, o) {
2907
+ super(t, r, s);
2908
+ h(this, "icon");
2909
+ h(this, "content", void 0);
2910
+ h(this, "contentObserver");
2911
+ this.setContentInternal(o, !0);
2912
+ }
2913
+ static create(t) {
2914
+ var a;
2915
+ const r = this.coordType, s = new BMap.Label(te.toString(t.content), {
2916
+ position: (a = t.position) == null ? void 0 : a.toBaidu(r),
2917
+ offset: t.offset && new BMap.Size(t.offset.x, t.offset.y)
2918
+ });
2919
+ t.zIndex && s.setZIndex(t.zIndex), s.setStyle({
2920
+ border: "0px",
2921
+ padding: "0px",
2922
+ backgroundColor: "unset"
2923
+ });
2924
+ const o = new nt(s, r, this, t.content);
2925
+ return s.__label__ = o, o;
2926
+ }
2927
+ setContentInternal(t, r = !1) {
2928
+ this.content !== t && (this.contentObserver && (this.contentObserver.disconnect(), this.contentObserver = void 0), typeof t != "string" && (this.contentObserver = new MutationObserver(() => {
2929
+ this.innerOverlay.setContent(t.outerHTML);
2930
+ }), this.contentObserver.observe(t, {
2931
+ attributes: !0,
2932
+ characterData: !0,
2933
+ childList: !0,
2934
+ subtree: !0
2935
+ })), r || this.innerOverlay.setContent(te.toString(t)), this.content = t);
2936
+ }
2937
+ setZIndex(t) {
2938
+ this.innerOverlay.setZIndex(t);
2939
+ }
2940
+ getPosition() {
2941
+ return y.fromBaidu(this.innerOverlay.getPosition(), this.coordType);
2942
+ }
2943
+ setPosition(t) {
2944
+ this.coordType = this.map.coordType, this.innerOverlay.setPosition(t.toBaidu(this.coordType));
2945
+ }
2946
+ getOffset() {
2947
+ const t = this.innerOverlay.getOffset();
2948
+ let r = 0, s = 0;
2949
+ return this.icon && (r = this.icon.anchor.width, s = this.icon.anchor.height), { x: t.width - r, y: t.height - s };
2950
+ }
2951
+ setOffset(t) {
2952
+ let r = 0, s = 0;
2953
+ this.icon && (r = this.icon.anchor.width, s = this.icon.anchor.height), this.innerOverlay.setOffset(new BMap.Size(t.x + r, t.y + s));
2954
+ }
2955
+ setContent(t) {
2956
+ this.setContentInternal(t);
2957
+ }
2958
+ /**
2959
+ * 关联新的Icon, 内部使用的方法
2960
+ * @description baidu中Label默认左上角对齐Icon的左上, 我们要将其转换为对齐marker的position
2961
+ * */
2962
+ attachIcon(t) {
2963
+ const r = this.innerOverlay.getOffset();
2964
+ let s = r.width, o = r.height;
2965
+ this.icon && (s -= this.icon.anchor.width, o -= this.icon.anchor.height), t && (s += t.anchor.width, o += t.anchor.height), this.innerOverlay.setOffset(new BMap.Size(s, o)), this.icon = t;
2966
+ }
2967
+ }
2968
+ class at extends Ze {
2969
+ static create(e) {
2970
+ var s;
2971
+ const t = this.coordType, r = Pr(
2972
+ te.toElement(e.content),
2973
+ (s = e.position) == null ? void 0 : s.toGoogle(t),
2974
+ e.offset,
2975
+ e.zIndex
2976
+ );
2977
+ return new at(r, t, this);
2978
+ }
2979
+ setZIndex(e) {
2980
+ this.innerOverlay.setZIndex(e);
2981
+ }
2982
+ setContent(e) {
2983
+ this.innerOverlay.setElement(te.toElement(e));
2984
+ }
2985
+ getPosition() {
2986
+ const e = this.innerOverlay.getPosition();
2987
+ return e ? y.fromGoogle(e, this.coordType) : y.ZERO;
2988
+ }
2989
+ setPosition(e) {
2990
+ this.coordType = this.map.coordType, this.innerOverlay.setPosition(e.toGoogle(this.coordType));
2991
+ }
2992
+ getOffset() {
2993
+ return this.innerOverlay.getOffset() ?? ce.ZERO;
2994
+ }
2995
+ setOffset(e) {
2996
+ this.innerOverlay.setOffset(e);
2997
+ }
2998
+ }
2999
+ function $t() {
3000
+ BMap.OverlayV3 || (BMap.OverlayV3 = BMap.Overlay);
3001
+ }
3002
+ let ke;
3003
+ function Br(i, e, t, r, s, o) {
3004
+ return ke || (ke = Sr()), new ke(i, e, t, r, s, o);
3005
+ }
3006
+ function Sr() {
3007
+ $t();
3008
+ const i = new BMap.Point(0, 0);
3009
+ return class extends BMap.OverlayV3 {
3010
+ constructor(r, s = i, o = ce.ZERO, a, g = 654, n = "") {
3011
+ super();
3012
+ // 类表达式不能有私有成员, 故改成public
3013
+ h(this, "container");
3014
+ h(this, "border");
3015
+ h(this, "inner");
3016
+ h(this, "map");
3017
+ h(this, "marker");
3018
+ this.content = r, this.position = s, this.offset = o;
3019
+ const l = "baidu-info-box-container";
3020
+ this.container = document.createElement("div"), this.container.className = l, this.container.style.position = "absolute", this.border = document.createElement("div"), this.border.className = `${l}__border ${n}`, this.inner = document.createElement("div"), this.inner.className = l + "__inner";
3021
+ const c = document.createElement("img");
3022
+ c.className = l + "__close", c.src = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224px%22%20height%3D%2224px%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%23000000%22%3E%0A%20%20%20%20%3Cpath%20d%3D%22M19%206.41L17.59%205%2012%2010.59%206.41%205%205%206.41%2010.59%2012%205%2017.59%206.41%2019%2012%2013.41%2017.59%2019%2019%2017.59%2013.41%2012z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M0%200h24v24H0z%22%20fill%3D%22none%22%2F%3E%0A%3C%2Fsvg%3E%0A", c.addEventListener("click", () => {
3023
+ this.close(), this.dispatchEvent({ type: "onclickclose" });
3024
+ }), this.inner.appendChild(r), this.border.appendChild(this.inner), this.border.appendChild(c), this.container.appendChild(this.border), a && this.setZIndex(a), this.setMaxWidth(g), this.onMarkerPositionChanged = this.onMarkerPositionChanged.bind(this);
3025
+ }
3026
+ /** @override */
3027
+ initialize(r) {
3028
+ return this.map = r, r.getPanes().floatPane.appendChild(this.container), this.container;
3029
+ }
3030
+ /** @override */
3031
+ draw() {
3032
+ if (!this.map)
3033
+ return;
3034
+ const r = this.marker ? this.marker.getPosition() : this.position, s = this.map.pointToOverlayPixel(r), o = s.x + this.offset.x, a = s.y + this.offset.y;
3035
+ this.container.style.left = `${o}px`, this.container.style.top = `${a}px`;
3036
+ }
3037
+ open(r, s) {
3038
+ s && s === this.marker || (this.marker && this.detachMarker(this.marker), this.marker = s, this.marker && this.attachMarker(this.marker), this.isOpen() ? this.draw() : this.marker && !this.marker.getMap() || r.addOverlay(this));
3039
+ }
3040
+ attachMarker(r) {
3041
+ r.__info_box__ = this, r.addEventListener("dragging", this.onMarkerPositionChanged), r.addEventListener("dragend", this.onMarkerPositionChanged);
3042
+ }
3043
+ detachMarker(r) {
3044
+ r.__info_box__ = void 0, r.removeEventListener("dragging", this.onMarkerPositionChanged), r.removeEventListener("dragend", this.onMarkerPositionChanged);
3045
+ }
3046
+ close() {
3047
+ this.map && (this.map.removeOverlay(this), this.marker && (this.detachMarker(this.marker), this.marker = void 0), this.map = void 0);
3048
+ }
3049
+ isOpen() {
3050
+ return this.map && this.map.getPanes().floatPane === this.container.parentNode;
3051
+ }
3052
+ onMarkerPositionChanged() {
3053
+ this.draw();
3054
+ }
3055
+ setZIndex(r) {
3056
+ this.container.style.zIndex = `${r}`;
3057
+ }
3058
+ setMaxWidth(r) {
3059
+ this.border.style.maxWidth = `${r}px`;
3060
+ }
3061
+ setPosition(r) {
3062
+ this.marker || (this.position = r, this.draw());
3063
+ }
3064
+ getPosition() {
3065
+ return this.position;
3066
+ }
3067
+ setOffset(r) {
3068
+ this.offset = r, this.draw();
3069
+ }
3070
+ getOffset() {
3071
+ return this.offset;
3072
+ }
3073
+ };
3074
+ }
3075
+ class lt extends Oe {
3076
+ constructor(e, t, r) {
3077
+ super(e, t, r), this.baiduMap = r;
3078
+ }
3079
+ static create(e) {
3080
+ var s;
3081
+ const t = this.coordType, r = Br(
3082
+ e.content,
3083
+ (s = e.position) == null ? void 0 : s.toBaidu(t),
3084
+ e.offset,
3085
+ e.zIndex,
3086
+ e.maxWidth,
3087
+ e.borderClass
3088
+ );
3089
+ return new lt(r, t, this);
3090
+ }
3091
+ open(e) {
3092
+ this.innerOverlay.open(this.baiduMap.innerMap, e == null ? void 0 : e.innerOverlay);
3093
+ }
3094
+ close() {
3095
+ this.innerOverlay.close();
3096
+ }
3097
+ getPosition() {
3098
+ return y.fromBaidu(this.innerOverlay.getPosition(), this.coordType);
3099
+ }
3100
+ setPosition(e) {
3101
+ this.coordType = this.map.coordType, this.innerOverlay.setPosition(e.toBaidu(this.coordType));
3102
+ }
3103
+ setMaxWidth(e) {
3104
+ this.innerOverlay.setMaxWidth(e);
3105
+ }
3106
+ setZIndex(e) {
3107
+ this.innerOverlay.setZIndex(e);
3108
+ }
3109
+ }
3110
+ class ht extends it {
3111
+ constructor(e, t, r) {
3112
+ super(new K(e, r)), this.inner = e, this.coordType = t, this.map = r;
3113
+ }
3114
+ static create(e) {
3115
+ var o;
3116
+ const t = this.coordType, r = new google.maps.InfoWindow({
3117
+ content: e.content,
3118
+ position: (o = e.position) == null ? void 0 : o.toGoogle(t),
3119
+ pixelOffset: e.offset && new google.maps.Size(e.offset.x, e.offset.y),
3120
+ zIndex: e.zIndex,
3121
+ maxWidth: e.maxWidth
3122
+ }), s = e.borderClass;
3123
+ return s && r.addListener("domready", () => {
3124
+ var g;
3125
+ const a = (g = e.content.parentElement) == null ? void 0 : g.parentElement;
3126
+ a && a.className.includes("gm-style-iw-c") && !a.className.includes(s) && (a.className += ` ${s}`);
3127
+ }), new ht(r, t, this);
3128
+ }
3129
+ open(e) {
3130
+ this.inner.open(this.map.innerMap, e == null ? void 0 : e.innerOverlay);
3131
+ }
3132
+ close() {
3133
+ this.inner.close();
3134
+ }
3135
+ getPosition() {
3136
+ return y.fromGoogle(this.inner.getPosition(), this.coordType);
3137
+ }
3138
+ setPosition(e) {
3139
+ this.coordType = this.map.coordType, this.inner.setPosition(e.toGoogle(this.coordType));
3140
+ }
3141
+ isOpen() {
3142
+ return this.inner.getMap() != null;
3143
+ }
3144
+ setMaxWidth(e) {
3145
+ if (this.isOpen()) {
3146
+ const t = this.inner.getMap(), r = this.inner.getAnchor();
3147
+ this.inner.close(), this.inner.setOptions({ maxWidth: e }), this.inner.open(t, r);
3148
+ } else
3149
+ this.inner.setOptions({ maxWidth: e });
3150
+ }
3151
+ setZIndex(e) {
3152
+ this.inner.setZIndex(e);
3153
+ }
3154
+ }
3155
+ class $r extends Re {
3156
+ constructor(t, r) {
3157
+ var s;
3158
+ super(t);
3159
+ h(this, "buildInMapTypeId2BIMT");
3160
+ h(this, "baiduMapType2BIMT");
3161
+ h(this, "map");
3162
+ h(this, "createLabel", nt.create);
3163
+ h(this, "createCircle", Ue.create);
3164
+ h(this, "createPolygon", He.create);
3165
+ h(this, "createPolyline", We.create);
3166
+ h(this, "createInfoWindow", st.create);
3167
+ h(this, "createInfoBox", lt.create);
3168
+ h(this, "createMarker", he.create);
3169
+ h(this, "createMapTypeControl", Xe.create);
3170
+ h(this, "createZoomControl", Je.create);
3171
+ h(this, "createScaleControl", et.create);
3172
+ this.buildInMapTypeId2BIMT = k.BUILD_IN_MAP_TYPES.getValueMap(E.prototype.getId), this.baiduMapType2BIMT = k.BUILD_IN_MAP_TYPES.getValueMap(E.prototype.asBaiduMapType), this.map = new BMap.Map(t, {
3173
+ minZoom: r.minZoom,
3174
+ maxZoom: r.maxZoom,
3175
+ mapType: r.buildInMapTypeId && ((s = this.buildInMapTypeId2BIMT.get(r.buildInMapTypeId)) == null ? void 0 : s.asBaiduMapType()),
3176
+ enableMapClick: !1
3177
+ // 关闭底图点击功能
3178
+ }), this.map.centerAndZoom(r.center.toBaidu(this.coordType), r.zoom), this.setGestureHandling(r.gestureHandling), r.infoWindowMode === "multi" && console.warn("baidu不支持多个InfoWindow, 可能会出现未知问题"), r.mapStyle && this.map.setMapStyle2(r.mapStyle.toBaidu()), this.setEventTargetDelegate(new J(this.map, this)), this.map.addEventListener("addoverlay", (o) => {
3179
+ const a = o.target.__info_box__;
3180
+ a && (console.debug("add:info-box", a), this.map.addOverlay(a));
3181
+ }), this.map.addEventListener("removeoverlay", (o) => {
3182
+ const a = o.target.__info_box__;
3183
+ a && (console.debug("remove:info-box", a), this.map.removeOverlay(a));
3184
+ });
3185
+ }
3186
+ setDefaultCursor(t) {
3187
+ this.innerMap.setDefaultCursor(t);
3188
+ }
3189
+ setGestureHandling(t = N.auto) {
3190
+ switch (t === N.auto && (t = this.element.parentElement && Ae.isScrollable(this.element.parentElement) ? N.cooperative : N.greedy), t) {
3191
+ case N.cooperative:
3192
+ this.map.disableScrollWheelZoom(), this.map.enableDragging(), this.map.enableDoubleClickZoom();
3193
+ break;
3194
+ case N.greedy:
3195
+ this.map.enableScrollWheelZoom(), this.map.enableDragging(), this.map.enableDoubleClickZoom();
3196
+ break;
3197
+ case N.none:
3198
+ this.map.disableDragging(), this.map.disableScrollWheelZoom(), this.map.disableDoubleClickZoom();
3199
+ break;
3200
+ }
3201
+ }
3202
+ get innerMap() {
3203
+ return this.map;
3204
+ }
3205
+ get coordType() {
3206
+ return this.getMapType().getBaiduCoordType();
3207
+ }
3208
+ addEventListener(t, r) {
3209
+ if (t === "center-changed") {
3210
+ super.addEventListener("movestart", r), super.addEventListener("moving", r), super.addEventListener("moveend", r), super.addEventListener("zoomend", r);
3211
+ return;
3212
+ }
3213
+ super.addEventListener(t, r);
3214
+ }
3215
+ removeEventListener(t, r) {
3216
+ if (t === "center-changed") {
3217
+ super.removeEventListener("movestart", r), super.removeEventListener("moving", r), super.removeEventListener("moveend", r), super.removeEventListener("zoomend", r);
3218
+ return;
3219
+ }
3220
+ super.removeEventListener(t, r);
3221
+ }
3222
+ fromContainerPointToLatLng(t) {
3223
+ return y.fromBaidu(this.innerMap.pixelToPoint(new BMap.Pixel(t.x, t.y)), this.coordType);
3224
+ }
3225
+ fromLatLngToContainerPoint(t) {
3226
+ return this.innerMap.pointToPixel(t.toBaidu(this.coordType));
3227
+ }
3228
+ setDraggable(t) {
3229
+ t ? this.innerMap.enableDragging() : this.innerMap.disableDragging();
3230
+ }
3231
+ setDisableDoubleClickZoom(t) {
3232
+ t ? this.map.enableDoubleClickZoom() : this.map.disableDoubleClickZoom();
3233
+ }
3234
+ getCenter() {
3235
+ return y.fromBaidu(this.map.getCenter(), this.coordType);
3236
+ }
3237
+ setCenter(t) {
3238
+ this.map.setCenter(t.toBaidu(this.coordType));
3239
+ }
3240
+ setMinZoom(t) {
3241
+ this.map.setMinZoom(t);
3242
+ }
3243
+ setMaxZoom(t) {
3244
+ this.map.setMaxZoom(t);
3245
+ }
3246
+ setMapStyle(t) {
3247
+ this.map.setMapStyle2(t.toBaidu());
3248
+ }
3249
+ setBuildInMapTypeId(t) {
3250
+ var s;
3251
+ const r = (s = this.buildInMapTypeId2BIMT.get(t)) == null ? void 0 : s.asBaiduMapType();
3252
+ this.map.setMapType(r ?? I("理论上来说不可能为空"));
3253
+ }
3254
+ setMapType(t) {
3255
+ this.map.setMapType(t.asBaiduMapType());
3256
+ }
3257
+ getMapType() {
3258
+ const t = this.map.getMapType(), r = this.baiduMapType2BIMT.get(t);
3259
+ return r || (t.__baidu_map_type__ ?? I("实现asBaiduMapType()时, 忘了给实例设置__baidu_map_type__?"));
3260
+ }
3261
+ addLayer(t) {
3262
+ this.map.addTileLayer(t.asBaiduLayer());
3263
+ }
3264
+ removeLayer(t) {
3265
+ this.map.removeTileLayer(t.asBaiduLayer());
3266
+ }
3267
+ panTo(t) {
3268
+ this.map.panTo(t.toBaidu(this.coordType));
3269
+ }
3270
+ panBy(t, r) {
3271
+ this.map.panBy(t, r);
3272
+ }
3273
+ fitBounds(t, r) {
3274
+ this.map.setViewport(t.toBaiduArray(this.coordType), {
3275
+ // enableAnimation: true, // 默认为true
3276
+ margins: r && [r.top, r.right, r.bottom, r.left]
3277
+ });
3278
+ }
3279
+ getBounds() {
3280
+ return W.fromBaidu(this.map.getBounds(), this.coordType);
3281
+ }
3282
+ addElementOverlay(t) {
3283
+ this.map.addOverlay(t.asBaidu());
3284
+ }
3285
+ removeElementOverlay(t) {
3286
+ this.map.removeOverlay(t.asBaidu());
3287
+ }
3288
+ addOverlay(t) {
3289
+ this.map.addOverlay(t.innerOverlay);
3290
+ }
3291
+ removeOverlay(t) {
3292
+ this.map.removeOverlay(t.innerOverlay);
3293
+ }
3294
+ addCustomControl(t) {
3295
+ if (!t.inner) {
3296
+ const r = class extends BMap.Control {
3297
+ constructor() {
3298
+ super(...arguments);
3299
+ h(this, "defaultAnchor", P.getBaidu().toValue(t.position));
3300
+ h(this, "defaultOffset", new BMap.Size(0, 0));
3301
+ }
3302
+ initialize(o) {
3303
+ const a = t.onCreateElement();
3304
+ return o.getContainer().appendChild(a), a;
3305
+ }
3306
+ };
3307
+ t.inner = new r(), this.map.addControl(t.inner);
3308
+ }
3309
+ }
3310
+ removeCustomControl(t) {
3311
+ t.inner && (ne(t.inner instanceof BMap.Control, `control.inner(${t.inner})需要是BMap.Control`), this.map.removeControl(t.inner));
3312
+ }
3313
+ createMarkerClusterer(t) {
3314
+ return new Tr(this, t);
3315
+ }
3316
+ }
3317
+ class Ar extends Re {
3318
+ constructor(t, r) {
3319
+ var o;
3320
+ super(t);
3321
+ h(this, "buildInMapTypeId2BIMT");
3322
+ h(this, "googleMapTypeId2BIMT");
3323
+ h(this, "map");
3324
+ h(this, "createLabel", at.create);
3325
+ h(this, "createCircle", Ye.create);
3326
+ h(this, "createPolygon", Fe.create);
3327
+ h(this, "createPolyline", Ve.create);
3328
+ h(this, "createInfoWindow", ot.create);
3329
+ h(this, "createInfoBox", ht.create);
3330
+ h(this, "createMarker", rt.create);
3331
+ h(this, "createMapTypeControl", me.create);
3332
+ h(this, "createZoomControl", Qe.create);
3333
+ h(this, "createScaleControl", tt.create);
3334
+ this.mapOptions = r, this.buildInMapTypeId2BIMT = k.BUILD_IN_MAP_TYPES.getValueMap(E.prototype.getId), this.googleMapTypeId2BIMT = k.BUILD_IN_MAP_TYPES.getValueMap(E.prototype.getGoogleMapTypeId);
3335
+ const s = r.buildInMapTypeId && this.buildInMapTypeId2BIMT.get(r.buildInMapTypeId);
3336
+ this.map = new google.maps.Map(t, {
3337
+ center: r.center.toGoogle((s ?? k.NORMAL).getGoogleCoordType()),
3338
+ zoom: r.zoom,
3339
+ disableDefaultUI: !0,
3340
+ streetViewControl: !0,
3341
+ gestureHandling: r.gestureHandling,
3342
+ minZoom: r.minZoom,
3343
+ maxZoom: r.maxZoom,
3344
+ styles: (o = r.mapStyle) == null ? void 0 : o.toGoogle(),
3345
+ mapTypeId: s == null ? void 0 : s.getGoogleMapTypeId()
3346
+ }), this.setEventTargetDelegate(new K(this.map, this));
3347
+ }
3348
+ setDefaultCursor(t) {
3349
+ this.innerMap.setOptions({ draggableCursor: t });
3350
+ }
3351
+ setGestureHandling(t) {
3352
+ this.map.setOptions({
3353
+ gestureHandling: t
3354
+ });
3355
+ }
3356
+ get innerMap() {
3357
+ return this.map;
3358
+ }
3359
+ get coordType() {
3360
+ return this.getMapType().getGoogleCoordType();
3361
+ }
3362
+ fromContainerPointToLatLng(t) {
3363
+ const r = this.innerMap.getProjection(), s = this.innerMap.getBounds();
3364
+ if (r == null || s == null)
3365
+ return y.ZERO;
3366
+ const o = r.fromLatLngToPoint(s.getSouthWest()), a = r.fromLatLngToPoint(s.getNorthEast()), g = Math.pow(2, this.innerMap.getZoom()), n = new google.maps.Point(t.x / g + o.x, t.y / g + a.y);
3367
+ return y.fromGoogle(r.fromPointToLatLng(n), this.coordType);
3368
+ }
3369
+ fromLatLngToContainerPoint(t) {
3370
+ const r = this.innerMap.getProjection(), s = this.innerMap.getBounds();
3371
+ if (r == null || s == null)
3372
+ return ce.ZERO;
3373
+ const o = r.fromLatLngToPoint(s.getSouthWest()), a = r.fromLatLngToPoint(s.getNorthEast()), g = Math.pow(2, this.innerMap.getZoom()), n = r.fromLatLngToPoint(t.toGoogle(this.coordType));
3374
+ return { x: (n.x - o.x) * g, y: (n.y - a.y) * g };
3375
+ }
3376
+ setDraggable(t) {
3377
+ this.innerMap.setOptions({ draggable: t });
3378
+ }
3379
+ setDisableDoubleClickZoom(t) {
3380
+ this.map.setOptions({ disableDoubleClickZoom: t });
3381
+ }
3382
+ getCenter() {
3383
+ return y.fromGoogle(this.map.getCenter(), this.coordType);
3384
+ }
3385
+ setCenter(t) {
3386
+ this.map.setCenter(t.toGoogle(this.coordType));
3387
+ }
3388
+ setMinZoom(t) {
3389
+ this.map.setOptions({ minZoom: t });
3390
+ }
3391
+ setMaxZoom(t) {
3392
+ this.map.setOptions({ maxZoom: t });
3393
+ }
3394
+ setMapStyle(t) {
3395
+ this.map.setOptions({ styles: t.toGoogle() });
3396
+ }
3397
+ setBuildInMapTypeId(t) {
3398
+ var s;
3399
+ const r = (s = this.buildInMapTypeId2BIMT.get(t)) == null ? void 0 : s.getGoogleMapTypeId();
3400
+ this.map.setMapTypeId(r ?? I("理论上来说不可能为空"));
3401
+ }
3402
+ setMapType(t) {
3403
+ t instanceof E ? this.map.setMapTypeId(t.getGoogleMapTypeId()) : (this.map.mapTypes.set(t.id, t.asGoogleMapType()), this.map.setMapTypeId(t.id));
3404
+ }
3405
+ getMapType() {
3406
+ const t = this.map.getMapTypeId(), r = this.googleMapTypeId2BIMT.get(t);
3407
+ return r || (this.map.mapTypes.get(t).__google_map_type__ ?? I(`实现${t}的asGoogleMapType()时, 忘了给实例设置__google_map_type__?`));
3408
+ }
3409
+ addOverlayMapType(t) {
3410
+ this.map.overlayMapTypes.push(t.asGoogleMapType());
3411
+ }
3412
+ removeOverlayMapType(t) {
3413
+ Me.remove(this.map.overlayMapTypes, t.asGoogleMapType());
3414
+ }
3415
+ addLayer(t) {
3416
+ t.asGoogleLayer().setMap(this.map);
3417
+ }
3418
+ removeLayer(t) {
3419
+ t.asGoogleLayer().setMap(null);
3420
+ }
3421
+ panTo(t) {
3422
+ this.map.panTo(t.toGoogle(this.coordType));
3423
+ }
3424
+ panBy(t, r) {
3425
+ this.map.panBy(t, r);
3426
+ }
3427
+ fitBounds(t, r) {
3428
+ this.map.fitBounds(t.toGoogle(this.coordType), r);
3429
+ }
3430
+ getBounds() {
3431
+ const t = this.map.getBounds();
3432
+ return t ? W.fromGoogle(t, this.coordType) : W.EMPTY;
3433
+ }
3434
+ addElementOverlay(t) {
3435
+ t.asGoogle().setMap(this.map);
3436
+ }
3437
+ removeElementOverlay(t) {
3438
+ t.asGoogle().setMap(null);
3439
+ }
3440
+ addOverlay(t) {
3441
+ t.innerOverlay.setMap(this.map);
3442
+ }
3443
+ removeOverlay(t) {
3444
+ t.innerOverlay.setMap(null);
3445
+ }
3446
+ addCustomControl(t) {
3447
+ t.inner || (t.inner = t.onCreateElement(), this.map.controls[P.getGoogle().toValue(t.position)].push(t.inner));
3448
+ }
3449
+ removeCustomControl(t) {
3450
+ if (t.inner) {
3451
+ const r = this.map.controls[P.getGoogle().toValue(t.position)];
3452
+ Me.remove(r, t.inner);
3453
+ }
3454
+ }
3455
+ createMarkerClusterer(t) {
3456
+ return new Or(this, t);
3457
+ }
3458
+ }
3459
+ const be = ["3.0"], zr = {
3460
+ baidu: {
3461
+ version: "3.0",
3462
+ // TODO: 在build时好像会被静态替换, 导致使用者不能无法设置它
3463
+ // 详见: https://cn.vitejs.dev/guide/build.html#library-mode:~:text=%E6%A8%A1%E5%BC%8F%E4%B8%8B%EF%BC%8C%E6%89%80%E6%9C%89-,({}).*,-%E7%94%A8%E6%B3%95%E5%9C%A8%E6%9E%84
3464
+ key: {}.VITE_APP_DEV_KEY_BAIDU,
3465
+ language: ""
3466
+ },
3467
+ google: {
3468
+ version: "",
3469
+ key: {}.VITE_APP_DEV_KEY_GOOGLE,
3470
+ language: "en-us"
3471
+ },
3472
+ here: {
3473
+ version: be[0],
3474
+ key: {}.VITE_APP_DEV_KEY_HERE,
3475
+ language: ""
3476
+ }
3477
+ };
3478
+ let At;
3479
+ function zt() {
3480
+ return At || I("请先安装: Vue<PartialTgMapConfig>.use(TgMap, {})");
3481
+ }
3482
+ function Nr(i) {
3483
+ i != null && (At = Tt(zr, i));
3484
+ }
3485
+ class Rr extends Re {
3486
+ constructor(t, r) {
3487
+ var a;
3488
+ super(t);
3489
+ h(this, "map");
3490
+ h(this, "defaultLayers");
3491
+ this.mapOptions = r;
3492
+ const s = zt().here;
3493
+ be.includes(s.version) || I(`不支持${s.version}, HereMap当前只支持如下版本: ${be}`);
3494
+ const o = new H.service.Platform({
3495
+ app_id: s.key.split(",")[0],
3496
+ app_code: s.key.split(",")[1]
3497
+ });
3498
+ this.defaultLayers = o.createDefaultLayers(), this.map = new H.Map(t, this.defaultLayers.normal.map, {
3499
+ zoom: r.zoom,
3500
+ center: (a = r.center) == null ? void 0 : a.toHere(this.coordType)
3501
+ }), new H.mapevents.Behavior(new H.mapevents.MapEvents(this.map)), H.ui.UI.createDefault(this.map, this.defaultLayers);
3502
+ }
3503
+ setDefaultCursor(t) {
3504
+ throw new Error("Method not implemented.");
3505
+ }
3506
+ get innerMap() {
3507
+ return this.map;
3508
+ }
3509
+ get coordType() {
3510
+ return Y.wgs84;
3511
+ }
3512
+ getCenter() {
3513
+ return y.fromHere(this.map.getCenter(), this.coordType);
3514
+ }
3515
+ setCenter(t) {
3516
+ this.map.setCenter(t.toHere(this.coordType));
3517
+ }
3518
+ // TODO: 实现其他方法
3519
+ setDraggable(t) {
3520
+ throw new Error("Method not implemented.");
3521
+ }
3522
+ setDisableDoubleClickZoom(t) {
3523
+ throw new Error("Method not implemented.");
3524
+ }
3525
+ fromContainerPointToLatLng(t) {
3526
+ throw new Error("Method not implemented.");
3527
+ }
3528
+ fromLatLngToContainerPoint(t) {
3529
+ throw new Error("Method not implemented.");
3530
+ }
3531
+ addElementOverlay(t) {
3532
+ throw new Error("Method not implemented.");
3533
+ }
3534
+ removeElementOverlay(t) {
3535
+ throw new Error("Method not implemented.");
3536
+ }
3537
+ createInfoBox(t) {
3538
+ throw new Error("Method not implemented.");
3539
+ }
3540
+ createLabel(t) {
3541
+ throw new Error("Method not implemented.");
3542
+ }
3543
+ fitBounds(t, r) {
3544
+ throw new Error("Method not implemented.");
3545
+ }
3546
+ getBounds() {
3547
+ throw new Error("Method not implemented.");
3548
+ }
3549
+ panTo(t) {
3550
+ throw new Error("Method not implemented.");
3551
+ }
3552
+ panBy(t, r) {
3553
+ throw new Error("Method not implemented.");
3554
+ }
3555
+ setBuildInMapTypeId(t) {
3556
+ throw new Error("Method not implemented.");
3557
+ }
3558
+ setMapType(t) {
3559
+ throw new Error("Method not implemented.");
3560
+ }
3561
+ getMapType() {
3562
+ throw new Error("Method not implemented.");
3563
+ }
3564
+ addLayer(t) {
3565
+ throw new Error("Method not implemented.");
3566
+ }
3567
+ removeLayer(t) {
3568
+ throw new Error("Method not implemented.");
3569
+ }
3570
+ setGestureHandling(t) {
3571
+ throw new Error("Method not implemented.");
3572
+ }
3573
+ setMinZoom(t) {
3574
+ throw new Error("Method not implemented.");
3575
+ }
3576
+ setMaxZoom(t) {
3577
+ throw new Error("Method not implemented.");
3578
+ }
3579
+ setMapStyle(t) {
3580
+ throw new Error("Method not implemented.");
3581
+ }
3582
+ addOverlay(t) {
3583
+ throw new Error("Method not implemented.");
3584
+ }
3585
+ removeOverlay(t) {
3586
+ throw new Error("Method not implemented.");
3587
+ }
3588
+ createMarker(t) {
3589
+ throw new Error("Method not implemented.");
3590
+ }
3591
+ createMarkerClusterer(t) {
3592
+ throw new Error("Method not implemented.");
3593
+ }
3594
+ createInfoWindow(t) {
3595
+ throw new Error("Method not implemented.");
3596
+ }
3597
+ createPolyline(t) {
3598
+ throw new Error("Method not implemented.");
3599
+ }
3600
+ createPolygon(t) {
3601
+ throw new Error("Method not implemented.");
3602
+ }
3603
+ createCircle(t) {
3604
+ throw new Error("Method not implemented.");
3605
+ }
3606
+ addCustomControl(t) {
3607
+ throw new Error("Method not implemented.");
3608
+ }
3609
+ removeCustomControl(t) {
3610
+ throw new Error("Method not implemented.");
3611
+ }
3612
+ createMapTypeControl(t) {
3613
+ throw new Error("Method not implemented.");
3614
+ }
3615
+ createZoomControl(t) {
3616
+ throw new Error("Method not implemented.");
3617
+ }
3618
+ createScaleControl(t) {
3619
+ throw new Error("Method not implemented.");
3620
+ }
3621
+ }
3622
+ var $ = /* @__PURE__ */ ((i) => (i.google = "google", i.baidu = "baidu", i.here = "here", i))($ || {}), ze;
3623
+ ((i) => {
3624
+ function e(t, r, s) {
3625
+ const o = Le.create(s);
3626
+ switch (t) {
3627
+ case "google":
3628
+ return new Ar(r, o);
3629
+ case "baidu":
3630
+ return new $r(r, o);
3631
+ case "here":
3632
+ return new Rr(r, o);
3633
+ }
3634
+ }
3635
+ i.createMap = e;
3636
+ })(ze || (ze = {}));
3637
+ function Dr(i, e) {
3638
+ const t = window, r = Zr(i);
3639
+ if (t[r])
3640
+ return Promise.resolve();
3641
+ switch (i != $.here && !e.key && I(`请先配置${i}地图的key`), i) {
3642
+ case $.google:
3643
+ return vt(`https://maps.googleapis.com/maps/api/js?key=${e.key}&language=${e.language}`);
3644
+ case $.baidu:
3645
+ return vt(`https://api.map.baidu.com/api?v=${e.version}&ak=${e.key}`);
3646
+ case $.here:
3647
+ return oe(se("core", e.version)).then(() => Promise.all([
3648
+ // 其他大多数模块都可以同时载入
3649
+ oe(se("service", e.version)),
3650
+ oe(se("mapevents", e.version)),
3651
+ oe(se("clustering", e.version)),
3652
+ oe(se("ui", e.version))
3653
+ ])).catch((s) => (delete t[r], Promise.reject(s)));
3654
+ }
3655
+ }
3656
+ function se(i, e = be[0]) {
3657
+ return `https://js.api.here.com/v3/${e}/mapsjs-${i}.js`;
3658
+ }
3659
+ function Zr(i) {
3660
+ switch (i) {
3661
+ case $.google:
3662
+ return "google";
3663
+ case $.baidu:
3664
+ return "BMap";
3665
+ case $.here:
3666
+ return "H";
3667
+ }
3668
+ }
3669
+ let Gr = 0;
3670
+ function vt(i, e = "callback") {
3671
+ return new Promise((t, r) => {
3672
+ const s = `__callback${Gr++}`;
3673
+ window[s] = t;
3674
+ const o = document.createElement("script");
3675
+ o.src = `${i}&${e}=${s}`, o.onerror = r, document.body.appendChild(o);
3676
+ });
3677
+ }
3678
+ function oe(i) {
3679
+ return new Promise((e, t) => {
3680
+ const r = document.createElement("script");
3681
+ r.src = i, r.onload = e, r.onerror = t, document.body.appendChild(r);
3682
+ });
3683
+ }
3684
+ const jr = C({
3685
+ name: "tg-map",
3686
+ props: {
3687
+ /** type没做响应式, 但外部可以把type作为tg-map的key, 让type修改时完全重建tg-map */
3688
+ type: V($, $.google),
3689
+ /**
3690
+ * 当对该属性使用双向绑定时, 改变center将触发update:center又反过来触发center改变, 最终导致无限循环...
3691
+ * 当前通过setCenter()时判断center是否有改变来避免该问题, 但为了避免可能存在的问题, 另外设计了如下机制:
3692
+ * - :center-sync-delay="300": 延时同步center, 防止center的值更新过快
3693
+ * - :current-center.sync="currentCenter": 实时获取center的值
3694
+ * - :last-center.sync="center": 获取tg-map销毁时的最后的center的值, 使用这种方式可以做到type切换时保留中心点位置
3695
+ * @see AbstractMapEventMap.center-changed
3696
+ * */
3697
+ center: z(y),
3698
+ /**
3699
+ * 同步center的延时
3700
+ * @default 300
3701
+ * @see center
3702
+ */
3703
+ centerSyncDelay: m(Number, 300),
3704
+ /**
3705
+ * 仅用来获取center的值, 需要设置center的值请使用`center`属性
3706
+ * @see center
3707
+ * */
3708
+ currentCenter: m(y),
3709
+ /**
3710
+ * 仅用于获取tg-map销毁时的最后的center的值
3711
+ * @see center
3712
+ */
3713
+ lastCenter: m(y),
3714
+ zoom: z(Number),
3715
+ infoWindowMode: er(["single", "multi"]),
3716
+ gestureHandling: V(N),
3717
+ minZoom: m(Number),
3718
+ maxZoom: m(Number),
3719
+ mapStyle: m(Object),
3720
+ /** 设置为除BuildInMapTypeId以外的值时, 无实际效果... */
3721
+ mapTypeId: m(String),
3722
+ /** 优先级比mapTypeId高 */
3723
+ mapType: m(Object)
3724
+ },
3725
+ data() {
3726
+ return {
3727
+ map: void 0,
3728
+ isDestroyed: !1
3729
+ };
3730
+ },
3731
+ setup() {
3732
+ return {
3733
+ centerSyncTimeoutId: 0
3734
+ };
3735
+ },
3736
+ computed: {
3737
+ propsJson() {
3738
+ return le.toJsonSafely(this.$props);
3739
+ }
3740
+ },
3741
+ watch: {
3742
+ center(i) {
3743
+ this.map && (this.map.getCenter().equals(i) || (console.debug("<tg-map> setCenter", i), this.map.setCenter(i)));
3744
+ },
3745
+ zoom(i) {
3746
+ var e;
3747
+ (e = this.map) == null || e.setZoom(i);
3748
+ },
3749
+ gestureHandling(i) {
3750
+ var e;
3751
+ (e = this.map) == null || e.setGestureHandling(i);
3752
+ },
3753
+ minZoom(i) {
3754
+ var e;
3755
+ (e = this.map) == null || e.setMinZoom(i);
3756
+ },
3757
+ maxZoom(i) {
3758
+ var e;
3759
+ (e = this.map) == null || e.setMaxZoom(i);
3760
+ },
3761
+ mapStyle(i) {
3762
+ var e;
3763
+ (e = this.map) == null || e.setMapStyle(i);
3764
+ },
3765
+ mapTypeId(i) {
3766
+ if (this.map) {
3767
+ const e = ye.toEnumOrNull(i, $e);
3768
+ e && this.map.setBuildInMapTypeId(e);
3769
+ }
3770
+ },
3771
+ mapType(i) {
3772
+ var e;
3773
+ (e = this.map) == null || e.setMapType(i ?? k.NORMAL);
3774
+ }
3775
+ },
3776
+ provide() {
3777
+ return {
3778
+ [_t]: Ht(() => this.map)
3779
+ };
3780
+ },
3781
+ async created() {
3782
+ const { type: i } = this;
3783
+ try {
3784
+ await Dr(i, zt()[i]);
3785
+ } catch (s) {
3786
+ this.$emit("error", s);
3787
+ return;
3788
+ }
3789
+ if (this.isDestroyed) {
3790
+ console.warn(`tg-map(type=${i})已销毁, 不需要继续执行`);
3791
+ return;
3792
+ }
3793
+ const e = this.map = ze.createMap(
3794
+ i,
3795
+ this.$refs.map,
3796
+ /* options: */
3797
+ {
3798
+ center: this.center,
3799
+ zoom: this.zoom,
3800
+ infoWindowMode: this.infoWindowMode,
3801
+ gestureHandling: this.gestureHandling,
3802
+ minZoom: this.minZoom,
3803
+ maxZoom: this.maxZoom,
3804
+ mapStyle: this.mapStyle,
3805
+ // 若不能转换成BuildInMapTypeId, 则会设为undefined
3806
+ buildInMapTypeId: ye.toEnumOrNull(this.mapTypeId, $e)
3807
+ }
3808
+ );
3809
+ if (this.mapType && e.setMapType(this.mapType), "ready" in this.$listeners && console.error("地图载入完成的事件已经从ready改为了load, 请手动修改"), R.call(
3810
+ this,
3811
+ this.map,
3812
+ /* excludes: */
3813
+ ["load"]
3814
+ ), this.$emit("load", this.map), "update:center" in this.$listeners) {
3815
+ const s = () => this.$emit("update:center", e.getCenter());
3816
+ e.addEventListener("center-changed", () => {
3817
+ this.centerSyncDelay > 0 ? (clearTimeout(this.centerSyncTimeoutId), this.centerSyncTimeoutId = setTimeout(s, this.centerSyncDelay)) : s();
3818
+ });
3819
+ }
3820
+ "update:current-center" in this.$listeners && (this.$emit("update:current-center", this.center), e.addEventListener("center-changed", () => {
3821
+ this.$emit("update:current-center", e.getCenter());
3822
+ })), "update:zoom" in this.$listeners && e.addEventListener("zoom-changed", () => {
3823
+ this.$emit("update:zoom", e.getZoom());
3824
+ });
3825
+ const t = "update:map-type" in this.$listeners, r = "update:map-type-id" in this.$listeners;
3826
+ (t || r) && e.addEventListener("map-type-changed", () => {
3827
+ const s = e.getMapType();
3828
+ t && this.$emit("update:map-type", s), r && this.$emit("update:map-type-id", s.id);
3829
+ });
3830
+ },
3831
+ destroyed() {
3832
+ this.isDestroyed = !0, this.map && ("update:last-center" in this.$listeners && this.$emit("update:last-center", this.map.getCenter()), "update:center" in this.$listeners && (clearTimeout(this.centerSyncTimeoutId), this.$emit("update:center", this.map.getCenter())));
3833
+ },
3834
+ methods: {}
3835
+ });
3836
+ const G = (i, e) => {
3837
+ const t = i.__vccOpts || i;
3838
+ for (const [r, s] of e)
3839
+ t[r] = s;
3840
+ return t;
3841
+ }, Wr = { class: "tg-map" }, Vr = {
3842
+ ref: "map",
3843
+ class: "tg-map__map"
3844
+ };
3845
+ function Hr(i, e, t, r, s, o) {
3846
+ return D(), Z("div", Wr, [
3847
+ Ft("div", Vr, null, 512),
3848
+ dt("", !0),
3849
+ i.map ? A(i.$slots, "default", { key: 1 }) : dt("", !0),
3850
+ A(i.$slots, "overlay")
3851
+ ]);
3852
+ }
3853
+ const Nt = /* @__PURE__ */ G(jr, [["render", Hr]]);
3854
+ function Fr(i) {
3855
+ if (i == null)
3856
+ return null;
3857
+ let e;
3858
+ if (typeof i == "string") {
3859
+ if (e = +i, Number.isNaN(e))
3860
+ return i;
3861
+ } else
3862
+ e = i;
3863
+ return `${e}px`;
3864
+ }
3865
+ const Ur = C({
3866
+ name: "tg-map-widget",
3867
+ props: {
3868
+ left: {
3869
+ type: [Number, String],
3870
+ default: null
3871
+ },
3872
+ top: {
3873
+ type: [Number, String],
3874
+ default: null
3875
+ },
3876
+ right: {
3877
+ type: [Number, String],
3878
+ default: null
3879
+ },
3880
+ bottom: {
3881
+ type: [Number, String],
3882
+ default: null
3883
+ }
3884
+ },
3885
+ computed: {
3886
+ topValue() {
3887
+ return this.top == null && this.bottom == null ? 0 : this.top;
3888
+ }
3889
+ },
3890
+ methods: {
3891
+ dimen: Fr
3892
+ }
3893
+ });
3894
+ function Yr(i, e, t, r, s, o) {
3895
+ return D(), Z("div", {
3896
+ class: q(i.$options.name),
3897
+ style: Ut({ left: i.dimen(i.left), top: i.dimen(i.topValue), right: i.dimen(i.right), bottom: i.dimen(i.bottom) })
3898
+ }, [
3899
+ A(i.$slots, "default")
3900
+ ], 6);
3901
+ }
3902
+ const Kr = /* @__PURE__ */ G(Ur, [["render", Yr]]), qr = C({
3903
+ name: "tg-custom-control",
3904
+ mixins: [w],
3905
+ props: {
3906
+ position: V(x, x.RIGHT_BOTTOM)
3907
+ },
3908
+ setup() {
3909
+ return {
3910
+ control: void 0
3911
+ };
3912
+ },
3913
+ watch: {
3914
+ position() {
3915
+ this.recreate();
3916
+ }
3917
+ },
3918
+ onCreate() {
3919
+ re(this.$parent, Nt) || console.warn("请将tg-custom-control放到tg-map中");
3920
+ const { $el: i } = this, e = class extends kr {
3921
+ onCreateElement() {
3922
+ return i;
3923
+ }
3924
+ };
3925
+ this.control = new e(this.position), this.$map.addCustomControl(this.control);
3926
+ },
3927
+ onDestroy() {
3928
+ this.$map.removeCustomControl(this.control);
3929
+ }
3930
+ });
3931
+ function Xr(i, e, t, r, s, o) {
3932
+ return D(), Z("div", {
3933
+ class: q(i.$options.name)
3934
+ }, [
3935
+ A(i.$slots, "default")
3936
+ ], 2);
3937
+ }
3938
+ const Jr = /* @__PURE__ */ G(qr, [["render", Xr]]), Qr = C({
3939
+ name: "tg-map-type-control",
3940
+ mixins: [w],
3941
+ props: {
3942
+ position: V(x, x.TOP_LEFT),
3943
+ type: V(Bt),
3944
+ mapTypes: m(Array)
3945
+ },
3946
+ setup() {
3947
+ return {
3948
+ control: void 0
3949
+ };
3950
+ },
3951
+ watch: {
3952
+ position(i) {
3953
+ this.control.setPosition(i);
3954
+ },
3955
+ type() {
3956
+ this.recreate();
3957
+ },
3958
+ mapTypes() {
3959
+ this.recreate();
3960
+ }
3961
+ },
3962
+ onCreate() {
3963
+ this.control = this.$map.createMapTypeControl(this), this.$map.addControl(this.control);
3964
+ },
3965
+ onDestroy() {
3966
+ this.$map.removeControl(this.control);
3967
+ }
3968
+ }), ei = C({
3969
+ name: "tg-scale-control",
3970
+ mixins: [w],
3971
+ props: {
3972
+ position: V(x, x.BOTTOM_RIGHT)
3973
+ },
3974
+ setup() {
3975
+ return {
3976
+ control: void 0
3977
+ };
3978
+ },
3979
+ watch: {
3980
+ position(i) {
3981
+ this.control.setPosition(i);
3982
+ }
3983
+ },
3984
+ onCreate() {
3985
+ this.control = this.$map.createScaleControl(this), this.$map.addControl(this.control);
3986
+ },
3987
+ onDestroy() {
3988
+ this.$map.removeControl(this.control);
3989
+ }
3990
+ }), ti = C({
3991
+ name: "tg-zoom-control",
3992
+ mixins: [w],
3993
+ props: {
3994
+ position: V(x, x.RIGHT_BOTTOM)
3995
+ },
3996
+ setup() {
3997
+ return {
3998
+ control: void 0
3999
+ };
4000
+ },
4001
+ watch: {
4002
+ position(i) {
4003
+ this.control.setPosition(i);
4004
+ }
4005
+ },
4006
+ onCreate() {
4007
+ this.control = this.$map.createZoomControl(this), this.$map.addControl(this.control);
4008
+ },
4009
+ onDestroy() {
4010
+ this.$map.removeControl(this.control);
4011
+ }
4012
+ }), ri = C({
4013
+ name: "tg-label",
4014
+ mixins: [w],
4015
+ props: {
4016
+ position: m(y),
4017
+ offset: m(Object),
4018
+ zIndex: m(Number)
4019
+ },
4020
+ setup() {
4021
+ return {
4022
+ overlay: void 0
4023
+ };
4024
+ },
4025
+ methods: {
4026
+ content() {
4027
+ return this.$el;
4028
+ },
4029
+ marker() {
4030
+ var i;
4031
+ return (i = this.$marker()) == null ? void 0 : i.marker;
4032
+ },
4033
+ $marker() {
4034
+ return re(this.$parent, de);
4035
+ },
4036
+ getOptions() {
4037
+ return {
4038
+ content: this.content(),
4039
+ position: this.position,
4040
+ offset: this.offset,
4041
+ zIndex: this.zIndex
4042
+ };
4043
+ }
4044
+ },
4045
+ watch: {
4046
+ position(i) {
4047
+ this.overlay.setPosition(i);
4048
+ },
4049
+ offset(i) {
4050
+ this.overlay.setOffset(i);
4051
+ },
4052
+ zIndex(i) {
4053
+ this.overlay.setZIndex(i);
4054
+ },
4055
+ visible(i) {
4056
+ this.overlay.setVisible(i);
4057
+ }
4058
+ },
4059
+ onCreate() {
4060
+ this.overlay = this.$map.createLabel(this.getOptions()), R.call(this, this.overlay), this.$marker() ? this.$marker().onAddLabel(this.overlay) : this.$map.addOverlay(this.overlay), R.call(this, this.overlay);
4061
+ },
4062
+ onDestroy() {
4063
+ this.$marker() ? this.$marker().onRemoveLabel(this.overlay) : this.$map.removeOverlay(this.overlay);
4064
+ }
4065
+ });
4066
+ function ii(i, e, t, r, s, o) {
4067
+ return D(), Z("div", {
4068
+ class: q(i.$options.name)
4069
+ }, [
4070
+ A(i.$slots, "default")
4071
+ ], 2);
4072
+ }
4073
+ const Rt = /* @__PURE__ */ G(ri, [["render", ii]]), si = C({
4074
+ name: "tg-info-window",
4075
+ mixins: [w],
4076
+ model: {
4077
+ prop: "show",
4078
+ event: "update:show"
4079
+ },
4080
+ props: {
4081
+ show: z(Boolean),
4082
+ position: m(y),
4083
+ maxWidth: m(Number),
4084
+ offset: m(Object),
4085
+ disableAutoPan: m(Boolean)
4086
+ },
4087
+ setup() {
4088
+ return {
4089
+ overlay: void 0
4090
+ };
4091
+ },
4092
+ methods: {
4093
+ content() {
4094
+ return this.$el;
4095
+ },
4096
+ $marker() {
4097
+ return re(this.$parent, de);
4098
+ },
4099
+ getOptions() {
4100
+ return {
4101
+ content: this.content(),
4102
+ position: this.position,
4103
+ maxWidth: this.maxWidth,
4104
+ offset: this.offset,
4105
+ disableAutoPan: this.disableAutoPan
4106
+ };
4107
+ }
4108
+ },
4109
+ watch: {
4110
+ show(i) {
4111
+ this.$marker() ? this.$marker().onInfoShowChanged(this, i) : i ? this.overlay.open() : this.overlay.close();
4112
+ },
4113
+ position(i) {
4114
+ this.overlay.setPosition(i);
4115
+ },
4116
+ maxWidth() {
4117
+ this.recreate();
4118
+ },
4119
+ offset() {
4120
+ this.recreate();
4121
+ },
4122
+ disableAutoPan() {
4123
+ this.recreate();
4124
+ }
4125
+ },
4126
+ onCreate() {
4127
+ this.overlay = this.$map.createInfoWindow(this.getOptions()), this.$marker() ? this.$marker().onAddInfo(this) : this.show && this.overlay.open(), this.overlay.addEventListener("open", () => {
4128
+ this.$emit("update:show", !0);
4129
+ }), this.overlay.addEventListener("close", () => {
4130
+ this.$emit("update:show", !1);
4131
+ }), R.call(this, this.overlay);
4132
+ },
4133
+ onDestroy() {
4134
+ this.$marker() ? this.$marker().onRemoveInfo(this) : this.overlay.close();
4135
+ }
4136
+ });
4137
+ function oi(i, e, t, r, s, o) {
4138
+ return Yt((D(), Z("div", {
4139
+ class: q(i.$options.name)
4140
+ }, [
4141
+ A(i.$slots, "default")
4142
+ ], 2)), [
4143
+ [Kt, i.show]
4144
+ ]);
4145
+ }
4146
+ const Dt = /* @__PURE__ */ G(si, [["render", oi]]), ni = C({
4147
+ name: "tg-info-box",
4148
+ mixins: [w],
4149
+ model: {
4150
+ prop: "show",
4151
+ event: "update:show"
4152
+ },
4153
+ props: {
4154
+ show: z(Boolean),
4155
+ position: m(y),
4156
+ offset: m(Object),
4157
+ maxWidth: m(Number),
4158
+ borderClass: m(String),
4159
+ zIndex: m(Number)
4160
+ },
4161
+ setup() {
4162
+ return {
4163
+ overlay: void 0
4164
+ };
4165
+ },
4166
+ watch: {
4167
+ show(i) {
4168
+ this.$marker() ? this.$marker().onInfoShowChanged(this, i) : i ? this.overlay.open() : this.overlay.close();
4169
+ },
4170
+ position(i) {
4171
+ this.overlay.setPosition(i);
4172
+ },
4173
+ offset() {
4174
+ this.recreate();
4175
+ },
4176
+ maxWidth(i) {
4177
+ this.overlay.setMaxWidth(i);
4178
+ },
4179
+ borderClass() {
4180
+ this.recreate();
4181
+ },
4182
+ zIndex(i) {
4183
+ this.overlay.setZIndex(i);
4184
+ }
4185
+ },
4186
+ onCreate() {
4187
+ this.overlay = this.$map.createInfoBox(this.getOptions()), this.$marker() ? this.$marker().onAddInfo(this) : this.show && this.overlay.open(), "update:show" in this.$listeners && this.overlay.addEventListener("closeclick", () => {
4188
+ this.$emit("update:show", !1);
4189
+ }), R.call(this, this.overlay);
4190
+ },
4191
+ onDestroy() {
4192
+ this.$marker() ? this.$marker().onRemoveInfo(this) : this.overlay.close();
4193
+ },
4194
+ methods: {
4195
+ getOptions() {
4196
+ return {
4197
+ content: this.content(),
4198
+ position: this.position,
4199
+ offset: this.offset,
4200
+ zIndex: this.zIndex,
4201
+ maxWidth: this.maxWidth,
4202
+ borderClass: this.borderClass
4203
+ };
4204
+ },
4205
+ content() {
4206
+ return this.$el;
4207
+ },
4208
+ $marker() {
4209
+ return re(this.$parent, de);
4210
+ },
4211
+ open(i) {
4212
+ this.overlay.open(i);
4213
+ },
4214
+ close() {
4215
+ this.overlay.close();
4216
+ }
4217
+ }
4218
+ });
4219
+ function ai(i, e, t, r, s, o) {
4220
+ return D(), Z("div", {
4221
+ class: q(i.$options.name)
4222
+ }, [
4223
+ A(i.$slots, "default")
4224
+ ], 2);
4225
+ }
4226
+ const Zt = /* @__PURE__ */ G(ni, [["render", ai]]), li = C({
4227
+ name: "tg-marker",
4228
+ mixins: [w],
4229
+ props: {
4230
+ position: z(y),
4231
+ title: m(String),
4232
+ icon: m(Object),
4233
+ clickable: m(Boolean),
4234
+ draggable: m(Boolean),
4235
+ crossOnDrag: m(Boolean),
4236
+ cursor: m(String),
4237
+ zIndex: m(Number),
4238
+ visible: m(Boolean)
4239
+ },
4240
+ setup() {
4241
+ return {
4242
+ marker: void 0
4243
+ };
4244
+ },
4245
+ watch: {
4246
+ position(i) {
4247
+ this.marker.setPosition(i);
4248
+ },
4249
+ title(i) {
4250
+ this.marker.setTitle(i);
4251
+ },
4252
+ icon(i) {
4253
+ i ? this.marker.setIcon(i) : this.recreate();
4254
+ },
4255
+ clickable(i) {
4256
+ this.marker instanceof he ? this.recreate() : this.marker.setClickable(i);
4257
+ },
4258
+ draggable(i) {
4259
+ this.marker.setDraggable(i);
4260
+ },
4261
+ crossOnDrag() {
4262
+ this.recreate();
4263
+ },
4264
+ cursor() {
4265
+ this.recreate();
4266
+ },
4267
+ zIndex(i) {
4268
+ this.marker instanceof he ? this.recreate() : this.marker.setZIndex(i);
4269
+ },
4270
+ visible(i) {
4271
+ this.marker.setVisible(i);
4272
+ }
4273
+ },
4274
+ onCreate() {
4275
+ const i = we(this.$children, Rt), e = we(this.$children, Zt), t = we(this.$children, Dt);
4276
+ this.marker = this.$map.createMarker(this), i && this.marker.setLabel(i.overlay), e && e.show && e.overlay.open(this.marker), this.$clusterer() ? this.$clusterer().onAddMarker(this.marker) : this.$map.addOverlay(this.marker), t && t.show && t.overlay.open(this.marker), R.call(this, this.marker);
4277
+ },
4278
+ onDestroy() {
4279
+ this.$clusterer() ? this.$clusterer().onRemoveMarker(this.marker) : this.$map.removeOverlay(this.marker);
4280
+ },
4281
+ methods: {
4282
+ $clusterer() {
4283
+ return re(this.$parent, Gt);
4284
+ },
4285
+ onAddLabel(i) {
4286
+ this.marker && this.marker.setLabel(i);
4287
+ },
4288
+ onRemoveLabel(i) {
4289
+ this.marker.setLabel(void 0);
4290
+ },
4291
+ onAddInfo(i) {
4292
+ this.marker && i.show && i.overlay.open(this.marker);
4293
+ },
4294
+ onRemoveInfo(i) {
4295
+ i.overlay.close();
4296
+ },
4297
+ onInfoShowChanged(i, e) {
4298
+ e ? i.overlay.open(this.marker) : i.overlay.close();
4299
+ }
4300
+ }
4301
+ });
4302
+ function hi(i, e, t, r, s, o) {
4303
+ return D(), Z("div", {
4304
+ class: q(i.$options.name)
4305
+ }, [
4306
+ A(i.$slots, "default")
4307
+ ], 2);
4308
+ }
4309
+ const de = /* @__PURE__ */ G(li, [["render", hi]]), ci = C({
4310
+ name: "tg-marker-clusterer",
4311
+ mixins: [w],
4312
+ // markers从this.$children中读取, 故需要省略(Omit)
4313
+ props: {
4314
+ gridSize: m(Number),
4315
+ maxZoom: m(Number),
4316
+ minClusterSize: m(Number),
4317
+ averageCenter: m(Boolean),
4318
+ styles: m(Array),
4319
+ stylesIndexCalculator: m(Function),
4320
+ zIndex: m(Number)
4321
+ },
4322
+ setup() {
4323
+ return {
4324
+ clusterer: void 0
4325
+ };
4326
+ },
4327
+ watch: {
4328
+ gridSize() {
4329
+ this.recreate();
4330
+ },
4331
+ maxZoom() {
4332
+ this.recreate();
4333
+ },
4334
+ minClusterSize() {
4335
+ this.recreate();
4336
+ },
4337
+ averageCenter() {
4338
+ this.recreate();
4339
+ },
4340
+ styles() {
4341
+ this.recreate();
4342
+ },
4343
+ stylesIndexCalculator() {
4344
+ this.recreate();
4345
+ },
4346
+ zIndex() {
4347
+ this.recreate();
4348
+ }
4349
+ },
4350
+ onCreate() {
4351
+ this.clusterer = this.$map.createMarkerClusterer(this.getOptions());
4352
+ },
4353
+ onDestroy() {
4354
+ this.clusterer.clearMarkers();
4355
+ },
4356
+ methods: {
4357
+ getOptions() {
4358
+ return {
4359
+ markers: this.markers(),
4360
+ gridSize: this.gridSize,
4361
+ maxZoom: this.maxZoom,
4362
+ minClusterSize: this.minClusterSize,
4363
+ averageCenter: this.averageCenter,
4364
+ styles: this.styles,
4365
+ stylesIndexCalculator: this.stylesIndexCalculator,
4366
+ zIndex: this.zIndex
4367
+ };
4368
+ },
4369
+ /** TgMarker有可能在该组件未初始化之前调用, 需要通过该方法判断 */
4370
+ isInitiated() {
4371
+ return this.clusterer != null;
4372
+ },
4373
+ markers() {
4374
+ return this.$children.map((e) => re(e, de)).filter(Qt).map((e) => e.marker);
4375
+ },
4376
+ onAddMarker(i) {
4377
+ this.isInitiated() && this.clusterer.addMarker(i);
4378
+ },
4379
+ onRemoveMarker(i) {
4380
+ this.isInitiated() && this.clusterer.removeMarker(i);
4381
+ }
4382
+ }
4383
+ });
4384
+ function di(i, e, t, r, s, o) {
4385
+ return D(), Z("div", {
4386
+ class: q(i.$options.name)
4387
+ }, [
4388
+ A(i.$slots, "default")
4389
+ ], 2);
4390
+ }
4391
+ const Gt = /* @__PURE__ */ G(ci, [["render", di]]), pi = C({
4392
+ name: "tg-traffic-layer",
4393
+ mixins: [w],
4394
+ props: {
4395
+ // 请直接使用v-if来控制它的显隐
4396
+ },
4397
+ setup() {
4398
+ return {
4399
+ layer: void 0
4400
+ };
4401
+ },
4402
+ watch: {},
4403
+ onCreate() {
4404
+ this.layer = new Ir(), this.$map.addLayer(this.layer);
4405
+ },
4406
+ onDestroy() {
4407
+ this.$map.removeLayer(this.layer);
4408
+ }
4409
+ }), ui = C({
4410
+ name: "tg-circle",
4411
+ mixins: [w],
4412
+ props: {
4413
+ center: z(y),
4414
+ radius: z(Number),
4415
+ clickable: m(Boolean),
4416
+ editable: m(Boolean),
4417
+ strokeColor: m(String),
4418
+ strokeOpacity: m(Number),
4419
+ strokeWeight: m(Number),
4420
+ visible: m(Boolean),
4421
+ fillColor: m(String),
4422
+ fillOpacity: m(Number)
4423
+ },
4424
+ setup() {
4425
+ return {
4426
+ overlay: void 0
4427
+ };
4428
+ },
4429
+ watch: {
4430
+ center(i) {
4431
+ this.overlay.setCenter(i);
4432
+ },
4433
+ radius(i) {
4434
+ this.overlay.setRadius(i);
4435
+ },
4436
+ clickable() {
4437
+ this.recreate();
4438
+ },
4439
+ editable(i) {
4440
+ this.overlay.setEditable(i);
4441
+ },
4442
+ strokeColor(i) {
4443
+ this.overlay.setStrokeColor(i);
4444
+ },
4445
+ strokeOpacity(i) {
4446
+ this.overlay.setStrokeOpacity(i);
4447
+ },
4448
+ strokeWeight(i) {
4449
+ this.overlay.setStrokeWeight(i);
4450
+ },
4451
+ fillColor(i) {
4452
+ this.overlay.setFillColor(i);
4453
+ },
4454
+ fillOpacity(i) {
4455
+ this.overlay.setFillOpacity(i);
4456
+ },
4457
+ visible(i) {
4458
+ this.overlay.setVisible(i);
4459
+ }
4460
+ },
4461
+ onCreate() {
4462
+ this.overlay = this.$map.createCircle(this), this.$map.addOverlay(this.overlay), R.call(this, this.overlay);
4463
+ },
4464
+ onDestroy() {
4465
+ this.$map.removeOverlay(this.overlay);
4466
+ }
4467
+ });
4468
+ var Ne = /* @__PURE__ */ ((i) => (i.map = "map", i.overlay = "overlay", i.overlayMouseTarget = "overlayMouseTarget", i.float = "float", i))(Ne || {});
4469
+ class gi {
4470
+ constructor(e, t) {
4471
+ h(this, "baidu");
4472
+ h(this, "google");
4473
+ h(this, "projection");
4474
+ h(this, "element", void 0);
4475
+ h(this, "mapPane");
4476
+ this.map = e, this.mapPane = t.mapPane;
4477
+ }
4478
+ create() {
4479
+ return this.element = this.onCreate(), this.element.className += " element-overlay", this.element;
4480
+ }
4481
+ draw() {
4482
+ this.projection && this.onDraw(this.projection);
4483
+ }
4484
+ getProjection() {
4485
+ return this.projection;
4486
+ }
4487
+ asBaidu() {
4488
+ if (!this.baidu) {
4489
+ const e = this;
4490
+ $t();
4491
+ class t extends BMap.OverlayV3 {
4492
+ initialize(o) {
4493
+ const a = e.create(), g = o.getPanes();
4494
+ let n;
4495
+ switch (e.mapPane) {
4496
+ case "float":
4497
+ n = g.floatPane;
4498
+ break;
4499
+ case "overlayMouseTarget":
4500
+ n = g.markerMouseTarget;
4501
+ break;
4502
+ case "overlay":
4503
+ n = g.markerPane;
4504
+ break;
4505
+ case "map":
4506
+ n = g.mapPane;
4507
+ break;
4508
+ default:
4509
+ pt(e.mapPane);
4510
+ break;
4511
+ }
4512
+ return n == null || n.appendChild(a), a;
4513
+ }
4514
+ draw() {
4515
+ e.draw();
4516
+ }
4517
+ }
4518
+ this.baidu = new t();
4519
+ const r = e.map.innerMap;
4520
+ this.projection = {
4521
+ fromLatLngToOverlayPoint(s) {
4522
+ return r.pointToOverlayPixel(s.toBaidu(e.map.coordType));
4523
+ },
4524
+ fromOverlayPointToLatLng(s) {
4525
+ return y.fromBaidu(r.overlayPixelToPoint(new BMap.Pixel(s.x, s.y)), e.map.coordType);
4526
+ }
4527
+ };
4528
+ }
4529
+ return this.baidu;
4530
+ }
4531
+ asGoogle() {
4532
+ if (!this.google) {
4533
+ const e = this;
4534
+ class t extends google.maps.OverlayView {
4535
+ onAdd() {
4536
+ const s = e.create(), o = this.getPanes();
4537
+ let a;
4538
+ switch (e.mapPane) {
4539
+ case "float":
4540
+ a = o.floatPane;
4541
+ break;
4542
+ case "overlayMouseTarget":
4543
+ a = o.overlayMouseTarget;
4544
+ break;
4545
+ case "overlay":
4546
+ a = o.overlayLayer;
4547
+ break;
4548
+ case "map":
4549
+ a = o.mapPane;
4550
+ break;
4551
+ default:
4552
+ pt(e.mapPane);
4553
+ break;
4554
+ }
4555
+ a.appendChild(s);
4556
+ }
4557
+ draw() {
4558
+ e.draw();
4559
+ }
4560
+ onRemove() {
4561
+ var s;
4562
+ (s = e.element.parentNode) == null || s.removeChild(e.element);
4563
+ }
4564
+ }
4565
+ this.google = new t(), this.projection = {
4566
+ fromLatLngToOverlayPoint(r) {
4567
+ return e.google.getProjection().fromLatLngToDivPixel(r.toGoogle(e.map.coordType));
4568
+ },
4569
+ fromOverlayPointToLatLng(r) {
4570
+ return y.fromGoogle(e.google.getProjection().fromDivPixelToLatLng(new google.maps.Point(r.x, r.y)), e.map.coordType);
4571
+ }
4572
+ };
4573
+ }
4574
+ return this.google;
4575
+ }
4576
+ }
4577
+ class mi extends gi {
4578
+ constructor(e, t, r, s) {
4579
+ super(e, t), this.content = r, this.position = s;
4580
+ }
4581
+ onCreate() {
4582
+ return this.content;
4583
+ }
4584
+ onDraw(e) {
4585
+ const t = e.fromLatLngToOverlayPoint(this.position);
4586
+ this.content.style.left = t.x + "px", this.content.style.top = t.y + "px";
4587
+ }
4588
+ setPosition(e) {
4589
+ this.position = e, this.draw();
4590
+ }
4591
+ }
4592
+ const fi = C({
4593
+ name: "tg-element-overlay",
4594
+ mixins: [w],
4595
+ props: {
4596
+ mapPane: V(Ne, Ne.overlayMouseTarget),
4597
+ position: z(y)
4598
+ },
4599
+ setup() {
4600
+ return {
4601
+ overlay: void 0
4602
+ };
4603
+ },
4604
+ methods: {
4605
+ content() {
4606
+ return this.$el;
4607
+ }
4608
+ },
4609
+ watch: {
4610
+ position(i) {
4611
+ this.overlay.setPosition(i);
4612
+ },
4613
+ mapPane() {
4614
+ this.recreate();
4615
+ }
4616
+ },
4617
+ onCreate() {
4618
+ this.overlay = new mi(this.$map, this, this.content(), this.position), this.$map.addElementOverlay(this.overlay);
4619
+ },
4620
+ onDestroy() {
4621
+ this.$map.removeElementOverlay(this.overlay);
4622
+ }
4623
+ });
4624
+ function yi(i, e, t, r, s, o) {
4625
+ return D(), Z("div", qt({
4626
+ class: i.$options.name
4627
+ }, Xt(i.$listeners, !0)), [
4628
+ A(i.$slots, "default")
4629
+ ], 16);
4630
+ }
4631
+ const vi = /* @__PURE__ */ G(fi, [["render", yi]]), _i = C({
4632
+ name: "tg-polygon",
4633
+ mixins: [w],
4634
+ props: {
4635
+ paths: z(Array),
4636
+ clickable: m(Boolean),
4637
+ editable: m(Boolean),
4638
+ strokeColor: m(String),
4639
+ strokeOpacity: m(Number),
4640
+ strokeWeight: m(Number),
4641
+ visible: m(Boolean),
4642
+ fillColor: m(String),
4643
+ fillOpacity: m(Number)
4644
+ },
4645
+ setup() {
4646
+ return {
4647
+ polygon: void 0
4648
+ };
4649
+ },
4650
+ watch: {
4651
+ paths(i) {
4652
+ this.polygon.setPaths(i);
4653
+ },
4654
+ clickable() {
4655
+ this.recreate();
4656
+ },
4657
+ editable(i) {
4658
+ this.polygon.setEditable(i);
4659
+ },
4660
+ strokeColor(i) {
4661
+ this.polygon.setStrokeColor(i);
4662
+ },
4663
+ strokeOpacity(i) {
4664
+ this.polygon.setStrokeOpacity(i);
4665
+ },
4666
+ strokeWeight(i) {
4667
+ this.polygon.setStrokeWeight(i);
4668
+ },
4669
+ fillColor(i) {
4670
+ this.polygon.setFillColor(i);
4671
+ },
4672
+ fillOpacity(i) {
4673
+ this.polygon.setFillOpacity(i);
4674
+ },
4675
+ visible(i) {
4676
+ this.polygon.setVisible(i);
4677
+ }
4678
+ },
4679
+ onCreate() {
4680
+ this.polygon = this.$map.createPolygon(this), this.$map.addOverlay(this.polygon), R.call(this, this.polygon);
4681
+ },
4682
+ onDestroy() {
4683
+ this.$map.removeOverlay(this.polygon);
4684
+ }
4685
+ }), Mi = C({
4686
+ name: "tg-polyline",
4687
+ mixins: [w],
4688
+ props: {
4689
+ path: z(Array),
4690
+ clickable: m(Boolean),
4691
+ editable: m(Boolean),
4692
+ strokeColor: m(String),
4693
+ strokeOpacity: m(Number),
4694
+ strokeWeight: m(Number),
4695
+ visible: m(Boolean)
4696
+ },
4697
+ setup() {
4698
+ return {
4699
+ polyline: void 0
4700
+ };
4701
+ },
4702
+ watch: {
4703
+ path(i) {
4704
+ this.polyline.setPath(i);
4705
+ },
4706
+ clickable() {
4707
+ this.recreate();
4708
+ },
4709
+ editable(i) {
4710
+ this.polyline.setEditable(i);
4711
+ },
4712
+ strokeColor(i) {
4713
+ this.polyline.setStrokeColor(i);
4714
+ },
4715
+ strokeOpacity(i) {
4716
+ this.polyline.setStrokeOpacity(i);
4717
+ },
4718
+ strokeWeight(i) {
4719
+ this.polyline.setStrokeWeight(i);
4720
+ },
4721
+ visible(i) {
4722
+ this.polyline.setVisible(i);
4723
+ }
4724
+ },
4725
+ onCreate() {
4726
+ this.polyline = this.$map.createPolyline(this), this.$map.addOverlay(this.polyline), R.call(this, this.polyline);
4727
+ },
4728
+ onDestroy() {
4729
+ this.$map.removeOverlay(this.polyline);
4730
+ }
4731
+ }), bi = ["beforeUpdate", "updated"], Ai = {
4732
+ install(i, e = {}) {
4733
+ if (e.enable !== !1) {
4734
+ const t = C({
4735
+ methods: {
4736
+ __life(r) {
4737
+ this.__life_impl(r);
4738
+ }
4739
+ },
4740
+ beforeCreate() {
4741
+ const r = this.$options.name || this.$options._componentTag || "", o = (e.nameRegex || /^[A-Z]/).test(r) ? (a) => {
4742
+ e.hookNames ? e.hookNames.includes(a) && console.debug("[lifecycle]", r, a) : bi.includes(a) || console.debug("[lifecycle]", r, a);
4743
+ } : fe;
4744
+ o("beforeCreate"), this.__life_impl = o;
4745
+ },
4746
+ created() {
4747
+ this.__life("created");
4748
+ },
4749
+ beforeMount() {
4750
+ this.__life("beforeMount");
4751
+ },
4752
+ mounted() {
4753
+ this.__life("mounted");
4754
+ },
4755
+ onCreate() {
4756
+ this.__life("onCreate");
4757
+ },
4758
+ onDestroy() {
4759
+ this.__life("onDestroy");
4760
+ },
4761
+ beforeUpdate() {
4762
+ this.__life("beforeUpdate");
4763
+ },
4764
+ updated() {
4765
+ this.__life("updated");
4766
+ },
4767
+ beforeDestroy() {
4768
+ this.__life("beforeDestroy");
4769
+ },
4770
+ destroyed() {
4771
+ this.__life("destroyed");
4772
+ }
4773
+ });
4774
+ i.mixin(t);
4775
+ }
4776
+ }
4777
+ }, zi = {
4778
+ install(i, e) {
4779
+ Nr(e);
4780
+ const t = /* @__PURE__ */ Object.assign({ "./TgMap.vue": Nt, "./TgMapWidget.vue": Kr, "./controls/TgCustomControl.vue": Jr, "./controls/TgMapTypeControl.vue": Qr, "./controls/TgScaleControl.vue": ei, "./controls/TgZoomControl.vue": ti, "./extra/TgMarkerClusterer.vue": Gt, "./layers/TgTrafficLayer.vue": pi, "./overlays/TgCircle.vue": ui, "./overlays/TgElementOverlay.vue": vi, "./overlays/TgInfoBox.vue": Zt, "./overlays/TgInfoWindow.vue": Dt, "./overlays/TgLabel.vue": Rt, "./overlays/TgMarker.vue": de, "./overlays/TgPolygon.vue": _i, "./overlays/TgPolyline.vue": Mi });
4781
+ Object.keys(t).forEach((s) => {
4782
+ var a;
4783
+ const o = t[s];
4784
+ i.component(((a = o.options) == null ? void 0 : a.name) ?? o.name, o);
4785
+ });
4786
+ const r = i.config.optionMergeStrategies;
4787
+ r[Ie] = r[Pe] = r.created;
4788
+ }
4789
+ };
4790
+ export {
4791
+ Lt as AbstractControl,
4792
+ Re as AbstractMap,
4793
+ Se as Arrays,
4794
+ Ue as BaiduCircle,
4795
+ Ke as BaiduControl,
4796
+ lt as BaiduInfoBoxOverlay,
4797
+ st as BaiduInfoWindow,
4798
+ Xe as BaiduMapTypeControl,
4799
+ he as BaiduMarker,
4800
+ Tr as BaiduMarkerClusterer,
4801
+ Oe as BaiduOverlay,
4802
+ He as BaiduPolygon,
4803
+ We as BaiduPolyline,
4804
+ et as BaiduScaleControl,
4805
+ Je as BaiduZoomControl,
4806
+ yt as CachedValue,
4807
+ x as ControlPosition,
4808
+ P as ControlPositionConverter,
4809
+ Y as CoordType,
4810
+ kr as CustomControl,
4811
+ Er as FastFindValues,
4812
+ Ye as GoogleCircle,
4813
+ qe as GoogleControl,
4814
+ ht as GoogleInfoBoxOverlay,
4815
+ ot as GoogleInfoWindow,
4816
+ me as GoogleMapTypeControl,
4817
+ rt as GoogleMarker,
4818
+ Or as GoogleMarkerClusterer,
4819
+ Ze as GoogleOverlay,
4820
+ Fe as GooglePolygon,
4821
+ Ve as GooglePolyline,
4822
+ tt as GoogleScaleControl,
4823
+ Qe as GoogleZoomControl,
4824
+ ee as Icon,
4825
+ it as InfoWindow,
4826
+ ft as KeyValue,
4827
+ y as LatLng,
4828
+ W as LatLngBounds,
4829
+ Ai as LifecycleLogPlugin,
4830
+ Ie as MIXIN_HOOK_CREATE,
4831
+ Pe as MIXIN_HOOK_DESTROY,
4832
+ _t as MIXIN_MAP_NAME,
4833
+ Me as MVCArrays,
4834
+ w as MapMixin,
4835
+ Bt as MapTypeControlType,
4836
+ kt as MarkerClusterer,
4837
+ le as Objects,
4838
+ Pt as Overlay,
4839
+ ce as Point,
4840
+ ye as Strings,
4841
+ Zt as TgInfoBox,
4842
+ Nt as TgMap,
4843
+ ze as TgMapFactory,
4844
+ $ as TgMapType,
4845
+ ue as callHook,
4846
+ xi as computedSaveOnThis,
4847
+ rr as createEmptyVNode,
4848
+ tr as createPropertyObject,
4849
+ Ei as createPropertyObjectTyped,
4850
+ wi as debug,
4851
+ zi as default,
4852
+ ki as eventLogMethods,
4853
+ we as findByComponentType,
4854
+ zt as getTgMapConfig,
4855
+ Qt as isDef,
4856
+ Li as isInstanceOf,
4857
+ Ii as lateinit,
4858
+ fe as noop,
4859
+ m as optionalProp,
4860
+ z as requiredProp,
4861
+ Bi as safeAs,
4862
+ re as safeAsComponent,
4863
+ Nr as setTgMapConfig,
4864
+ V as stringEnumProp,
4865
+ er as stringEnumPropFromArray,
4866
+ I as throwError,
4867
+ Jt as throwUnsupported,
4868
+ Ci as todo,
4869
+ Pi as typed
4870
+ };
4871
+ //# sourceMappingURL=tg-map.js.map