@lin1538001/unified-map 0.0.0-stage → 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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +82 -2
  3. package/dist/chunks/AMapAdapter-76901841.js +581 -0
  4. package/dist/chunks/ArcGISAdapter-5e6881de.js +962 -0
  5. package/dist/chunks/BMapAdapter-0d882313.js +581 -0
  6. package/dist/chunks/color-128d7dff.js +38 -0
  7. package/dist/chunks/index-dd303ebf.js +1190 -0
  8. package/dist/chunks/mapLoader-06d6e155.js +226 -0
  9. package/dist/index.js +7 -0
  10. package/dist/types/index.d.ts +2 -0
  11. package/dist/types/index.d.ts.map +1 -0
  12. package/dist/types/map/InfoWindow.d.ts +38 -0
  13. package/dist/types/map/InfoWindow.d.ts.map +1 -0
  14. package/dist/types/map/UnifiedMap.d.ts +266 -0
  15. package/dist/types/map/UnifiedMap.d.ts.map +1 -0
  16. package/dist/types/map/adapters/AMapAdapter.d.ts +87 -0
  17. package/dist/types/map/adapters/AMapAdapter.d.ts.map +1 -0
  18. package/dist/types/map/adapters/ArcGISAdapter.d.ts +92 -0
  19. package/dist/types/map/adapters/ArcGISAdapter.d.ts.map +1 -0
  20. package/dist/types/map/adapters/BMapAdapter.d.ts +83 -0
  21. package/dist/types/map/adapters/BMapAdapter.d.ts.map +1 -0
  22. package/dist/types/map/adapters/MapAdapter.d.ts +46 -0
  23. package/dist/types/map/adapters/MapAdapter.d.ts.map +1 -0
  24. package/dist/types/map/adapters/color.d.ts +3 -0
  25. package/dist/types/map/adapters/color.d.ts.map +1 -0
  26. package/dist/types/map/coordinates.d.ts +29 -0
  27. package/dist/types/map/coordinates.d.ts.map +1 -0
  28. package/dist/types/map/errors.d.ts +8 -0
  29. package/dist/types/map/errors.d.ts.map +1 -0
  30. package/dist/types/map/index.d.ts +5 -0
  31. package/dist/types/map/index.d.ts.map +1 -0
  32. package/dist/types/map/types.d.ts +240 -0
  33. package/dist/types/map/types.d.ts.map +1 -0
  34. package/dist/types/utils/mapLoader.d.ts +49 -0
  35. package/dist/types/utils/mapLoader.d.ts.map +1 -0
  36. package/package.json +63 -4
