@lin1538001/unified-map 0.1.0 → 0.1.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.
@@ -1,11 +1,11 @@
1
1
  var M = Object.defineProperty;
2
2
  var b = (L, t, e) => t in L ? M(L, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : L[t] = e;
3
3
  var f = (L, t, e) => (b(L, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { b as C, c as R } from "./mapLoader-06d6e155.js";
5
- import { M as c, a as S } from "./index-5b75eace.js";
4
+ import { b as C, c as I } from "./mapLoader-06d6e155.js";
5
+ import { M as y, a as S } from "./index-dd303ebf.js";
6
6
  import { t as V } from "./color-128d7dff.js";
7
7
  import "vue";
8
- class z {
8
+ class _ {
9
9
  constructor() {
10
10
  f(this, "coordinateSystem", "bd09");
11
11
  f(this, "sdk", null);
@@ -22,9 +22,9 @@ class z {
22
22
  f(this, "polygonLayers", /* @__PURE__ */ new Set());
23
23
  }
24
24
  async init(t) {
25
- var i, s, r, a, o, l, n;
25
+ var i, r, s, a, o, l, n;
26
26
  if (!t.key)
27
- throw new c("SDK_ERROR", "Baidu Map requires an AK");
27
+ throw new y("SDK_ERROR", "Baidu Map requires an AK");
28
28
  const e = this.resolveContainer(t.container);
29
29
  this.containerElement = typeof e == "string" ? document.getElementById(e) : e;
30
30
  try {
@@ -34,16 +34,16 @@ class z {
34
34
  }), this.map.centerAndZoom(
35
35
  this.toPoint(t.center || [116.410316, 39.916699]),
36
36
  t.zoom ?? 12
37
- ), (s = (i = this.map).enableScrollWheelZoom) == null || s.call(i, !0), this.mapVglSdk = await R(), this.mapVglView = new this.mapVglSdk.View({ map: this.map });
37
+ ), (r = (i = this.map).enableScrollWheelZoom) == null || r.call(i, !0), this.mapVglSdk = await I(), this.mapVglView = new this.mapVglSdk.View({ map: this.map });
38
38
  } catch (h) {
39
- throw (a = (r = this.mapVglView) == null ? void 0 : r.destroy) == null || a.call(r), this.mapVglView = null, this.mapVglSdk = null, (l = (o = this.map) == null ? void 0 : o.destroy) == null || l.call(o), (n = this.containerElement) == null || n.replaceChildren(), this.containerElement = null, this.sdk = null, this.map = null, new c("SDK_ERROR", "Failed to initialize Baidu Map", { cause: h });
39
+ throw (a = (s = this.mapVglView) == null ? void 0 : s.destroy) == null || a.call(s), this.mapVglView = null, this.mapVglSdk = null, (l = (o = this.map) == null ? void 0 : o.destroy) == null || l.call(o), (n = this.containerElement) == null || n.replaceChildren(), this.containerElement = null, this.sdk = null, this.map = null, new y("SDK_ERROR", "Failed to initialize Baidu Map", { cause: h });
40
40
  }
41
41
  }
42
42
  destroy() {
43
- var t, e, i, s, r, a, o, l, n, h, m, g;
43
+ var t, e, i, r, s, a, o, l, n, h, m, g;
44
44
  this.activeEdit && this.finishEdit(this.activeEdit), this.cancelDraw();
45
45
  for (const d of [...this.massPointLayers])
46
- (e = (t = this.mapVglView) == null ? void 0 : t.removeLayer) == null || e.call(t, d.layer), (s = (i = d.layer) == null ? void 0 : i.clear) == null || s.call(i);
46
+ (e = (t = this.mapVglView) == null ? void 0 : t.removeLayer) == null || e.call(t, d.layer), (r = (i = d.layer) == null ? void 0 : i.clear) == null || r.call(i);
47
47
  this.massPointLayers.clear();
48
48
  for (const d of [...this.scatterLayers])
49
49
  this.destroyScatterLayer(d);
@@ -53,7 +53,7 @@ class z {
53
53
  this.polylineLayers.clear();
54
54
  for (const d of [...this.polygonLayers])
55
55
  this.destroyVectorLayer(d);
56
- this.polygonLayers.clear(), (a = (r = this.mapVglView) == null ? void 0 : r.destroy) == null || a.call(r), this.mapVglView = null, this.mapVglSdk = null, (l = (o = this.map) == null ? void 0 : o.clearOverlays) == null || l.call(o), typeof ((n = this.map) == null ? void 0 : n.destroy) == "function" ? this.map.destroy() : (m = (h = this.map) == null ? void 0 : h.dispose) == null || m.call(h), this.map = null, this.sdk = null, (g = this.containerElement) == null || g.replaceChildren(), this.containerElement = null;
56
+ this.polygonLayers.clear(), (a = (s = this.mapVglView) == null ? void 0 : s.destroy) == null || a.call(s), this.mapVglView = null, this.mapVglSdk = null, (l = (o = this.map) == null ? void 0 : o.clearOverlays) == null || l.call(o), typeof ((n = this.map) == null ? void 0 : n.destroy) == "function" ? this.map.destroy() : (m = (h = this.map) == null ? void 0 : h.dispose) == null || m.call(h), this.map = null, this.sdk = null, (g = this.containerElement) == null || g.replaceChildren(), this.containerElement = null;
57
57
  }
58
58
  addMarker(t) {
59
59
  const e = this.createMarker(t);
@@ -69,16 +69,16 @@ class z {
69
69
  }
70
70
  addPolylineLayer(t) {
71
71
  if (!this.mapVglView || !this.mapVglSdk)
72
- throw new c("SDK_ERROR", "Baidu MapVGL is unavailable");
72
+ throw new y("SDK_ERROR", "Baidu MapVGL is unavailable");
73
73
  const e = new this.mapVglSdk.LineLayer(this.toPolylineLayerStyle(t)), i = { layer: e };
74
74
  return this.mapVglView.addLayer(e), e.setData(this.toPolylineLayerData(t)), this.setMassPointLayerVisibility(e, t.visible !== !1), this.polylineLayers.add(i), i;
75
75
  }
76
76
  updatePolylineLayer(t, e, i) {
77
- var r, a, o, l;
78
- const s = t;
79
- if (!this.polylineLayers.has(s))
80
- throw new c("OVERLAY_NOT_FOUND", "Polyline layer is no longer registered");
81
- return ("style" in i || "zIndex" in i || "minZoom" in i || "maxZoom" in i) && ((a = (r = s.layer).setOptions) == null || a.call(r, this.toPolylineLayerStyle(e))), "polylines" in i && ((l = (o = s.layer).setData) == null || l.call(o, this.toPolylineLayerData(e))), "visible" in i && this.setMassPointLayerVisibility(s.layer, e.visible !== !1), t;
77
+ var s, a, o, l;
78
+ const r = t;
79
+ if (!this.polylineLayers.has(r))
80
+ throw new y("OVERLAY_NOT_FOUND", "Polyline layer is no longer registered");
81
+ return ("style" in i || "zIndex" in i || "minZoom" in i || "maxZoom" in i) && ((a = (s = r.layer).setOptions) == null || a.call(s, this.toPolylineLayerStyle(e))), "polylines" in i && ((l = (o = r.layer).setData) == null || l.call(o, this.toPolylineLayerData(e))), "visible" in i && this.setMassPointLayerVisibility(r.layer, e.visible !== !1), t;
82
82
  }
83
83
  removePolylineLayer(t) {
84
84
  const e = t;
@@ -86,16 +86,16 @@ class z {
86
86
  }
87
87
  addPolygonLayer(t) {
88
88
  if (!this.mapVglView || !this.mapVglSdk)
89
- throw new c("SDK_ERROR", "Baidu MapVGL is unavailable");
89
+ throw new y("SDK_ERROR", "Baidu MapVGL is unavailable");
90
90
  const e = new this.mapVglSdk.PolygonLayer(this.toPolygonLayerStyle(t)), i = { layer: e };
91
91
  return this.mapVglView.addLayer(e), e.setData(this.toPolygonLayerData(t)), this.setMassPointLayerVisibility(e, t.visible !== !1), this.polygonLayers.add(i), i;
92
92
  }
93
93
  updatePolygonLayer(t, e, i) {
94
- var r, a, o, l;
95
- const s = t;
96
- if (!this.polygonLayers.has(s))
97
- throw new c("OVERLAY_NOT_FOUND", "Polygon layer is no longer registered");
98
- return ("style" in i || "zIndex" in i || "minZoom" in i || "maxZoom" in i) && ((a = (r = s.layer).setOptions) == null || a.call(r, this.toPolygonLayerStyle(e))), "polygons" in i && ((l = (o = s.layer).setData) == null || l.call(o, this.toPolygonLayerData(e))), "visible" in i && this.setMassPointLayerVisibility(s.layer, e.visible !== !1), t;
94
+ var s, a, o, l;
95
+ const r = t;
96
+ if (!this.polygonLayers.has(r))
97
+ throw new y("OVERLAY_NOT_FOUND", "Polygon layer is no longer registered");
98
+ return ("style" in i || "zIndex" in i || "minZoom" in i || "maxZoom" in i) && ((a = (s = r.layer).setOptions) == null || a.call(s, this.toPolygonLayerStyle(e))), "polygons" in i && ((l = (o = r.layer).setData) == null || l.call(o, this.toPolygonLayerData(e))), "visible" in i && this.setMassPointLayerVisibility(r.layer, e.visible !== !1), t;
99
99
  }
100
100
  removePolygonLayer(t) {
101
101
  const e = t;
@@ -103,34 +103,35 @@ class z {
103
103
  }
104
104
  addMassPoints(t) {
105
105
  if (!this.mapVglView || !this.mapVglSdk)
106
- throw new c("SDK_ERROR", "Baidu MapVGL is unavailable");
107
- const e = new this.mapVglSdk.PointLayer(this.toMassPointLayerStyle(t)), i = { layer: e };
108
- return this.mapVglView.addLayer(e), e.setData(this.toMassPointData(t)), this.setMassPointLayerVisibility(e, t.visible !== !1), this.massPointLayers.add(i), i;
106
+ throw new y("SDK_ERROR", "Baidu MapVGL is unavailable");
107
+ const e = this.createMassPointLayer(t);
108
+ return this.massPointLayers.add(e), e;
109
109
  }
110
110
  updateMassPoints(t, e) {
111
- var s, r, a, o;
111
+ var s, a, o, l;
112
112
  const i = t;
113
113
  if (!this.massPointLayers.has(i))
114
- throw new c("OVERLAY_NOT_FOUND", "Mass point layer is no longer registered");
115
- return (r = (s = i.layer).setOptions) == null || r.call(s, this.toMassPointLayerStyle(e)), (o = (a = i.layer).setData) == null || o.call(a, this.toMassPointData(e)), this.setMassPointLayerVisibility(i.layer, e.visible !== !1), t;
114
+ throw new y("OVERLAY_NOT_FOUND", "Mass point layer is no longer registered");
115
+ const r = this.createMassPointLayer(e);
116
+ return (a = (s = this.mapVglView) == null ? void 0 : s.removeLayer) == null || a.call(s, i.layer), (l = (o = i.layer) == null ? void 0 : o.clear) == null || l.call(o), i.layer = r.layer, t;
116
117
  }
117
118
  removeMassPoints(t) {
118
- var i, s, r, a;
119
+ var i, r, s, a;
119
120
  const e = t;
120
- this.massPointLayers.has(e) && ((s = (i = this.mapVglView) == null ? void 0 : i.removeLayer) == null || s.call(i, e.layer), (a = (r = e.layer) == null ? void 0 : r.clear) == null || a.call(r), this.massPointLayers.delete(e));
121
+ this.massPointLayers.has(e) && ((r = (i = this.mapVglView) == null ? void 0 : i.removeLayer) == null || r.call(i, e.layer), (a = (s = e.layer) == null ? void 0 : s.clear) == null || a.call(s), this.massPointLayers.delete(e));
121
122
  }
122
123
  addScatterLayer(t) {
123
124
  if (!this.mapVglView || !this.mapVglSdk)
124
- throw new c("SDK_ERROR", "Baidu MapVGL is unavailable");
125
+ throw new y("SDK_ERROR", "Baidu MapVGL is unavailable");
125
126
  const e = this.createScatterLayer(t);
126
127
  return this.scatterLayers.add(e), e;
127
128
  }
128
129
  updateScatterLayer(t, e) {
129
130
  const i = t;
130
131
  if (!this.scatterLayers.has(i))
131
- throw new c("OVERLAY_NOT_FOUND", "Scatter layer is no longer registered");
132
- const s = this.createScatterLayer(e);
133
- return this.scatterLayers.add(s), this.destroyScatterLayer(i), this.scatterLayers.delete(i), s;
132
+ throw new y("OVERLAY_NOT_FOUND", "Scatter layer is no longer registered");
133
+ const r = this.createScatterLayer(e);
134
+ return this.scatterLayers.add(r), this.destroyScatterLayer(i), this.scatterLayers.delete(i), r;
134
135
  }
135
136
  removeScatterLayer(t) {
136
137
  const e = t;
@@ -138,68 +139,68 @@ class z {
138
139
  }
139
140
  updateOverlay(t, e, i) {
140
141
  var o, l, n, h, m, g, d;
141
- const s = this.overlayKinds.get(t);
142
- if (!s)
143
- throw new c("OVERLAY_NOT_FOUND", "Overlay is no longer registered");
144
- if (s === "marker")
142
+ const r = this.overlayKinds.get(t);
143
+ if (!r)
144
+ throw new y("OVERLAY_NOT_FOUND", "Overlay is no longer registered");
145
+ if (r === "marker")
145
146
  return this.removeOverlay(t), this.addMarker(e);
146
- const r = t, a = e;
147
- if ("path" in i && ((o = r.setPath) == null || o.call(r, a.path.map((y) => this.toPoint(y)))), (l = r.setStrokeColor) == null || l.call(r, a.strokeColor || "#3366ff"), (n = r.setStrokeWeight) == null || n.call(r, a.strokeWeight ?? (s === "polygon" ? 3 : 5)), (h = r.setStrokeOpacity) == null || h.call(r, a.strokeOpacity ?? 1), (m = r.setStrokeStyle) == null || m.call(r, a.strokeStyle || "solid"), s === "polygon") {
148
- const y = e;
149
- (g = r.setFillColor) == null || g.call(r, y.fillColor || "#3366ff"), (d = r.setFillOpacity) == null || d.call(r, y.fillOpacity ?? 0.3);
147
+ const s = t, a = e;
148
+ if ("path" in i && ((o = s.setPath) == null || o.call(s, a.path.map((c) => this.toPoint(c)))), (l = s.setStrokeColor) == null || l.call(s, a.strokeColor || "#3366ff"), (n = s.setStrokeWeight) == null || n.call(s, a.strokeWeight ?? (r === "polygon" ? 3 : 5)), (h = s.setStrokeOpacity) == null || h.call(s, a.strokeOpacity ?? 1), (m = s.setStrokeStyle) == null || m.call(s, a.strokeStyle || "solid"), r === "polygon") {
149
+ const c = e;
150
+ (g = s.setFillColor) == null || g.call(s, c.fillColor || "#3366ff"), (d = s.setFillOpacity) == null || d.call(s, c.fillOpacity ?? 0.3);
150
151
  }
151
152
  return t;
152
153
  }
153
154
  removeOverlay(t) {
154
- var i, s;
155
+ var i, r;
155
156
  const e = this.activeEdit;
156
- e && e.native === t && this.finishEdit(e), (s = (i = this.map) == null ? void 0 : i.removeOverlay) == null || s.call(i, t), t && (typeof t == "object" || typeof t == "function") && this.overlayKinds.delete(t);
157
+ e && e.native === t && this.finishEdit(e), (r = (i = this.map) == null ? void 0 : i.removeOverlay) == null || r.call(i, t), t && (typeof t == "object" || typeof t == "function") && this.overlayKinds.delete(t);
157
158
  }
158
159
  getPath(t) {
159
160
  var i;
160
161
  const e = (i = t == null ? void 0 : t.getPath) == null ? void 0 : i.call(t);
161
- return Array.isArray(e) ? e.map((s) => S([s.lng, s.lat])) : null;
162
+ return Array.isArray(e) ? e.map((r) => S([r.lng, r.lat])) : null;
162
163
  }
163
164
  getPosition(t) {
164
- var s, r;
165
- const e = t, i = ((s = e == null ? void 0 : e.getPosition) == null ? void 0 : s.call(e)) || ((r = e == null ? void 0 : e.getCenter) == null ? void 0 : r.call(e));
165
+ var r, s;
166
+ const e = t, i = ((r = e == null ? void 0 : e.getPosition) == null ? void 0 : r.call(e)) || ((s = e == null ? void 0 : e.getCenter) == null ? void 0 : s.call(e));
166
167
  return i ? S([i.lng, i.lat]) : null;
167
168
  }
168
169
  onMapClick(t) {
169
170
  const e = (i) => {
170
- const s = this.toClickEvent(i);
171
- if (!s)
171
+ const r = this.toClickEvent(i);
172
+ if (!r)
172
173
  return;
173
- const r = (i == null ? void 0 : i.overlay) || (i == null ? void 0 : i.target), a = r && r !== this.map && this.overlayKinds.has(r) ? r : void 0;
174
- t(s, a);
174
+ const s = (i == null ? void 0 : i.overlay) || (i == null ? void 0 : i.target), a = s && s !== this.map && this.overlayKinds.has(s) ? s : void 0;
175
+ t(r, a);
175
176
  };
176
177
  return this.map.addEventListener("click", e), () => {
177
- var i, s;
178
- return (s = (i = this.map) == null ? void 0 : i.removeEventListener) == null ? void 0 : s.call(i, "click", e);
178
+ var i, r;
179
+ return (r = (i = this.map) == null ? void 0 : i.removeEventListener) == null ? void 0 : r.call(i, "click", e);
179
180
  };
180
181
  }
181
182
  onOverlayClick(t, e) {
182
- var r;
183
- const i = t, s = (a) => {
183
+ var s;
184
+ const i = t, r = (a) => {
184
185
  const o = this.toClickEvent(a, t);
185
186
  o && e(o);
186
187
  };
187
- return (r = i.addEventListener) == null || r.call(i, "click", s), () => {
188
+ return (s = i.addEventListener) == null || s.call(i, "click", r), () => {
188
189
  var a;
189
- return (a = i.removeEventListener) == null ? void 0 : a.call(i, "click", s);
190
+ return (a = i.removeEventListener) == null ? void 0 : a.call(i, "click", r);
190
191
  };
191
192
  }
192
193
  startEdit(t, e, i) {
193
194
  var a;
194
195
  if (this.overlayKinds.get(t) !== e)
195
- throw new c("INVALID_OPTIONS", "Only polyline and polygon overlays can be edited");
196
- const s = t;
197
- if (typeof s.enableEditing != "function")
198
- throw new c("SDK_ERROR", `Baidu Map ${e} editing is unavailable`);
196
+ throw new y("INVALID_OPTIONS", "Only polyline and polygon overlays can be edited");
197
+ const r = t;
198
+ if (typeof r.enableEditing != "function")
199
+ throw new y("SDK_ERROR", `Baidu Map ${e} editing is unavailable`);
199
200
  if (this.activeDraw)
200
- throw new c("DRAW_IN_PROGRESS", "Cannot edit while drawing");
201
+ throw new y("DRAW_IN_PROGRESS", "Cannot edit while drawing");
201
202
  this.activeEdit && this.finishEdit(this.activeEdit);
202
- const r = {
203
+ const s = {
203
204
  native: t,
204
205
  handler: () => {
205
206
  const o = this.getPath(t);
@@ -208,19 +209,19 @@ class z {
208
209
  onChange: i,
209
210
  stopped: !1
210
211
  };
211
- return this.activeEdit = r, (a = s.addEventListener) == null || a.call(s, "lineupdate", r.handler), s.enableEditing(), () => this.finishEdit(r);
212
+ return this.activeEdit = s, (a = r.addEventListener) == null || a.call(r, "lineupdate", s.handler), r.enableEditing(), () => this.finishEdit(s);
212
213
  }
213
- startDraw(t, e, i, s) {
214
+ startDraw(t, e, i, r) {
214
215
  var a;
215
216
  if (this.activeDraw)
216
- throw new c("DRAW_IN_PROGRESS", "A drawing operation is already active");
217
+ throw new y("DRAW_IN_PROGRESS", "A drawing operation is already active");
217
218
  this.activeEdit && this.finishEdit(this.activeEdit);
218
- const r = (a = window.BMapGLLib) == null ? void 0 : a.DrawingManager;
219
- if (r) {
220
- this.startDrawingManager(r, t, e, i, s);
219
+ const s = (a = window.BMapGLLib) == null ? void 0 : a.DrawingManager;
220
+ if (s) {
221
+ this.startDrawingManager(s, t, e, i, r);
221
222
  return;
222
223
  }
223
- this.startManualDraw(t, e, i, s);
224
+ this.startManualDraw(t, e, i, r);
224
225
  }
225
226
  cancelDraw() {
226
227
  const t = this.activeDraw;
@@ -239,14 +240,45 @@ class z {
239
240
  getZoom() {
240
241
  return this.map.getZoom();
241
242
  }
243
+ fitView(t, e, i, r) {
244
+ if (t.length === 0)
245
+ return;
246
+ const s = t.map((n) => this.toPoint(n)), a = [i[0], i[3], i[1], i[2]], o = this.map.getViewport(s, { margins: a }), l = r === void 0 ? o.zoom : Math.min(o.zoom, r);
247
+ this.map.setViewport(
248
+ { center: o.center, zoom: l },
249
+ { enableAnimation: !e, margins: a, delay: 0 }
250
+ );
251
+ }
252
+ createInfoWindow(t, e, i) {
253
+ var o, l;
254
+ const r = new this.sdk.InfoWindow(t.content ?? "", {
255
+ ...t.size ? { width: t.size[0], height: t.size[1] } : {},
256
+ ...t.offset ? { offset: new this.sdk.Size(t.offset[0], t.offset[1]) } : {},
257
+ enableAutoPan: t.autoMove ?? !0,
258
+ enableCloseOnClick: t.closeWhenClickMap ?? !1
259
+ }), s = (n) => e(n), a = (n) => i(n);
260
+ return (o = r.addEventListener) == null || o.call(r, "open", s), (l = r.addEventListener) == null || l.call(r, "close", a), { value: r, openHandler: s, closeHandler: a };
261
+ }
262
+ openInfoWindow(t, e) {
263
+ this.map.openInfoWindow(t.value, this.toPoint(e));
264
+ }
265
+ closeInfoWindow(t) {
266
+ var e, i;
267
+ (i = (e = this.map).closeInfoWindow) == null || i.call(e);
268
+ }
269
+ destroyInfoWindow(t) {
270
+ var i, r, s, a, o, l, n, h;
271
+ const e = t;
272
+ (r = (i = e.value).removeEventListener) == null || r.call(i, "open", e.openHandler), (a = (s = e.value).removeEventListener) == null || a.call(s, "close", e.closeHandler), (l = (o = e.value).isOpen) != null && l.call(o) && ((h = (n = this.map) == null ? void 0 : n.closeInfoWindow) == null || h.call(n));
273
+ }
242
274
  resolveContainer(t) {
243
275
  if (typeof t == "string") {
244
276
  if (!document.getElementById(t))
245
- throw new c("INVALID_OPTIONS", `Container not found: ${t}`);
277
+ throw new y("INVALID_OPTIONS", `Container not found: ${t}`);
246
278
  return t;
247
279
  }
248
280
  if (!t)
249
- throw new c("INVALID_OPTIONS", "A map container is required");
281
+ throw new y("INVALID_OPTIONS", "A map container is required");
250
282
  return t;
251
283
  }
252
284
  toPoint(t) {
@@ -256,17 +288,17 @@ class z {
256
288
  const i = (t == null ? void 0 : t.latlng) || (t == null ? void 0 : t.latLng) || (t == null ? void 0 : t.point) || (e ? this.nativeAnchor(e) : null);
257
289
  if (!i)
258
290
  return null;
259
- const s = S([i.lng, i.lat]);
291
+ const r = S([i.lng, i.lat]);
260
292
  return {
261
- lnglat: { lng: s[0], lat: s[1] },
262
- position: s,
293
+ lnglat: { lng: r[0], lat: r[1] },
294
+ position: r,
263
295
  coordinateSystem: this.coordinateSystem,
264
296
  originalEvent: t
265
297
  };
266
298
  }
267
299
  nativeAnchor(t) {
268
- var s, r, a, o;
269
- const e = t, i = ((s = e == null ? void 0 : e.getPosition) == null ? void 0 : s.call(e)) || ((r = e == null ? void 0 : e.getCenter) == null ? void 0 : r.call(e));
300
+ var r, s, a, o;
301
+ const e = t, i = ((r = e == null ? void 0 : e.getPosition) == null ? void 0 : r.call(e)) || ((s = e == null ? void 0 : e.getCenter) == null ? void 0 : s.call(e));
270
302
  return i || ((o = (a = e == null ? void 0 : e.getPath) == null ? void 0 : a.call(e)) == null ? void 0 : o[0]) || null;
271
303
  }
272
304
  addNative(t, e) {
@@ -278,7 +310,7 @@ class z {
278
310
  const m = new this.sdk.Size(e.width, e.height), g = e.anchor === "bottom-center" ? new this.sdk.Size(e.width / 2, e.height) : new this.sdk.Size(e.width / 2, e.height / 2), d = new this.sdk.Icon(e.url, m, { anchor: g, imageSize: m });
279
311
  return new this.sdk.Marker(i, { icon: d, enableClicking: !0 });
280
312
  }
281
- const s = e.radius ?? 8, r = e.strokeWeight ?? 2, a = (s + r) * 2, o = `<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 ${a} ${a}"><circle cx="${a / 2}" cy="${a / 2}" r="${s}" fill="${e.fillColor || "#1677ff"}" fill-opacity="${e.fillOpacity ?? 0.8}" stroke="${e.strokeColor || "#ffffff"}" stroke-width="${r}"/></svg>`, l = `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(o)}`, n = new this.sdk.Size(a, a), h = new this.sdk.Icon(l, n, {
313
+ const r = e.radius ?? 8, s = e.strokeWeight ?? 2, a = (r + s) * 2, o = `<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 ${a} ${a}"><circle cx="${a / 2}" cy="${a / 2}" r="${r}" fill="${e.fillColor || "#1677ff"}" fill-opacity="${e.fillOpacity ?? 0.8}" stroke="${e.strokeColor || "#ffffff"}" stroke-width="${s}"/></svg>`, l = `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(o)}`, n = new this.sdk.Size(a, a), h = new this.sdk.Icon(l, n, {
282
314
  anchor: new this.sdk.Size(a / 2, a / 2),
283
315
  imageSize: n
284
316
  });
@@ -298,6 +330,20 @@ class z {
298
330
  }
299
331
  toMassPointLayerStyle(t) {
300
332
  const e = t.style || {};
333
+ if (e.icon) {
334
+ const i = e.icon.width ?? e.size ?? 20, r = e.icon.height ?? e.size ?? 20;
335
+ return {
336
+ icon: e.icon.url,
337
+ width: i,
338
+ height: r,
339
+ offset: e.icon.anchor === "bottom-center" ? [0, -r / 2] : [0, 0],
340
+ unit: e.unit === "meter" ? "m" : "px",
341
+ opacity: e.opacity ?? 1,
342
+ renderOrder: t.zIndex ?? 100,
343
+ minZoom: t.minZoom ?? 3,
344
+ maxZoom: t.maxZoom ?? 21
345
+ };
346
+ }
301
347
  return {
302
348
  color: V(e.color || "#ff1a0a", e.opacity ?? 0.85),
303
349
  shape: "circle",
@@ -310,6 +356,11 @@ class z {
310
356
  maxZoom: t.maxZoom ?? 21
311
357
  };
312
358
  }
359
+ createMassPointLayer(t) {
360
+ var r;
361
+ const e = (r = t.style) != null && r.icon ? this.mapVglSdk.IconLayer : this.mapVglSdk.PointLayer, i = new e(this.toMassPointLayerStyle(t));
362
+ return this.mapVglView.addLayer(i), i.setData(this.toMassPointData(t)), this.setMassPointLayerVisibility(i, t.visible !== !1), { layer: i };
363
+ }
313
364
  toPolylineLayerStyle(t) {
314
365
  const e = t.style || {};
315
366
  return {
@@ -352,30 +403,30 @@ class z {
352
403
  }));
353
404
  }
354
405
  destroyVectorLayer(t) {
355
- var e, i, s, r;
356
- (i = (e = this.mapVglView) == null ? void 0 : e.removeLayer) == null || i.call(e, t.layer), (r = (s = t.layer) == null ? void 0 : s.clear) == null || r.call(s);
406
+ var e, i, r, s;
407
+ (i = (e = this.mapVglView) == null ? void 0 : e.removeLayer) == null || i.call(e, t.layer), (s = (r = t.layer) == null ? void 0 : r.clear) == null || s.call(r);
357
408
  }
358
409
  closeRing(t) {
359
- const e = t[0], i = t[t.length - 1], s = t.map((r) => [r[0], r[1]]);
360
- return e[0] === i[0] && e[1] === i[1] ? s : [...s, [e[0], e[1]]];
410
+ const e = t[0], i = t[t.length - 1], r = t.map((s) => [s[0], s[1]]);
411
+ return e[0] === i[0] && e[1] === i[1] ? r : [...r, [e[0], e[1]]];
361
412
  }
362
413
  createScatterLayer(t) {
363
414
  var a;
364
415
  const e = document.createElement("canvas");
365
416
  e.width = 1, e.height = 1;
366
- const i = new this.mapVglSdk.IconLayer(this.toScatterLayerStyle(t, e)), s = new Image(), r = {
417
+ const i = new this.mapVglSdk.IconLayer(this.toScatterLayerStyle(t, e)), r = new Image(), s = {
367
418
  layer: i,
368
419
  frames: [],
369
- image: s,
420
+ image: r,
370
421
  animationFrame: null,
371
422
  startedAt: 0,
372
423
  lastFrame: -1,
373
424
  options: t,
374
425
  disposed: !1
375
426
  };
376
- return this.mapVglView.addLayer(i), i.setData(this.toMassPointData(t)), this.setMassPointLayerVisibility(i, t.visible !== !1), s.onload = () => this.prepareScatterFrames(r), s.onerror = () => {
377
- r.disposed || console.error(`Baidu scatter texture failed to load: ${s.src}`);
378
- }, s.src = ((a = t.style) == null ? void 0 : a.texture) || "/breath_red.png", r;
427
+ return this.mapVglView.addLayer(i), i.setData(this.toMassPointData(t)), this.setMassPointLayerVisibility(i, t.visible !== !1), r.onload = () => this.prepareScatterFrames(s), r.onerror = () => {
428
+ s.disposed || console.error(`Baidu scatter texture failed to load: ${r.src}`);
429
+ }, r.src = ((a = t.style) == null ? void 0 : a.texture) || "/breath_red.png", s;
379
430
  }
380
431
  prepareScatterFrames(t) {
381
432
  if (t.disposed)
@@ -385,13 +436,13 @@ class z {
385
436
  console.error("Baidu scatter texture must be a horizontal sequence of square frames");
386
437
  return;
387
438
  }
388
- t.frames = Array.from({ length: i }, (s, r) => {
439
+ t.frames = Array.from({ length: i }, (r, s) => {
389
440
  const a = document.createElement("canvas");
390
441
  a.width = e, a.height = e;
391
442
  const o = a.getContext("2d");
392
443
  return o == null || o.drawImage(
393
444
  t.image,
394
- r * e,
445
+ s * e,
395
446
  0,
396
447
  e,
397
448
  e,
@@ -403,14 +454,14 @@ class z {
403
454
  }), t.startedAt = performance.now(), t.options.visible !== !1 && this.animateScatterLayer(t);
404
455
  }
405
456
  animateScatterLayer(t) {
406
- var s;
457
+ var r;
407
458
  if (t.disposed || t.frames.length === 0)
408
459
  return;
409
- const e = Math.max(1, ((s = t.options.style) == null ? void 0 : s.duration) ?? 2e3), i = (r) => {
460
+ const e = Math.max(1, ((r = t.options.style) == null ? void 0 : r.duration) ?? 2e3), i = (s) => {
410
461
  var l, n;
411
462
  if (t.disposed)
412
463
  return;
413
- const a = (r - t.startedAt) % e / e, o = Math.min(
464
+ const a = (s - t.startedAt) % e / e, o = Math.min(
414
465
  t.frames.length - 1,
415
466
  Math.floor(a * t.frames.length)
416
467
  );
@@ -422,8 +473,8 @@ class z {
422
473
  t.animationFrame = window.requestAnimationFrame(i);
423
474
  }
424
475
  destroyScatterLayer(t) {
425
- var e, i, s, r;
426
- t.disposed = !0, t.animationFrame !== null && window.cancelAnimationFrame(t.animationFrame), t.animationFrame = null, t.image.onload = null, t.image.onerror = null, t.frames.length = 0, (i = (e = this.mapVglView) == null ? void 0 : e.removeLayer) == null || i.call(e, t.layer), (r = (s = t.layer) == null ? void 0 : s.clear) == null || r.call(s);
476
+ var e, i, r, s;
477
+ t.disposed = !0, t.animationFrame !== null && window.cancelAnimationFrame(t.animationFrame), t.animationFrame = null, t.image.onload = null, t.image.onerror = null, t.frames.length = 0, (i = (e = this.mapVglView) == null ? void 0 : e.removeLayer) == null || i.call(e, t.layer), (s = (r = t.layer) == null ? void 0 : r.clear) == null || s.call(r);
427
478
  }
428
479
  toScatterLayerStyle(t, e) {
429
480
  const i = t.style || {};
@@ -445,8 +496,8 @@ class z {
445
496
  }));
446
497
  }
447
498
  setMassPointLayerVisibility(t, e) {
448
- var i, s, r, a;
449
- e ? (s = (i = this.mapVglView) == null ? void 0 : i.showLayer) == null || s.call(i, t) : (a = (r = this.mapVglView) == null ? void 0 : r.hideLayer) == null || a.call(r, t);
499
+ var i, r, s, a;
500
+ e ? (r = (i = this.mapVglView) == null ? void 0 : i.showLayer) == null || r.call(i, t) : (a = (s = this.mapVglView) == null ? void 0 : s.hideLayer) == null || a.call(s, t);
450
501
  }
451
502
  toPolylineStyle(t) {
452
503
  return {
@@ -466,7 +517,7 @@ class z {
466
517
  fillOpacity: e.fillOpacity ?? 0.3
467
518
  };
468
519
  }
469
- startDrawingManager(t, e, i, s, r) {
520
+ startDrawingManager(t, e, i, r, s) {
470
521
  const a = new t(this.map, {
471
522
  isOpen: !1,
472
523
  enableDrawingTool: !1,
@@ -477,10 +528,10 @@ class z {
477
528
  if (!h || h.finished)
478
529
  return;
479
530
  const m = (n == null ? void 0 : n.overlay) || n, g = this.getPath(m);
480
- !m || !g || (h.finished = !0, h.cleanup(!1), this.overlayKinds.set(m, e), this.activeDraw === h && (this.activeDraw = null), s(m, g));
531
+ !m || !g || (h.finished = !0, h.cleanup(!1), this.overlayKinds.set(m, e), this.activeDraw === h && (this.activeDraw = null), r(m, g));
481
532
  }, l = {
482
533
  finished: !1,
483
- onCancel: r,
534
+ onCancel: s,
484
535
  cleanup: () => {
485
536
  var n, h;
486
537
  (n = a.removeEventListener) == null || n.call(a, "overlaycomplete", o), (h = a.close) == null || h.call(a);
@@ -489,42 +540,42 @@ class z {
489
540
  this.activeDraw = l, a.addEventListener("overlaycomplete", o), a.setDrawingMode(e), a.open();
490
541
  }
491
542
  /** DrawingManager 不可用时的轻量后备:单击加点,双击完成。 */
492
- startManualDraw(t, e, i, s) {
543
+ startManualDraw(t, e, i, r) {
493
544
  var g, d;
494
- const r = [];
545
+ const s = [];
495
546
  let a = null;
496
- const o = t === "polyline" ? 2 : 3, l = (y) => {
497
- var w;
498
- const p = (y == null ? void 0 : y.latlng) || (y == null ? void 0 : y.latLng) || (y == null ? void 0 : y.point);
547
+ const o = t === "polyline" ? 2 : 3, l = (c) => {
548
+ var u;
549
+ const p = (c == null ? void 0 : c.latlng) || (c == null ? void 0 : c.latLng) || (c == null ? void 0 : c.point);
499
550
  if (!p)
500
551
  return;
501
- const u = r[r.length - 1];
502
- u && u.lng === p.lng && u.lat === p.lat || (r.push(p), !a && r.length >= o ? (a = t === "polyline" ? new this.sdk.Polyline(r.slice(), this.toPolylineStyle(e)) : new this.sdk.Polygon(r.slice(), this.toPolygonStyle(e)), this.map.addOverlay(a)) : (w = a == null ? void 0 : a.setPath) == null || w.call(a, r.slice()));
503
- }, n = (y) => l(y), h = (y) => {
504
- var u, w;
505
- (w = (u = y == null ? void 0 : y.domEvent) == null ? void 0 : u.preventDefault) == null || w.call(u), l(y);
552
+ const w = s[s.length - 1];
553
+ w && w.lng === p.lng && w.lat === p.lat || (s.push(p), !a && s.length >= o ? (a = t === "polyline" ? new this.sdk.Polyline(s.slice(), this.toPolylineStyle(e)) : new this.sdk.Polygon(s.slice(), this.toPolygonStyle(e)), this.map.addOverlay(a)) : (u = a == null ? void 0 : a.setPath) == null || u.call(a, s.slice()));
554
+ }, n = (c) => l(c), h = (c) => {
555
+ var w, u;
556
+ (u = (w = c == null ? void 0 : c.domEvent) == null ? void 0 : w.preventDefault) == null || u.call(w), l(c);
506
557
  const p = this.activeDraw;
507
- !p || p.finished || !a || r.length < o || (p.finished = !0, p.cleanup(!1), this.overlayKinds.set(a, t), this.activeDraw === p && (this.activeDraw = null), i(a, this.getPath(a) || []));
558
+ !p || p.finished || !a || s.length < o || (p.finished = !0, p.cleanup(!1), this.overlayKinds.set(a, t), this.activeDraw === p && (this.activeDraw = null), i(a, this.getPath(a) || []));
508
559
  }, m = {
509
560
  finished: !1,
510
- onCancel: s,
511
- cleanup: (y = !1) => {
512
- var p, u, w, O, P, E, k, D;
513
- (u = (p = this.map) == null ? void 0 : p.removeEventListener) == null || u.call(p, "click", n), (O = (w = this.map) == null ? void 0 : w.removeEventListener) == null || O.call(w, "dblclick", h), (E = (P = this.map) == null ? void 0 : P.enableDoubleClickZoom) == null || E.call(P), y && a && ((D = (k = this.map) == null ? void 0 : k.removeOverlay) == null || D.call(k, a));
561
+ onCancel: r,
562
+ cleanup: (c = !1) => {
563
+ var p, w, u, E, k, O, P, D;
564
+ (w = (p = this.map) == null ? void 0 : p.removeEventListener) == null || w.call(p, "click", n), (E = (u = this.map) == null ? void 0 : u.removeEventListener) == null || E.call(u, "dblclick", h), (O = (k = this.map) == null ? void 0 : k.enableDoubleClickZoom) == null || O.call(k), c && a && ((D = (P = this.map) == null ? void 0 : P.removeOverlay) == null || D.call(P, a));
514
565
  }
515
566
  };
516
567
  this.activeDraw = m, (d = (g = this.map).disableDoubleClickZoom) == null || d.call(g), this.map.addEventListener("click", n), this.map.addEventListener("dblclick", h);
517
568
  }
518
569
  finishEdit(t) {
519
- var s, r;
570
+ var r, s;
520
571
  if (t.stopped)
521
572
  return;
522
573
  const e = this.getPath(t.native);
523
574
  e && t.onChange(e), t.stopped = !0;
524
575
  const i = t.native;
525
- (s = i.removeEventListener) == null || s.call(i, "lineupdate", t.handler), (r = i.disableEditing) == null || r.call(i), this.activeEdit === t && (this.activeEdit = null);
576
+ (r = i.removeEventListener) == null || r.call(i, "lineupdate", t.handler), (s = i.disableEditing) == null || s.call(i), this.activeEdit === t && (this.activeEdit = null);
526
577
  }
527
578
  }
528
579
  export {
529
- z as BMapAdapter
580
+ _ as BMapAdapter
530
581
  };