@@ -0,0 +1,962 @@
1
+ var x = Object.defineProperty;
2
+ var T = (L, e, t) => e in L ? x(L, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : L[e] = t;
3
+ var h = (L, e, t) => (T(L, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import "@arcgis/core/assets/esri/themes/light/main.css";
5
+ import * as A from "@arcgis/core/core/reactiveUtils";
6
+ import f from "@arcgis/core/Graphic";
7
+ import W from "@arcgis/core/geometry/Multipoint";
8
+ import g from "@arcgis/core/geometry/Point";
9
+ import M from "@arcgis/core/geometry/Polygon";
10
+ import V from "@arcgis/core/geometry/Polyline";
11
+ import { xyToLngLat as D } from "@arcgis/core/geometry/support/webMercatorUtils";
12
+ import k from "@arcgis/core/layers/FeatureLayer";
13
+ import O from "@arcgis/core/symbols/PictureMarkerSymbol";
14
+ import F from "@arcgis/core/symbols/CIMSymbol";
15
+ import I from "@arcgis/core/symbols/SimpleFillSymbol";
16
+ import b from "@arcgis/core/symbols/SimpleLineSymbol";
17
+ import P from "@arcgis/core/symbols/SimpleMarkerSymbol";
18
+ import w from "@arcgis/core/renderers/SimpleRenderer";
19
+ import R from "@arcgis/core/widgets/Sketch/SketchViewModel";
20
+ import G from "@arcgis/core/Map";
21
+ import H from "@arcgis/core/views/MapView";
22
+ import N from "@arcgis/core/layers/GraphicsLayer";
23
+ import { M as c, a as E } from "./index-dd303ebf.js";
24
+ import { a as d } from "./color-128d7dff.js";
25
+ import "vue";
26
+ class K {
27
+ constructor() {
28
+ this.map = null, this.mapView = null, this.graphicsLayer = null, this.clickHandler = null, this.Graphic = f, this.Point = g, this.Polyline = V, this.Polygon = M, this.SimpleMarkerSymbol = P, this.SimpleLineSymbol = b, this.SimpleFillSymbol = I, this.SketchViewModel = R;
29
+ }
30
+ /**
31
+ * 创建地图
32
+ * @param {string|HTMLElement} container - 地图容器
33
+ * @param {Object} options - 地图配置
34
+ * @returns {Promise<Object>} 地图实例
35
+ */
36
+ async createMap(e, t = {}) {
37
+ const {
38
+ center: i = [116.404, 39.915],
39
+ zoom: r = 15,
40
+ basemap: a = null,
41
+ // 默认空白底图
42
+ enableClick: s = !0
43
+ } = t, o = typeof e == "string" ? e : e.id;
44
+ if (!o)
45
+ throw new Error("地图容器必须有id属性");
46
+ return this.map = new G({
47
+ basemap: a
48
+ // null 表示空白底图
49
+ }), this.mapView = new H({
50
+ container: o,
51
+ map: this.map,
52
+ center: i,
53
+ zoom: r
54
+ }), this.graphicsLayer = new N({
55
+ elevationInfo: { mode: "on-the-ground" }
56
+ // ✅ 确保图形贴地显示
57
+ }), this.map.add(this.graphicsLayer), s && console.warn('⚠️ ArcGIS 自动点击打点已禁用,请使用 MapManager.on("click") 事件'), await this.mapView.when(), console.log("地图创建成功(ArcGIS 4.x)"), {
58
+ map: this.map,
59
+ mapView: this.mapView,
60
+ graphicsLayer: this.graphicsLayer
61
+ };
62
+ }
63
+ /**
64
+ * 添加点标记
65
+ * @param {Object|number[]} point - ArcGIS Point对象或坐标数组 [lng, lat]
66
+ * @param {Object} options - 标记样式配置
67
+ */
68
+ addPoint(e, t = {}) {
69
+ if (!this.mapView || !this.graphicsLayer)
70
+ throw new Error("地图未初始化,请先调用createMap");
71
+ let i;
72
+ e.longitude !== void 0 && e.latitude !== void 0 ? i = e : Array.isArray(e) ? i = new g({
73
+ longitude: e[0],
74
+ latitude: e[1]
75
+ }) : i = new g(e);
76
+ const r = new P({
77
+ color: t.color || "red",
78
+ size: t.size || 12,
79
+ outline: {
80
+ color: t.outlineColor || "white",
81
+ width: t.outlineWidth || 2
82
+ }
83
+ }), a = new f({
84
+ geometry: i,
85
+ symbol: r,
86
+ attributes: t.attributes || {}
87
+ });
88
+ return this.graphicsLayer.add(a), console.log("添加点标记:", i.longitude, i.latitude), a;
89
+ }
90
+ /**
91
+ * 添加线段
92
+ * @param {Array<Array<number>>} points - 经纬度坐标数组 [[lng1, lat1], [lng2, lat2], ...]
93
+ * @param {Object} options - 线段样式配置
94
+ * @param {string} options.color - 线段颜色(十六进制或颜色名称)
95
+ * @param {number} options.width - 线宽(像素)
96
+ * @param {number} options.opacity - 透明度 (0-1)
97
+ * @returns {Graphic} 线段Graphic对象
98
+ */
99
+ addPolyline(e, t = {}) {
100
+ if (!this.mapView || !this.graphicsLayer)
101
+ throw new Error("地图未初始化,请先调用createMap");
102
+ const i = (o) => {
103
+ if (Array.isArray(o))
104
+ return o;
105
+ let l = o || "#3366FF";
106
+ l = l.replace("#", "");
107
+ const n = parseInt(l.substring(0, 2), 16), y = parseInt(l.substring(2, 4), 16), u = parseInt(l.substring(4, 6), 16);
108
+ return [n, y, u];
109
+ }, r = new V({
110
+ paths: [e.map((o) => [o[0], o[1]])]
111
+ // ArcGIS Polyline paths 格式
112
+ }), a = new b({
113
+ color: i(t.color),
114
+ width: t.width || 5,
115
+ style: "solid"
116
+ });
117
+ if (t.opacity && t.opacity < 1) {
118
+ const o = i(t.color);
119
+ a.color = [...o, t.opacity];
120
+ }
121
+ const s = new f({
122
+ geometry: r,
123
+ symbol: a,
124
+ attributes: t.attributes || {}
125
+ });
126
+ return this.graphicsLayer.add(s), console.log("添加线段:", e.length, "个点"), s;
127
+ }
128
+ /**
129
+ * 添加圆形标记(用于绘制节点)
130
+ * @param {Array<number>} lnglat - [lng, lat]
131
+ * @param {Object} options - 标记样式配置
132
+ * @param {string} options.color - 标记颜色(十六进制)
133
+ * @param {number} options.radius - 标记半径(像素)
134
+ * @param {string} options.strokeColor - 边框颜色(十六进制)
135
+ * @param {number} options.strokeWidth - 边框宽度(像素)
136
+ * @returns {Graphic} 标记Graphic对象
137
+ */
138
+ addCircleMarker(e, t = {}) {
139
+ if (!this.mapView || !this.graphicsLayer)
140
+ throw new Error("地图未初始化,请先调用createMap");
141
+ const i = this.SimpleMarkerSymbol, r = this.Graphic, a = this.Point, s = (p) => {
142
+ if (Array.isArray(p))
143
+ return p;
144
+ let m = p || "#FF0000";
145
+ m = m.replace("#", "");
146
+ const _ = parseInt(m.substring(0, 2), 16), C = parseInt(m.substring(2, 4), 16), v = parseInt(m.substring(4, 6), 16);
147
+ return [_, C, v];
148
+ }, o = s(t.color || "#FF0000"), l = t.radius || 4, n = s(t.strokeColor || "#FFFFFF"), y = t.strokeWidth || 2, u = new a({
149
+ longitude: e[0],
150
+ latitude: e[1]
151
+ }), z = new i({
152
+ style: "circle",
153
+ color: o,
154
+ size: l,
155
+ outline: {
156
+ color: n,
157
+ width: y
158
+ }
159
+ }), S = new r({
160
+ geometry: u,
161
+ symbol: z
162
+ });
163
+ return this.graphicsLayer.add(S), S;
164
+ }
165
+ /**
166
+ * ✅ 新增:添加多边形(用于绘制和编辑)
167
+ * @param {Array<Array<number>>} points - 多边形顶点数组 [[lng, lat], [lng, lat], ...]
168
+ * @param {Object} options - 多边形样式配置
169
+ * @param {string} options.fillColor - 填充颜色(十六进制)
170
+ * @param {number} options.fillOpacity - 填充透明度(0-1)
171
+ * @param {string} options.strokeColor - 边框颜色(十六进制)
172
+ * @param {number} options.strokeWidth - 边框宽度(像素)
173
+ * @returns {Graphic} 多边形Graphic对象
174
+ */
175
+ addPolygon(e, t = {}) {
176
+ if (!this.mapView || !this.graphicsLayer)
177
+ throw new Error("地图未初始化,请先调用createMap");
178
+ const i = this.Polygon, r = this.SimpleFillSymbol, a = this.Graphic, s = (p) => {
179
+ if (Array.isArray(p))
180
+ return p;
181
+ let m = p || "#3366FF";
182
+ m = m.replace("#", "");
183
+ const _ = parseInt(m.substring(0, 2), 16), C = parseInt(m.substring(2, 4), 16), v = parseInt(m.substring(4, 6), 16);
184
+ return [_, C, v];
185
+ }, o = s(t.fillColor || "#3366FF"), l = t.fillOpacity || 0.3, n = s(t.strokeColor || "#3366FF"), y = t.strokeWidth || 5, u = new i({
186
+ rings: [e.map((p) => [p[0], p[1]])]
187
+ // ArcGIS 使用 rings 属性
188
+ }), z = new r({
189
+ color: [...o, l],
190
+ // ✅ RGBA 格式(支持透明度)
191
+ outline: {
192
+ color: n,
193
+ width: y
194
+ }
195
+ }), S = new a({
196
+ geometry: u,
197
+ symbol: z
198
+ });
199
+ return this.graphicsLayer.add(S), console.log("添加多边形:", e.length, "个顶点"), S;
200
+ }
201
+ /**
202
+ * 清除所有点标记
203
+ */
204
+ clearPoints() {
205
+ this.graphicsLayer && this.graphicsLayer.removeAll();
206
+ }
207
+ /**
208
+ * 设置地图中心
209
+ * @param {number[]} center - [lng, lat]
210
+ */
211
+ setCenter(e) {
212
+ this.mapView && (this.mapView.center = e);
213
+ }
214
+ /**
215
+ * 设置缩放级别
216
+ * @param {number} zoom
217
+ */
218
+ setZoom(e) {
219
+ this.mapView && (this.mapView.zoom = e);
220
+ }
221
+ /**
222
+ * 销毁地图
223
+ */
224
+ destroy() {
225
+ this.mapView && (this.mapView.destroy(), this.mapView = null, this.map = null, this.graphicsLayer = null);
226
+ }
227
+ }
228
+ class ye {
229
+ constructor() {
230
+ h(this, "coordinateSystem", "wgs84");
231
+ h(this, "loader", new K());
232
+ h(this, "mapView", null);
233
+ h(this, "graphicsLayer", null);
234
+ h(this, "sketchViewModel", null);
235
+ h(this, "mapClickHandles", /* @__PURE__ */ new Set());
236
+ h(this, "overlayClickCallbacks", /* @__PURE__ */ new Map());
237
+ h(this, "hitTestHandle", null);
238
+ h(this, "activeDraw", null);
239
+ h(this, "activeEdit", null);
240
+ h(this, "overlayKinds", /* @__PURE__ */ new WeakMap());
241
+ h(this, "massPointLayers", /* @__PURE__ */ new Set());
242
+ h(this, "scatterLayers", /* @__PURE__ */ new Set());
243
+ h(this, "polylineLayers", /* @__PURE__ */ new Set());
244
+ h(this, "polygonLayers", /* @__PURE__ */ new Set());
245
+ h(this, "activeInfoWindow", null);
246
+ }
247
+ async init(e) {
248
+ const t = this.resolveContainer(e.container);
249
+ try {
250
+ const i = await this.loader.createMap(t, {
251
+ center: e.center || [116.397428, 39.90923],
252
+ zoom: e.zoom ?? 12,
253
+ basemap: e.basemap || "osm",
254
+ useTianditu: !1,
255
+ enableClick: !1
256
+ });
257
+ this.mapView = i.mapView, this.graphicsLayer = i.graphicsLayer;
258
+ } catch (i) {
259
+ throw this.mapView = null, this.graphicsLayer = null, new c("SDK_ERROR", "Failed to initialize ArcGIS", { cause: i });
260
+ }
261
+ }
262
+ destroy() {
263
+ var e;
264
+ this.activeEdit && this.finishEdit(this.activeEdit, !1), this.cancelDraw();
265
+ for (const t of this.mapClickHandles)
266
+ t.remove();
267
+ this.mapClickHandles.clear(), (e = this.hitTestHandle) == null || e.remove(), this.hitTestHandle = null, this.overlayClickCallbacks.clear(), this.resetSketchViewModel();
268
+ for (const t of [...this.massPointLayers])
269
+ this.destroyMassPointLayer(t);
270
+ this.massPointLayers.clear();
271
+ for (const t of [...this.scatterLayers])
272
+ this.destroyScatterLayer(t);
273
+ this.scatterLayers.clear();
274
+ for (const t of [...this.polylineLayers])
275
+ this.destroyVectorLayer(t);
276
+ this.polylineLayers.clear();
277
+ for (const t of [...this.polygonLayers])
278
+ this.destroyVectorLayer(t);
279
+ this.polygonLayers.clear(), this.activeInfoWindow && this.destroyInfoWindow(this.activeInfoWindow), this.loader.destroy(), this.mapView = null, this.graphicsLayer = null;
280
+ }
281
+ addMarker(e) {
282
+ const t = this.createMarker(e);
283
+ return this.graphicsLayer.add(t), this.remember(t, "marker"), t;
284
+ }
285
+ addPolyline(e) {
286
+ const t = this.createPolyline(e);
287
+ return this.graphicsLayer.add(t), this.remember(t, "polyline"), t;
288
+ }
289
+ addPolygon(e) {
290
+ const t = this.createPolygon(e);
291
+ return this.graphicsLayer.add(t), this.remember(t, "polygon"), t;
292
+ }
293
+ addPolylineLayer(e) {
294
+ const t = this.createPolylineLayer(e);
295
+ return this.addVisualizationLayer(t), this.polylineLayers.add(t), this.reorderVisualizationLayers(), t;
296
+ }
297
+ updatePolylineLayer(e, t, i) {
298
+ const r = e;
299
+ if (!this.polylineLayers.has(r))
300
+ throw new c("OVERLAY_NOT_FOUND", "Polyline layer is no longer registered");
301
+ return "polylines" in i ? (this.replaceVisualizationLayer(r, this.createPolylineLayer(t)), e) : (r.layer.renderer = new w({ symbol: this.createPolylineLayerSymbol(t) }), this.updateVisualizationLayerOptions(r, t, 90), e);
302
+ }
303
+ removePolylineLayer(e) {
304
+ const t = e;
305
+ this.polylineLayers.has(t) && (this.destroyVectorLayer(t), this.polylineLayers.delete(t));
306
+ }
307
+ addPolygonLayer(e) {
308
+ const t = this.createPolygonLayer(e);
309
+ return this.addVisualizationLayer(t), this.polygonLayers.add(t), this.reorderVisualizationLayers(), t;
310
+ }
311
+ updatePolygonLayer(e, t, i) {
312
+ const r = e;
313
+ if (!this.polygonLayers.has(r))
314
+ throw new c("OVERLAY_NOT_FOUND", "Polygon layer is no longer registered");
315
+ return "polygons" in i ? (this.replaceVisualizationLayer(r, this.createPolygonLayer(t)), e) : (r.layer.renderer = new w({ symbol: this.createPolygonLayerSymbol(t) }), this.updateVisualizationLayerOptions(r, t, 80), e);
316
+ }
317
+ removePolygonLayer(e) {
318
+ const t = e;
319
+ this.polygonLayers.has(t) && (this.destroyVectorLayer(t), this.polygonLayers.delete(t));
320
+ }
321
+ addMassPoints(e) {
322
+ var a;
323
+ const t = this.createMassPointLayer(e), i = (a = this.mapView) == null ? void 0 : a.map;
324
+ if (!i)
325
+ throw new c("SDK_ERROR", "ArcGIS map is unavailable");
326
+ const r = i.layers.indexOf(this.graphicsLayer);
327
+ return r >= 0 ? i.add(t.layer, r) : i.add(t.layer), this.massPointLayers.add(t), this.reorderVisualizationLayers(), t;
328
+ }
329
+ updateMassPoints(e, t, i) {
330
+ var n, y;
331
+ const r = e;
332
+ if (!this.massPointLayers.has(r))
333
+ throw new c("OVERLAY_NOT_FOUND", "Mass point layer is no longer registered");
334
+ const a = (n = this.mapView) == null ? void 0 : n.map;
335
+ if (!a)
336
+ throw new c("SDK_ERROR", "ArcGIS map is unavailable");
337
+ if (!("points" in i))
338
+ return r.layer.renderer = new w({ symbol: this.createMassPointSymbol(t) }), r.layer.opacity = (y = t.style) != null && y.icon ? t.style.opacity ?? 1 : 1, r.layer.visible = t.visible !== !1, r.layer.minScale = this.zoomToScale(t.minZoom ?? 3), r.layer.maxScale = this.zoomToScale(t.maxZoom ?? 21), r.zIndex = t.zIndex ?? 100, this.reorderVisualizationLayers(), e;
339
+ const s = this.createMassPointLayer(t), o = r.layer, l = a.layers.indexOf(o);
340
+ return a.remove(o), l >= 0 ? a.add(s.layer, l) : a.add(s.layer), o.destroy(), r.layer = s.layer, r.zIndex = s.zIndex, this.reorderVisualizationLayers(), e;
341
+ }
342
+ removeMassPoints(e) {
343
+ const t = e;
344
+ this.massPointLayers.has(t) && (this.destroyMassPointLayer(t), this.massPointLayers.delete(t));
345
+ }
346
+ addScatterLayer(e) {
347
+ var a;
348
+ const t = (a = this.mapView) == null ? void 0 : a.map;
349
+ if (!t)
350
+ throw new c("SDK_ERROR", "ArcGIS map is unavailable");
351
+ const i = this.createScatterLayer(e), r = t.layers.indexOf(this.graphicsLayer);
352
+ return r >= 0 ? t.add(i.layer, r) : t.add(i.layer), this.scatterLayers.add(i), this.reorderVisualizationLayers(), i;
353
+ }
354
+ updateScatterLayer(e, t, i) {
355
+ var n;
356
+ const r = e;
357
+ if (!this.scatterLayers.has(r))
358
+ throw new c("OVERLAY_NOT_FOUND", "Scatter layer is no longer registered");
359
+ const a = (n = this.mapView) == null ? void 0 : n.map;
360
+ if (!a)
361
+ throw new c("SDK_ERROR", "ArcGIS map is unavailable");
362
+ if (!("points" in i))
363
+ return r.layer.renderer = new w({ symbol: this.createScatterSymbol(t) }), r.layer.visible = t.visible !== !1, r.layer.minScale = this.zoomToScale(t.minZoom ?? 3), r.layer.maxScale = this.zoomToScale(t.maxZoom ?? 21), r.zIndex = t.zIndex ?? 120, this.reorderVisualizationLayers(), e;
364
+ const s = this.createScatterLayer(t), o = r.layer, l = a.layers.indexOf(o);
365
+ return a.remove(o), l >= 0 ? a.add(s.layer, l) : a.add(s.layer), o.destroy(), r.layer = s.layer, r.zIndex = s.zIndex, this.reorderVisualizationLayers(), e;
366
+ }
367
+ removeScatterLayer(e) {
368
+ const t = e;
369
+ this.scatterLayers.has(t) && (this.destroyScatterLayer(t), this.scatterLayers.delete(t));
370
+ }
371
+ updateOverlay(e, t, i) {
372
+ const r = this.overlayKinds.get(e);
373
+ if (!r)
374
+ throw new c("OVERLAY_NOT_FOUND", "Overlay is no longer registered");
375
+ const a = e, s = r === "marker" ? this.createMarker(t) : r === "polyline" ? this.createPolyline(t) : this.createPolygon(t);
376
+ return a.symbol = s.symbol, (r === "marker" && "position" in i || r !== "marker" && "path" in i) && (a.geometry = s.geometry), e;
377
+ }
378
+ removeOverlay(e) {
379
+ var i;
380
+ const t = this.activeEdit;
381
+ t && t.native === e && this.finishEdit(t, !1), (i = this.graphicsLayer) == null || i.remove(e), this.overlayClickCallbacks.delete(e), e && (typeof e == "object" || typeof e == "function") && this.overlayKinds.delete(e);
382
+ }
383
+ getPath(e) {
384
+ var a, s;
385
+ const t = e == null ? void 0 : e.geometry, i = ((a = t == null ? void 0 : t.paths) == null ? void 0 : a[0]) || ((s = t == null ? void 0 : t.rings) == null ? void 0 : s[0]);
386
+ if (!i)
387
+ return null;
388
+ const r = i.map((o) => this.toLngLat(o[0], o[1], t.spatialReference));
389
+ if (t.type === "polygon" && r.length > 1) {
390
+ const o = r[0], l = r[r.length - 1];
391
+ o[0] === l[0] && o[1] === l[1] && r.pop();
392
+ }
393
+ return r;
394
+ }
395
+ getPosition(e) {
396
+ const t = e == null ? void 0 : e.geometry;
397
+ return !t || t.type !== "point" ? null : this.toLngLat(t.x, t.y, t.spatialReference);
398
+ }
399
+ onMapClick(e) {
400
+ let t = !0;
401
+ const i = this.mapView.on("click", (r) => {
402
+ if (!r.mapPoint)
403
+ return;
404
+ const a = this.toLngLat(
405
+ r.mapPoint.x,
406
+ r.mapPoint.y,
407
+ r.mapPoint.spatialReference
408
+ ), s = {
409
+ lnglat: { lng: a[0], lat: a[1] },
410
+ position: a,
411
+ coordinateSystem: this.coordinateSystem,
412
+ originalEvent: r
413
+ };
414
+ this.mapView.hitTest(r).then((o) => {
415
+ var n;
416
+ if (!t)
417
+ return;
418
+ const l = (n = o.results) == null ? void 0 : n.find((y) => {
419
+ const u = y == null ? void 0 : y.graphic;
420
+ return u && this.overlayKinds.has(u);
421
+ });
422
+ e(s, l == null ? void 0 : l.graphic);
423
+ }).catch((o) => {
424
+ t && (console.error("ArcGIS hitTest failed", o), e(s));
425
+ });
426
+ });
427
+ return this.mapClickHandles.add(i), () => {
428
+ t = !1, i.remove(), this.mapClickHandles.delete(i);
429
+ };
430
+ }
431
+ onOverlayClick(e, t) {
432
+ let i = this.overlayClickCallbacks.get(e);
433
+ return i || (i = /* @__PURE__ */ new Set(), this.overlayClickCallbacks.set(e, i)), i.add(t), this.ensureHitTestListener(), () => {
434
+ var a;
435
+ const r = this.overlayClickCallbacks.get(e);
436
+ r == null || r.delete(t), r && r.size === 0 && this.overlayClickCallbacks.delete(e), this.overlayClickCallbacks.size === 0 && ((a = this.hitTestHandle) == null || a.remove(), this.hitTestHandle = null);
437
+ };
438
+ }
439
+ startEdit(e, t, i) {
440
+ if (this.overlayKinds.get(e) !== t)
441
+ throw new c("INVALID_OPTIONS", "Only polyline and polygon overlays can be edited");
442
+ this.activeDraw && this.cancelDraw(), this.activeEdit && this.finishEdit(this.activeEdit, !0);
443
+ const r = this.getSketchViewModel(), a = { id: Symbol("arcgis-edit"), native: e, sketch: r, handle: null, onChange: i, finished: !1 }, s = r.on("update", (o) => {
444
+ var n;
445
+ if (a.finished || !((n = o.graphics) != null && n.includes(e)))
446
+ return;
447
+ const l = this.getPath(e);
448
+ l && a.onChange(l), (o.state === "complete" || o.state === "cancel") && this.finishEdit(a, !1);
449
+ });
450
+ a.handle = s, this.activeEdit = a;
451
+ try {
452
+ r.update([e], { tool: "reshape" }).catch((o) => {
453
+ a.finished || this.finishEdit(a, !1), console.error(`ArcGIS ${t} editing failed`, o);
454
+ });
455
+ } catch (o) {
456
+ throw this.finishEdit(a, !1), new c("SDK_ERROR", `Failed to start ArcGIS ${t} editing`, { cause: o });
457
+ }
458
+ return () => this.finishEdit(a, !0);
459
+ }
460
+ startDraw(e, t, i, r) {
461
+ if (this.activeDraw)
462
+ throw new c("DRAW_IN_PROGRESS", "A drawing operation is already active");
463
+ this.activeEdit && this.finishEdit(this.activeEdit, !0), this.resetSketchViewModel();
464
+ const a = this.getSketchViewModel();
465
+ this.applyDrawStyle(a, e, t);
466
+ const s = { id: Symbol("arcgis-draw"), sketch: a, handle: null, onCancel: r, finished: !1 }, o = a.on("create", (l) => {
467
+ if (s.finished)
468
+ return;
469
+ if (l.state === "cancel") {
470
+ this.finishDraw(s), r();
471
+ return;
472
+ }
473
+ if (l.state !== "complete" || !l.graphic)
474
+ return;
475
+ this.remember(l.graphic, e);
476
+ const n = this.getPath(l.graphic) || [];
477
+ this.finishDraw(s), i(l.graphic, n);
478
+ });
479
+ s.handle = o, this.activeDraw = s;
480
+ try {
481
+ a.create(e, { mode: "click" }).catch((l) => {
482
+ s.finished || (this.finishDraw(s), s.onCancel()), console.error("ArcGIS drawing failed", l);
483
+ });
484
+ } catch (l) {
485
+ throw this.finishDraw(s), new c("SDK_ERROR", "Failed to start ArcGIS drawing", { cause: l });
486
+ }
487
+ }
488
+ cancelDraw() {
489
+ const e = this.activeDraw;
490
+ e && (e.sketch.cancel(), e.finished || (this.finishDraw(e), e.onCancel()));
491
+ }
492
+ setCenter(e) {
493
+ this.mapView.center = e;
494
+ }
495
+ getCenter() {
496
+ const e = this.mapView.center;
497
+ return E([e.longitude, e.latitude]);
498
+ }
499
+ setZoom(e) {
500
+ this.mapView.zoom = e;
501
+ }
502
+ getZoom() {
503
+ return this.mapView.zoom;
504
+ }
505
+ async fitView(e, t, i, r) {
506
+ if (e.length === 0)
507
+ return;
508
+ const a = { ...this.mapView.padding || {} };
509
+ this.mapView.padding = {
510
+ top: i[0],
511
+ bottom: i[1],
512
+ left: i[2],
513
+ right: i[3]
514
+ };
515
+ const s = e.length === 1 ? {
516
+ target: new g({
517
+ longitude: e[0][0],
518
+ latitude: e[0][1],
519
+ spatialReference: { wkid: 4326 }
520
+ }),
521
+ zoom: r ?? 18
522
+ } : {
523
+ target: new W({
524
+ points: e.map((o) => [o[0], o[1]]),
525
+ spatialReference: { wkid: 4326 }
526
+ })
527
+ };
528
+ try {
529
+ await this.mapView.goTo(s, { animate: !t }), r !== void 0 && this.mapView.zoom > r && await this.mapView.goTo(
530
+ { center: this.mapView.center, zoom: r },
531
+ { animate: !1 }
532
+ );
533
+ } catch (o) {
534
+ if ((o == null ? void 0 : o.name) !== "AbortError")
535
+ throw o;
536
+ } finally {
537
+ this.mapView.padding = a;
538
+ }
539
+ }
540
+ createInfoWindow(e, t, i) {
541
+ return {
542
+ options: { ...e },
543
+ onOpen: t,
544
+ onClose: i,
545
+ closeWatch: null,
546
+ mapClickHandle: null
547
+ };
548
+ }
549
+ openInfoWindow(e, t) {
550
+ const i = e;
551
+ this.activeInfoWindow = i, i.options.closeWhenClickMap && (i.mapClickHandle = this.mapView.on("click", () => {
552
+ this.activeInfoWindow === i && this.closeInfoWindow(i);
553
+ }));
554
+ const r = new g({
555
+ longitude: t[0],
556
+ latitude: t[1],
557
+ spatialReference: { wkid: 4326 }
558
+ });
559
+ this.mapView.openPopup({
560
+ location: r,
561
+ content: i.options.content ?? ""
562
+ }).then(() => {
563
+ this.activeInfoWindow === i && (i.onOpen(), i.closeWatch = A.watch(
564
+ () => {
565
+ var a, s;
566
+ return (s = (a = this.mapView) == null ? void 0 : a.popup) == null ? void 0 : s.visible;
567
+ },
568
+ (a) => {
569
+ a !== !1 || this.activeInfoWindow !== i || this.finishInfoWindow(i, !0);
570
+ }
571
+ ));
572
+ }).catch((a) => {
573
+ console.error("ArcGIS info window failed to open", a), this.finishInfoWindow(i, !0);
574
+ });
575
+ }
576
+ closeInfoWindow(e) {
577
+ var i, r;
578
+ const t = e;
579
+ this.activeInfoWindow === t && ((r = (i = this.mapView) == null ? void 0 : i.closePopup) == null || r.call(i), this.finishInfoWindow(t, !0));
580
+ }
581
+ destroyInfoWindow(e) {
582
+ var i, r;
583
+ const t = e;
584
+ this.activeInfoWindow === t && ((r = (i = this.mapView) == null ? void 0 : i.closePopup) == null || r.call(i)), this.finishInfoWindow(t, !1);
585
+ }
586
+ finishInfoWindow(e, t) {
587
+ var i, r;
588
+ (i = e.closeWatch) == null || i.remove(), e.closeWatch = null, (r = e.mapClickHandle) == null || r.remove(), e.mapClickHandle = null, this.activeInfoWindow === e && (this.activeInfoWindow = null), t && e.onClose();
589
+ }
590
+ resolveContainer(e) {
591
+ if (typeof e == "string") {
592
+ if (!document.getElementById(e))
593
+ throw new c("INVALID_OPTIONS", `Container not found: ${e}`);
594
+ return e;
595
+ }
596
+ if (!e)
597
+ throw new c("INVALID_OPTIONS", "A map container is required");
598
+ return e.id || (e.id = `unified-map-${Math.random().toString(36).slice(2)}`), e.id;
599
+ }
600
+ remember(e, t) {
601
+ this.overlayKinds.set(e, t);
602
+ }
603
+ createMarker(e) {
604
+ const t = e.style || { kind: "circle" }, i = new g({ longitude: e.position[0], latitude: e.position[1] }), r = t.kind === "icon" ? new O({
605
+ url: t.url,
606
+ width: t.width,
607
+ height: t.height,
608
+ yoffset: t.anchor === "bottom-center" ? t.height / 2 : 0
609
+ }) : new P({
610
+ style: "circle",
611
+ size: (t.radius ?? 8) * 2,
612
+ color: d(t.fillColor || "#1677ff", t.fillOpacity ?? 0.8),
613
+ outline: {
614
+ color: d(t.strokeColor || "#ffffff"),
615
+ width: t.strokeWeight ?? 2
616
+ }
617
+ });
618
+ return new f({ geometry: i, symbol: r });
619
+ }
620
+ createPolyline(e) {
621
+ return new f({
622
+ geometry: new V({ paths: [e.path.map((t) => [t[0], t[1]])], spatialReference: { wkid: 4326 } }),
623
+ symbol: new b({
624
+ color: d(e.strokeColor || "#3366ff", e.strokeOpacity ?? 1),
625
+ width: e.strokeWeight ?? 5,
626
+ style: e.strokeStyle === "dashed" ? "dash" : "solid"
627
+ })
628
+ });
629
+ }
630
+ createPolygon(e) {
631
+ const t = e.path.map((i) => [i[0], i[1]]);
632
+ return t.length > 0 && (t[0][0] !== t[t.length - 1][0] || t[0][1] !== t[t.length - 1][1]) && t.push(t[0]), new f({
633
+ geometry: new M({ rings: [t], spatialReference: { wkid: 4326 } }),
634
+ symbol: new I({
635
+ color: d(e.fillColor || "#3366ff", e.fillOpacity ?? 0.3),
636
+ outline: {
637
+ color: d(e.strokeColor || "#3366ff", e.strokeOpacity ?? 1),
638
+ width: e.strokeWeight ?? 3,
639
+ style: e.strokeStyle === "dashed" ? "dash" : "solid"
640
+ }
641
+ })
642
+ });
643
+ }
644
+ createMassPointLayer(e) {
645
+ var r;
646
+ const t = e.points.map((a, s) => new f({
647
+ geometry: new g({
648
+ longitude: a.position[0],
649
+ latitude: a.position[1],
650
+ spatialReference: { wkid: 4326 }
651
+ }),
652
+ attributes: {
653
+ ...a.properties || {},
654
+ __unified_object_id: s + 1
655
+ }
656
+ })), i = new k({
657
+ ...e.id ? { id: e.id, title: e.id } : {},
658
+ source: t,
659
+ fields: [{
660
+ name: "__unified_object_id",
661
+ alias: "Object ID",
662
+ type: "oid"
663
+ }],
664
+ objectIdField: "__unified_object_id",
665
+ geometryType: "point",
666
+ spatialReference: { wkid: 4326 },
667
+ renderer: new w({ symbol: this.createMassPointSymbol(e) }),
668
+ opacity: (r = e.style) != null && r.icon ? e.style.opacity ?? 1 : 1,
669
+ popupEnabled: !1,
670
+ visible: e.visible !== !1,
671
+ // ArcGIS 使用比例尺分母:minScale 是最远可见范围(较大的数),
672
+ // maxScale 是最近可见范围(较小的数),方向与 zoom 数值相反。
673
+ minScale: this.zoomToScale(e.minZoom ?? 3),
674
+ maxScale: this.zoomToScale(e.maxZoom ?? 21)
675
+ });
676
+ return i.load().catch((a) => {
677
+ console.error("ArcGIS mass point layer failed to load", a);
678
+ }), { layer: i, zIndex: e.zIndex ?? 100 };
679
+ }
680
+ createPolylineLayer(e) {
681
+ const t = e.polylines.map((r, a) => new f({
682
+ geometry: new V({
683
+ paths: [r.path.map((s) => [s[0], s[1]])],
684
+ spatialReference: { wkid: 4326 }
685
+ }),
686
+ attributes: {
687
+ ...r.properties || {},
688
+ __unified_polyline_id: a + 1
689
+ }
690
+ })), i = new k({
691
+ ...e.id ? { id: e.id, title: e.id } : {},
692
+ source: t,
693
+ fields: [{ name: "__unified_polyline_id", alias: "Object ID", type: "oid" }],
694
+ objectIdField: "__unified_polyline_id",
695
+ geometryType: "polyline",
696
+ spatialReference: { wkid: 4326 },
697
+ renderer: new w({ symbol: this.createPolylineLayerSymbol(e) }),
698
+ popupEnabled: !1,
699
+ visible: e.visible !== !1,
700
+ minScale: this.zoomToScale(e.minZoom ?? 3),
701
+ maxScale: this.zoomToScale(e.maxZoom ?? 21)
702
+ });
703
+ return i.load().catch((r) => console.error("ArcGIS polyline layer failed to load", r)), { layer: i, zIndex: e.zIndex ?? 90 };
704
+ }
705
+ createPolylineLayerSymbol(e) {
706
+ const t = e.style || {};
707
+ return new b({
708
+ color: d(t.strokeColor || "#3366ff", t.strokeOpacity ?? 1),
709
+ width: t.strokeWeight ?? 3,
710
+ style: t.strokeStyle === "dashed" ? "dash" : "solid"
711
+ });
712
+ }
713
+ createPolygonLayer(e) {
714
+ const t = e.polygons.map((r, a) => new f({
715
+ geometry: new M({
716
+ rings: [this.closeRing(r.path).map(([s, o]) => [s, o])],
717
+ spatialReference: { wkid: 4326 }
718
+ }),
719
+ attributes: {
720
+ ...r.properties || {},
721
+ __unified_polygon_id: a + 1
722
+ }
723
+ })), i = new k({
724
+ ...e.id ? { id: e.id, title: e.id } : {},
725
+ source: t,
726
+ fields: [{ name: "__unified_polygon_id", alias: "Object ID", type: "oid" }],
727
+ objectIdField: "__unified_polygon_id",
728
+ geometryType: "polygon",
729
+ spatialReference: { wkid: 4326 },
730
+ renderer: new w({ symbol: this.createPolygonLayerSymbol(e) }),
731
+ popupEnabled: !1,
732
+ visible: e.visible !== !1,
733
+ minScale: this.zoomToScale(e.minZoom ?? 3),
734
+ maxScale: this.zoomToScale(e.maxZoom ?? 21)
735
+ });
736
+ return i.load().catch((r) => console.error("ArcGIS polygon layer failed to load", r)), { layer: i, zIndex: e.zIndex ?? 80 };
737
+ }
738
+ createPolygonLayerSymbol(e) {
739
+ const t = e.style || {};
740
+ return new I({
741
+ color: d(t.fillColor || "#3366ff", t.fillOpacity ?? 0.3),
742
+ outline: {
743
+ color: d(t.strokeColor || "#3366ff", t.strokeOpacity ?? 1),
744
+ width: t.strokeWeight ?? 2,
745
+ style: t.strokeStyle === "dashed" ? "dash" : "solid"
746
+ }
747
+ });
748
+ }
749
+ createMassPointSymbol(e) {
750
+ const t = e.style || {};
751
+ if (t.icon) {
752
+ const i = t.icon.width ?? t.size ?? 20, r = t.icon.height ?? t.size ?? 20;
753
+ return new O({
754
+ url: t.icon.url,
755
+ width: i,
756
+ height: r,
757
+ yoffset: t.icon.anchor === "bottom-center" ? r / 2 : 0
758
+ });
759
+ }
760
+ return new P({
761
+ style: "circle",
762
+ size: t.size ?? 10,
763
+ color: d(t.color || "#1677ff", t.opacity ?? 0.85),
764
+ outline: {
765
+ color: d(t.borderColor || "#ffffff"),
766
+ width: t.borderWidth ?? 0
767
+ }
768
+ });
769
+ }
770
+ createScatterLayer(e) {
771
+ const t = e.points.map((r, a) => new f({
772
+ geometry: new g({
773
+ longitude: r.position[0],
774
+ latitude: r.position[1],
775
+ spatialReference: { wkid: 4326 }
776
+ }),
777
+ attributes: {
778
+ ...r.properties || {},
779
+ __unified_scatter_id: a + 1
780
+ }
781
+ })), i = new k({
782
+ ...e.id ? { id: e.id, title: e.id } : {},
783
+ source: t,
784
+ fields: [{ name: "__unified_scatter_id", alias: "Object ID", type: "oid" }],
785
+ objectIdField: "__unified_scatter_id",
786
+ geometryType: "point",
787
+ spatialReference: { wkid: 4326 },
788
+ renderer: new w({ symbol: this.createScatterSymbol(e) }),
789
+ popupEnabled: !1,
790
+ visible: e.visible !== !1,
791
+ minScale: this.zoomToScale(e.minZoom ?? 3),
792
+ maxScale: this.zoomToScale(e.maxZoom ?? 21)
793
+ });
794
+ return i.load().catch((r) => {
795
+ console.error("ArcGIS scatter layer failed to load", r);
796
+ }), { layer: i, zIndex: e.zIndex ?? 120 };
797
+ }
798
+ createScatterSymbol(e) {
799
+ const t = e.style || {}, i = t.size ?? 40, r = (t.duration ?? 2e3) / 1e3, a = (t.repeatDelay ?? 0) / 1e3, s = {
800
+ type: "CIMAnimatedSymbolProperties",
801
+ playAnimation: !0,
802
+ randomizeStartTime: t.randomizeStartTime ?? !1,
803
+ repeatType: "Loop",
804
+ repeatDelay: a,
805
+ duration: r
806
+ };
807
+ return new F({
808
+ data: {
809
+ type: "CIMSymbolReference",
810
+ symbol: {
811
+ type: "CIMPointSymbol",
812
+ symbolLayers: [{
813
+ type: "CIMPictureMarker",
814
+ enable: !0,
815
+ size: i,
816
+ scaleX: 1,
817
+ tintColor: [255, 255, 255, Math.round((t.opacity ?? 1) * 255)],
818
+ url: "/breath_red_apng.png",
819
+ animatedSymbolProperties: s
820
+ }]
821
+ }
822
+ }
823
+ });
824
+ }
825
+ destroyMassPointLayer(e) {
826
+ var t, i;
827
+ (i = (t = this.mapView) == null ? void 0 : t.map) == null || i.remove(e.layer), e.layer.destroy();
828
+ }
829
+ destroyScatterLayer(e) {
830
+ var t, i;
831
+ (i = (t = this.mapView) == null ? void 0 : t.map) == null || i.remove(e.layer), e.layer.destroy();
832
+ }
833
+ addVisualizationLayer(e) {
834
+ var r;
835
+ const t = (r = this.mapView) == null ? void 0 : r.map;
836
+ if (!t)
837
+ throw new c("SDK_ERROR", "ArcGIS map is unavailable");
838
+ const i = t.layers.indexOf(this.graphicsLayer);
839
+ i >= 0 ? t.add(e.layer, i) : t.add(e.layer);
840
+ }
841
+ updateVisualizationLayerOptions(e, t, i) {
842
+ e.layer.visible = t.visible !== !1, e.layer.minScale = this.zoomToScale(t.minZoom ?? 3), e.layer.maxScale = this.zoomToScale(t.maxZoom ?? 21), e.zIndex = t.zIndex ?? i, this.reorderVisualizationLayers();
843
+ }
844
+ replaceVisualizationLayer(e, t) {
845
+ var s;
846
+ const i = (s = this.mapView) == null ? void 0 : s.map;
847
+ if (!i)
848
+ throw new c("SDK_ERROR", "ArcGIS map is unavailable");
849
+ const r = e.layer, a = i.layers.indexOf(r);
850
+ i.remove(r), a >= 0 ? i.add(t.layer, a) : i.add(t.layer), r.destroy(), e.layer = t.layer, e.zIndex = t.zIndex, this.reorderVisualizationLayers();
851
+ }
852
+ destroyVectorLayer(e) {
853
+ var t, i;
854
+ (i = (t = this.mapView) == null ? void 0 : t.map) == null || i.remove(e.layer), e.layer.destroy();
855
+ }
856
+ closeRing(e) {
857
+ const t = e[0], i = e[e.length - 1], r = e.map((s) => [s[0], s[1]]);
858
+ (t[0] !== i[0] || t[1] !== i[1]) && r.push([t[0], t[1]]);
859
+ let a = 0;
860
+ for (let s = 0; s < r.length - 1; s += 1)
861
+ a += r[s][0] * r[s + 1][1] - r[s + 1][0] * r[s][1];
862
+ return a > 0 ? [...r].reverse() : r;
863
+ }
864
+ reorderVisualizationLayers() {
865
+ var s;
866
+ const e = (s = this.mapView) == null ? void 0 : s.map, t = [
867
+ ...this.polygonLayers,
868
+ ...this.polylineLayers,
869
+ ...this.massPointLayers,
870
+ ...this.scatterLayers
871
+ ];
872
+ if (!e || t.length === 0)
873
+ return;
874
+ const i = t.sort((o, l) => o.zIndex - l.zIndex), r = i.map((o) => e.layers.indexOf(o.layer)).filter((o) => o >= 0);
875
+ if (r.length === 0)
876
+ return;
877
+ const a = Math.min(...r);
878
+ i.forEach((o, l) => e.reorder(o.layer, a + l));
879
+ }
880
+ /** 将 Web 地图 zoom 映射为 ArcGIS 比例尺分母,用于保持统一缩放范围语义。 */
881
+ zoomToScale(e) {
882
+ return 591657527591555e-6 / Math.pow(2, e);
883
+ }
884
+ getSketchViewModel() {
885
+ return this.sketchViewModel || (this.sketchViewModel = new R({
886
+ view: this.mapView,
887
+ layer: this.graphicsLayer,
888
+ updateOnGraphicClick: !1,
889
+ // UnifiedMap 的一次 draw* 调用只对应一个覆盖物;完成后由调用方决定
890
+ // 是否再次绘制。显式指定 single,避免 SDK 配置变化后自动复用旧会话。
891
+ creationMode: "single"
892
+ })), this.sketchViewModel;
893
+ }
894
+ /**
895
+ * 释放当前 SketchViewModel,但保留外部 GraphicsLayer 及其中已完成的图形。
896
+ * 绘制与编辑操作复用同一图层,不复用 SDK 内部工具会话。
897
+ */
898
+ resetSketchViewModel() {
899
+ var t;
900
+ const e = this.sketchViewModel;
901
+ e && (e.state === "active" && e.cancel(), (t = e.destroy) == null || t.call(e), this.sketchViewModel === e && (this.sketchViewModel = null));
902
+ }
903
+ applyDrawStyle(e, t, i) {
904
+ if (t === "polyline") {
905
+ e.polylineSymbol = new b({
906
+ color: d(i.strokeColor || "#3366ff", i.strokeOpacity ?? 1),
907
+ width: i.strokeWeight ?? 5,
908
+ style: i.strokeStyle === "dashed" ? "dash" : "solid"
909
+ });
910
+ return;
911
+ }
912
+ const r = i;
913
+ e.polygonSymbol = new I({
914
+ color: d(r.fillColor || "#3366ff", r.fillOpacity ?? 0.3),
915
+ outline: {
916
+ color: d(i.strokeColor || "#3366ff", i.strokeOpacity ?? 1),
917
+ width: i.strokeWeight ?? 3,
918
+ style: i.strokeStyle === "dashed" ? "dash" : "solid"
919
+ }
920
+ });
921
+ }
922
+ finishDraw(e) {
923
+ var t, i;
924
+ e.finished || (e.finished = !0, (t = e.handle) == null || t.remove(), ((i = this.activeDraw) == null ? void 0 : i.id) === e.id && (this.activeDraw = null));
925
+ }
926
+ finishEdit(e, t) {
927
+ var r, a;
928
+ if (e.finished)
929
+ return;
930
+ const i = this.getPath(e.native);
931
+ i && e.onChange(i), e.finished = !0, (r = e.handle) == null || r.remove(), t && e.sketch.state === "active" ? e.sketch.complete() : !t && e.sketch.state === "active" && e.sketch.cancel(), ((a = this.activeEdit) == null ? void 0 : a.id) === e.id && (this.activeEdit = null);
932
+ }
933
+ toLngLat(e, t, i) {
934
+ const r = i == null ? void 0 : i.wkid, s = (i == null ? void 0 : i.isWebMercator) || r === 3857 || r === 102100 || r === 102113 ? D(e, t) : [e, t];
935
+ return E(s);
936
+ }
937
+ ensureHitTestListener() {
938
+ this.hitTestHandle || (this.hitTestHandle = this.mapView.on("click", (e) => {
939
+ this.mapView.hitTest(e).then((t) => {
940
+ var o;
941
+ const i = (o = t.results) == null ? void 0 : o.find((l) => this.overlayClickCallbacks.has(l.graphic));
942
+ if (!i)
943
+ return;
944
+ const r = this.overlayClickCallbacks.get(i.graphic);
945
+ if (!r || !e.mapPoint)
946
+ return;
947
+ const a = this.toLngLat(e.mapPoint.x, e.mapPoint.y, e.mapPoint.spatialReference), s = {
948
+ lnglat: { lng: a[0], lat: a[1] },
949
+ position: a,
950
+ coordinateSystem: this.coordinateSystem,
951
+ originalEvent: e
952
+ };
953
+ r.forEach((l) => l(s));
954
+ }).catch((t) => {
955
+ console.error("ArcGIS hitTest failed", t);
956
+ });
957
+ }));
958
+ }
959
+ }
960
+ export {
961
+ ye as ArcGISAdapter
962
+ };