hy-dispatch-ui-v3 0.2.53 → 0.2.55

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 (116) hide show
  1. package/dist/tailwind.css +53 -0
  2. package/es/components/hyBatchUploadDialog/batchUploadDialog.vue.mjs +39 -10
  3. package/es/components/hyConfirmDialog/confirmDialog.vue.mjs +12 -22
  4. package/es/components/hyDialog/dialog.vue.mjs +9 -7
  5. package/es/components/hyForm/cpns/arrayItem.vue.mjs +5 -5
  6. package/es/components/hyForm/cpns/extraItem.vue.mjs +6 -1
  7. package/es/components/hyForm/cpns/formItem.vue.mjs +29 -14
  8. package/es/components/hyForm/js/index.mjs +29 -25
  9. package/es/components/hyForm/js/useAppForm.mjs +15 -30
  10. package/es/components/hyIconBox/iconBox.vue.mjs +1 -1
  11. package/es/components/hyIconBox/style/iconBox.scss +1 -1
  12. package/es/components/hyMap/index.mjs +6 -0
  13. package/es/components/hyMap/js/index.mjs +59 -0
  14. package/es/components/hyMap/map.vue.mjs +59 -0
  15. package/es/components/hyOrgCascader/js/index.mjs +53 -0
  16. package/es/components/hyOrgCascader/orgCascader.vue.mjs +22 -25
  17. package/es/components/hySearch/search.vue.mjs +6 -8
  18. package/es/components/hyTable/cpns/columnSelect.vue.mjs +10 -18
  19. package/es/components/hyTable/table.vue.mjs +8 -11
  20. package/es/components/hyTableActionButton/tableActionButton.vue.mjs +6 -3
  21. package/es/components/hyTableForm/batchTableForm.vue.mjs +182 -135
  22. package/es/components/hyTableForm/js/index.mjs +2 -2
  23. package/es/components/hyTableForm/tableForm.vue.mjs +29 -20
  24. package/es/components/hyTooltip/tooltip.vue.mjs +1 -1
  25. package/es/components/hyTree/js/index.mjs +5 -4
  26. package/es/components/hyTree/tree.vue.mjs +5 -0
  27. package/es/components/index.mjs +1 -0
  28. package/es/hooks/index.mjs +1 -0
  29. package/es/hooks/useApi.mjs +11 -5
  30. package/es/hooks/useAudioPlayerConfig.mjs +13 -5
  31. package/es/hooks/useEnsureHyIcon.mjs +11 -5
  32. package/es/hooks/useLocale.mjs +6 -5
  33. package/es/hooks/usePermissionMap.mjs +13 -5
  34. package/es/hooks/useSubscribe.mjs +28 -0
  35. package/es/hooks/useTooltipConfig.mjs +11 -5
  36. package/es/hooks/useUserAvatarMap.mjs +13 -5
  37. package/es/hooks/useVideoPlayerConfig.mjs +13 -5
  38. package/es/index.mjs +3 -2
  39. package/es/static/map/CFCASIPInput.min.js +258 -0
  40. package/es/static/map/MarkerCluster.css +75 -0
  41. package/es/static/map/bigemap.css +838 -0
  42. package/es/static/map/bigemap.js +5 -0
  43. package/es/static/map/bm.geometryutil.js +754 -0
  44. package/es/static/map/bmDraw.css +329 -0
  45. package/es/static/map/bmDraw.js +181 -0
  46. package/es/static/map/car.png +0 -0
  47. package/es/static/map/markercluster.js +2679 -0
  48. package/es/static/map/moveMarker.js +74 -0
  49. package/es/utils/form.mjs +38 -2
  50. package/es/utils/index.mjs +1 -2
  51. package/es/utils/map/hook/bigMap.mjs +1136 -0
  52. package/es/utils/map/hook/gaode.mjs +683 -0
  53. package/es/utils/map/hook/leafletjs.mjs +1336 -0
  54. package/es/utils/map/index.mjs +291 -0
  55. package/es/utils/map/js/mapProxy.mjs +38 -0
  56. package/es/utils/map/js/webgis.mjs +153 -0
  57. package/es/version.mjs +1 -1
  58. package/lib/components/hyBatchUploadDialog/batchUploadDialog.vue.js +40 -11
  59. package/lib/components/hyConfirmDialog/confirmDialog.vue.js +13 -23
  60. package/lib/components/hyDialog/dialog.vue.js +9 -7
  61. package/lib/components/hyForm/cpns/arrayItem.vue.js +4 -4
  62. package/lib/components/hyForm/cpns/extraItem.vue.js +6 -1
  63. package/lib/components/hyForm/cpns/formItem.vue.js +26 -11
  64. package/lib/components/hyForm/js/index.js +29 -23
  65. package/lib/components/hyForm/js/useAppForm.js +14 -29
  66. package/lib/components/hyIconBox/iconBox.vue.js +1 -1
  67. package/lib/components/hyIconBox/style/iconBox.scss +1 -1
  68. package/lib/components/hyMap/index.js +11 -0
  69. package/lib/components/hyMap/js/index.js +61 -0
  70. package/lib/components/hyMap/map.vue.js +63 -0
  71. package/lib/components/hyOrgCascader/js/index.js +56 -0
  72. package/lib/components/hyOrgCascader/orgCascader.vue.js +21 -24
  73. package/lib/components/hySearch/search.vue.js +4 -6
  74. package/lib/components/hyTable/cpns/columnSelect.vue.js +12 -20
  75. package/lib/components/hyTable/table.vue.js +17 -20
  76. package/lib/components/hyTableActionButton/tableActionButton.vue.js +5 -2
  77. package/lib/components/hyTableForm/batchTableForm.vue.js +181 -134
  78. package/lib/components/hyTableForm/js/index.js +1 -1
  79. package/lib/components/hyTableForm/tableForm.vue.js +29 -20
  80. package/lib/components/hyTooltip/tooltip.vue.js +1 -1
  81. package/lib/components/hyTree/js/index.js +5 -4
  82. package/lib/components/hyTree/tree.vue.js +5 -0
  83. package/lib/components/index.js +22 -20
  84. package/lib/hooks/index.js +3 -0
  85. package/lib/hooks/useApi.js +10 -4
  86. package/lib/hooks/useAudioPlayerConfig.js +12 -4
  87. package/lib/hooks/useEnsureHyIcon.js +10 -4
  88. package/lib/hooks/useLocale.js +5 -4
  89. package/lib/hooks/usePermissionMap.js +12 -4
  90. package/lib/hooks/useSubscribe.js +31 -0
  91. package/lib/hooks/useTooltipConfig.js +10 -4
  92. package/lib/hooks/useUserAvatarMap.js +12 -4
  93. package/lib/hooks/useVideoPlayerConfig.js +12 -4
  94. package/lib/index.js +27 -22
  95. package/lib/static/map/CFCASIPInput.min.js +258 -0
  96. package/lib/static/map/MarkerCluster.css +75 -0
  97. package/lib/static/map/bigemap.css +838 -0
  98. package/lib/static/map/bigemap.js +5 -0
  99. package/lib/static/map/bm.geometryutil.js +754 -0
  100. package/lib/static/map/bmDraw.css +329 -0
  101. package/lib/static/map/bmDraw.js +181 -0
  102. package/lib/static/map/car.png +0 -0
  103. package/lib/static/map/markercluster.js +2679 -0
  104. package/lib/static/map/moveMarker.js +74 -0
  105. package/lib/utils/form.js +38 -0
  106. package/lib/utils/index.js +2 -2
  107. package/lib/utils/map/hook/bigMap.js +1140 -0
  108. package/lib/utils/map/hook/gaode.js +687 -0
  109. package/lib/utils/map/hook/leafletjs.js +1360 -0
  110. package/lib/utils/map/index.js +298 -0
  111. package/lib/utils/map/js/mapProxy.js +44 -0
  112. package/lib/utils/map/js/webgis.js +162 -0
  113. package/lib/version.js +1 -1
  114. package/package.json +16 -1
  115. package/es/utils/bus.mjs +0 -5
  116. package/lib/utils/bus.js +0 -7
@@ -0,0 +1,1136 @@
1
+ import L from 'leaflet';
2
+ import { EventEmitter } from 'events';
3
+ import { importCoordinate, exportCoordinate } from '../js/webgis.mjs';
4
+ import { createMapProxy, createWrappedHandlerStore } from '../js/mapProxy.mjs';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
9
+ const CIRCLE_SEGMENTS = 36;
10
+ function remToPx(rem) {
11
+ const rootFontSize = parseFloat(
12
+ getComputedStyle(document.documentElement).fontSize
13
+ );
14
+ return rem * rootFontSize;
15
+ }
16
+ function rangingStartIconOption(options, dicId) {
17
+ return {
18
+ html: `<div style="width:32px;height:32px;border-radius:9999px;background-color:${options.labelColor || "#2df2ff3f"};display:flex;justify-content:center;align-items:center;position:relative;">
19
+ <div style="width:12px;height:12px;border-radius:9999px;background-color:${options.labelFillColor || "#fff"};border:1px solid ${options.lineColor || "#2df2ff"};"></div>
20
+ <div style="position:absolute;left:0;top:32px;padding-left:4px;padding-right:4px;font-size:12px;line-height:16px;background-color:#fff;border:1px solid #000;color:#000;white-space:nowrap;">\u8D77\u70B9
21
+ <i data-id="${dicId}" class="el-icon-close"></i></div>
22
+ </div>`,
23
+ className: "my-div-icon",
24
+ iconSize: [remToPx(2), remToPx(2)],
25
+ iconAnchor: [remToPx(1), remToPx(1)]
26
+ };
27
+ }
28
+ function rangingPointIconOption(options, distance, dicId, showDeleteAll = false) {
29
+ return {
30
+ html: `<div style="width:12px;height:12px;border-radius:9999px;background-color:${options.labelFillColor || "#fff"};border:1px solid ${options.lineColor || "#2df2ff"};position:relative;">
31
+ <div style="position:absolute;left:0;top:12px;padding-left:4px;padding-right:4px;font-size:12px;line-height:16px;background-color:#fff;border:1px solid #000;color:#000;white-space:nowrap;">${distance}km
32
+ <i data-id="${dicId}" class="el-icon-close"></i>
33
+ ${showDeleteAll ? '<i data-id="delete-all" class="el-icon-delete"></i>' : ""}
34
+ </div>
35
+ </div>`,
36
+ className: "my-div-icon",
37
+ iconSize: [remToPx(0.75), remToPx(0.75)],
38
+ iconAnchor: [remToPx(0.375), remToPx(0.375)]
39
+ };
40
+ }
41
+ function circleToPolygonPoints(center, radius, asObject = false) {
42
+ const points = [];
43
+ const angleStep = Math.PI * 2 / CIRCLE_SEGMENTS;
44
+ for (let i = 0; i < CIRCLE_SEGMENTS; i++) {
45
+ const angle = angleStep * i;
46
+ const lat = center.lat + radius * Math.cos(angle) / 111.32;
47
+ const lng = center.lng + radius * Math.sin(angle) / (111.32 * Math.cos(center.lat * Math.PI / 180));
48
+ points.push(asObject ? { lat, lng } : [lat, lng]);
49
+ }
50
+ return points;
51
+ }
52
+ const generalMapMethods = {
53
+ // 导入到地图里面
54
+ getBounds: function(target) {
55
+ const bounds = target.getBounds();
56
+ let southWest = bounds.getSouthWest();
57
+ let northEast = bounds.getNorthEast();
58
+ let center = bounds.getCenter();
59
+ bounds.getSouthWest = function() {
60
+ const { lat, lng } = latAndLngCheck(southWest);
61
+ return { lat, lng };
62
+ };
63
+ bounds.getNorthEast = function() {
64
+ const { lat, lng } = latAndLngCheck(northEast);
65
+ return { lat, lng };
66
+ };
67
+ bounds.getCenter = function() {
68
+ const { lat, lng } = latAndLngCheck(center);
69
+ return { lat, lng };
70
+ };
71
+ return bounds;
72
+ },
73
+ getMap: function(map) {
74
+ return createMapProxy(map, {
75
+ getCenter: function(target) {
76
+ const center = target.getCenter();
77
+ const { lng, lat } = latAndLngCheck(center);
78
+ return { lat, lng };
79
+ }
80
+ });
81
+ },
82
+ // 导出到外面
83
+ getBoundsExport: function(target) {
84
+ const bounds = target.getBounds();
85
+ let southWest = bounds.getSouthWest();
86
+ let northEast = bounds.getNorthEast();
87
+ let center = bounds.getCenter();
88
+ bounds.getSouthWest = function() {
89
+ const { lat, lng } = latAndLngCheckExport(southWest);
90
+ return { lat, lng };
91
+ };
92
+ bounds.getNorthEast = function() {
93
+ const { lat, lng } = latAndLngCheckExport(northEast);
94
+ return { lat, lng };
95
+ };
96
+ bounds.getCenter = function() {
97
+ const { lat, lng } = latAndLngCheckExport(center);
98
+ return { lat, lng };
99
+ };
100
+ return bounds;
101
+ }
102
+ };
103
+ function latAndLngCheck(item) {
104
+ const type = Array.isArray(item);
105
+ if (type) {
106
+ return importCoordinate({
107
+ lat: item[0],
108
+ lng: item[1]
109
+ });
110
+ } else {
111
+ return importCoordinate({
112
+ lat: item.lat,
113
+ lng: item.lng
114
+ });
115
+ }
116
+ }
117
+ function latAndLngCheckExport(item) {
118
+ const type = Array.isArray(item);
119
+ if (type) {
120
+ return exportCoordinate({
121
+ lat: item[0],
122
+ lng: item[1]
123
+ });
124
+ } else {
125
+ return exportCoordinate({
126
+ lat: item.lat,
127
+ lng: item.lng
128
+ });
129
+ }
130
+ }
131
+ function latLngListCheck(dataList = []) {
132
+ const newDataList = [];
133
+ for (let i = 0; i < dataList.length; i++) {
134
+ const item = dataList[i];
135
+ const type = Array.isArray(item);
136
+ let { lat, lng } = latAndLngCheck(item);
137
+ if (type) {
138
+ newDataList.push([lat, lng]);
139
+ } else {
140
+ newDataList.push({
141
+ ...item,
142
+ lat,
143
+ lng
144
+ });
145
+ }
146
+ }
147
+ return newDataList;
148
+ }
149
+ function latLngListCheckExport(dataList = []) {
150
+ const newDataList = [];
151
+ for (let i = 0; i < dataList.length; i++) {
152
+ const item = dataList[i];
153
+ const type = Array.isArray(item);
154
+ let { lat, lng } = latAndLngCheckExport(item);
155
+ if (type) {
156
+ newDataList.push([lat, lng]);
157
+ } else {
158
+ newDataList.push({
159
+ ...item,
160
+ lat,
161
+ lng
162
+ });
163
+ }
164
+ }
165
+ return newDataList;
166
+ }
167
+ class bigMap extends EventEmitter {
168
+ constructor(request) {
169
+ super();
170
+ // 绘画多边形覆盖物
171
+ __publicField(this, "Polygon", (pathList = [], option) => {
172
+ if (pathList && pathList.length !== 0) {
173
+ pathList = latLngListCheck(pathList);
174
+ }
175
+ const polygon = new this.BM.Polygon([pathList], option);
176
+ const wrappedHandlers = createWrappedHandlerStore();
177
+ const handlers = {
178
+ addTo: function(target, map) {
179
+ return target.addTo(generalMapMethods.getMap(map));
180
+ },
181
+ // 修改位置
182
+ getBounds: function(target) {
183
+ return generalMapMethods.getBoundsExport(target);
184
+ },
185
+ getLatLngs: function(target) {
186
+ const latLngList = target.getLatLngs();
187
+ const item = JSON.parse(JSON.stringify(latLngList[0]));
188
+ return [latLngListCheckExport([...item])];
189
+ },
190
+ on: function(target, types, fn, context) {
191
+ if (types === "click") {
192
+ const customClickHandler = (e) => {
193
+ const newEvent = { ...e };
194
+ const { lat, lng } = latAndLngCheckExport(newEvent.latlng);
195
+ newEvent.latlng = L.latLng(lat, lng);
196
+ fn.call(context || target, newEvent);
197
+ };
198
+ wrappedHandlers.remember(types, fn, customClickHandler);
199
+ return target.on(types, customClickHandler, context);
200
+ }
201
+ return target.on(types, fn, context);
202
+ },
203
+ off: function(target, types, fn, context) {
204
+ const wrappedFn = wrappedHandlers.take(types, fn);
205
+ return target.off(types, wrappedFn || fn, context);
206
+ }
207
+ };
208
+ return createMapProxy(polygon, handlers);
209
+ });
210
+ this.initParams = request;
211
+ }
212
+ // 初始化地图
213
+ InitMap(domId, option) {
214
+ this.BM = this.initParams.BM;
215
+ this.BM.Config.HTTP_URL = this.initParams.bmHttpsUrl;
216
+ this.BM.Config.HTTPS_URL = this.initParams.bmHttpsUrl;
217
+ const { center } = option;
218
+ const { lat, lng } = latAndLngCheck([center.lat, center.lng]);
219
+ const crsJons = {};
220
+ if (this.initParams.crs) {
221
+ crsJons.crs = this.BM.CRS[`${this.initParams.crs}`];
222
+ }
223
+ const load = () => {
224
+ if (option.completeCallbacks) {
225
+ option.completeCallbacks();
226
+ }
227
+ };
228
+ const newMap = this.BM.map(domId, this.initParams.bmUiName, {
229
+ ...crsJons,
230
+ center: [lat, lng],
231
+ minZoom: option.minZoom,
232
+ maxZoom: option.maxZoom,
233
+ zoom: option.zoom,
234
+ zoomControl: false,
235
+ attributionControl: false,
236
+ load: load()
237
+ });
238
+ const wrappedHandlers = createWrappedHandlerStore();
239
+ const handlers = {
240
+ // 获取原始地图实例(不经过代理)
241
+ getRawMap: function(target) {
242
+ return target;
243
+ },
244
+ // 删除地图
245
+ removeMap: function(target, params) {
246
+ if (!params) {
247
+ target.remove();
248
+ target.off();
249
+ }
250
+ },
251
+ fitBounds: function(target, params) {
252
+ if (!Array.isArray(params)) {
253
+ params = [params];
254
+ }
255
+ const fitBoundsList = params.map(
256
+ (item) => createMapProxy(item, {
257
+ getBounds: (boundsTarget) => generalMapMethods.getBounds(boundsTarget)
258
+ })
259
+ );
260
+ return target.fitBounds(fitBoundsList);
261
+ },
262
+ // 获取中心点
263
+ getCenter: function(target) {
264
+ const center2 = target.getCenter();
265
+ return latAndLngCheckExport(center2);
266
+ },
267
+ // 四个角
268
+ getBounds: function(target) {
269
+ const bounds = target.getBounds();
270
+ let southWest = bounds.getSouthWest();
271
+ let northEast = bounds.getNorthEast();
272
+ bounds.getSouthWest = function() {
273
+ return latAndLngCheckExport(southWest);
274
+ };
275
+ bounds.getNorthEast = function() {
276
+ return latAndLngCheckExport(northEast);
277
+ };
278
+ return bounds;
279
+ },
280
+ // 移动至目标位置
281
+ panTo: function(target, center2, options) {
282
+ const { lat: lat2, lng: lng2 } = latAndLngCheck(center2);
283
+ return target.panTo({ lat: lat2, lng: lng2 }, options);
284
+ },
285
+ // 移动至目标位置并缩放图层
286
+ setView: function(target, center2, zoom, options) {
287
+ const { lat: lat2, lng: lng2 } = latAndLngCheck(center2);
288
+ return target.setView({ lat: lat2, lng: lng2 }, zoom, options);
289
+ },
290
+ // 自定义地图
291
+ on: function(target, types, fn, context) {
292
+ if (types === "click") {
293
+ const customClickHandler = (e) => {
294
+ const newEvent = { ...e };
295
+ newEvent.latlng = latAndLngCheckExport(newEvent.latlng);
296
+ fn.call(context || target, newEvent);
297
+ };
298
+ wrappedHandlers.remember(types, fn, customClickHandler);
299
+ return target.on(types, customClickHandler, context);
300
+ } else if (types === "pm:create") {
301
+ const customClickHandler = (e) => {
302
+ const newEvent = { ...e };
303
+ const bounds = newEvent.layer.getBounds();
304
+ if (!newEvent.layer.getLatLngs) {
305
+ newEvent.layer.getLatLngs = () => {
306
+ const circle = newEvent.layer;
307
+ const points = circleToPolygonPoints(
308
+ circle.getLatLng(),
309
+ circle.getRadius() / 1e3,
310
+ true
311
+ );
312
+ return [latLngListCheckExport(points)];
313
+ };
314
+ } else {
315
+ const latLngList = newEvent.layer.getLatLngs();
316
+ newEvent.layer.getLatLngs = () => {
317
+ const item = JSON.parse(JSON.stringify(latLngList[0]));
318
+ return [latLngListCheckExport([...item])];
319
+ };
320
+ }
321
+ newEvent.layer.getBounds = () => {
322
+ let southWest = bounds.getSouthWest();
323
+ let northEast = bounds.getNorthEast();
324
+ bounds.getSouthWest = function() {
325
+ return latAndLngCheckExport(southWest);
326
+ };
327
+ bounds.getNorthEast = function() {
328
+ return latAndLngCheckExport(northEast);
329
+ };
330
+ return bounds;
331
+ };
332
+ fn.call(context || target, newEvent);
333
+ };
334
+ wrappedHandlers.remember(types, fn, customClickHandler);
335
+ return target.on(types, customClickHandler, context);
336
+ }
337
+ return target.on(types, fn, context);
338
+ },
339
+ off: function(target, types, fn, context) {
340
+ const wrappedFn = wrappedHandlers.take(types, fn);
341
+ return target.off(types, wrappedFn || fn, context);
342
+ }
343
+ };
344
+ return createMapProxy(newMap, handlers);
345
+ }
346
+ // 地图图层
347
+ layerGroup(map, markers = []) {
348
+ const layerGroup = this.BM.layerGroup(markers);
349
+ layerGroup.addTo(map);
350
+ return layerGroup;
351
+ }
352
+ // 自定义图标
353
+ DivIcon(option) {
354
+ option = {
355
+ ...option,
356
+ html: option.html,
357
+ className: option.className,
358
+ iconSize: option.iconSize,
359
+ iconAnchor: option.iconAnchor
360
+ };
361
+ return this.BM.divIcon(option);
362
+ }
363
+ // 生成 marker
364
+ Marker(markerOptions) {
365
+ const { position = {} } = markerOptions;
366
+ markerOptions = {
367
+ ...markerOptions,
368
+ position: [position.lat, position.lng],
369
+ icon: markerOptions.icon,
370
+ pane: markerOptions.pane || "markerPane"
371
+ };
372
+ if (markerOptions.position && markerOptions.position.length !== 0) {
373
+ const { lat, lng } = latAndLngCheck(markerOptions.position);
374
+ markerOptions.position = [lat, lng];
375
+ }
376
+ const marker = new this.BM.marker(markerOptions.position, markerOptions);
377
+ marker.getInitMarker = () => {
378
+ return marker;
379
+ };
380
+ marker.extData = markerOptions.extData || null;
381
+ const wrappedHandlers = createWrappedHandlerStore();
382
+ const handlers = {
383
+ getLatLng: function(target) {
384
+ const latlng = target.getLatLng();
385
+ const { lat, lng } = latAndLngCheckExport(latlng);
386
+ return { lat, lng };
387
+ },
388
+ // 更改标记位置。
389
+ setLatLng: function(target, lngAndLat) {
390
+ const { lat, lng } = latAndLngCheck(lngAndLat);
391
+ target.setLatLng([lat, lng]);
392
+ },
393
+ // 更改标记图标。
394
+ setIcon: function(target, iconParams) {
395
+ target.setIcon(iconParams.divIcon);
396
+ },
397
+ on: function(target, types, fn, context) {
398
+ if (types === "click") {
399
+ const customClickHandler = (e) => {
400
+ const newEvent = { ...e, originEvent: e.originalEvent };
401
+ const { lat, lng } = latAndLngCheckExport(newEvent.latlng);
402
+ newEvent.latlng = { lat, lng };
403
+ fn.call(context || target, newEvent);
404
+ };
405
+ wrappedHandlers.remember(types, fn, customClickHandler);
406
+ return target.on(types, customClickHandler, context);
407
+ }
408
+ return target.on(types, fn, context);
409
+ },
410
+ off: function(target, types, fn, context) {
411
+ const wrappedFn = wrappedHandlers.take(types, fn);
412
+ return target.off(types, wrappedFn || fn, context);
413
+ }
414
+ };
415
+ return createMapProxy(marker, handlers);
416
+ }
417
+ // 生成 聚合点
418
+ MarkerClusterGroup(map, markerList, option) {
419
+ option = {
420
+ showCoverageOnHover: false,
421
+ zoomToBoundsOnClick: true,
422
+ removeOutsideVisibleBounds: true,
423
+ spiderfyDistanceMultiplier: 1,
424
+ spiderLegPolylineOptions: { weight: 1, color: "#5E9DB4", opacity: 1 },
425
+ ...option,
426
+ iconCreateFunction: option.iconCreateFunction,
427
+ disableClusteringAtZoom: option.disableClusteringAtZoom,
428
+ maxClusterRadius: option.maxClusterRadius
429
+ };
430
+ const displayCluster = new this.BM.MarkerClusterGroup(option);
431
+ map.addLayer(displayCluster);
432
+ const toNativeMarkers = (list = []) => {
433
+ const markers = Array.isArray(list) ? list : [list];
434
+ return markers.map(
435
+ (marker) => marker?.getInitMarker ? marker.getInitMarker() : marker
436
+ ).filter(Boolean);
437
+ };
438
+ const handlers = {
439
+ remove: function(target) {
440
+ target.remove();
441
+ },
442
+ removeLayers: function(target, markerList2 = []) {
443
+ target.removeLayers(toNativeMarkers(markerList2));
444
+ },
445
+ addLayers: function(target, markerList2 = []) {
446
+ target.addLayers(toNativeMarkers(markerList2));
447
+ }
448
+ };
449
+ const newDisplayCluster = createMapProxy(displayCluster, handlers);
450
+ newDisplayCluster.addLayers(markerList);
451
+ return newDisplayCluster;
452
+ }
453
+ // 绘画圆
454
+ Circle(latLngList = {}, option = {}) {
455
+ option = {
456
+ ...option,
457
+ radius: option.radius,
458
+ color: option.color,
459
+ opacity: option.opacity,
460
+ weight: option.weight,
461
+ fillColor: option.fillColor,
462
+ fillOpacity: option.fillOpacity
463
+ };
464
+ const { lat, lng } = latAndLngCheck(latLngList);
465
+ latLngList = [lat, lng];
466
+ const circle = new this.BM.Circle(latLngList, option);
467
+ const handlers = {
468
+ // 添加到地图
469
+ addTo: function(target, map) {
470
+ return target.addTo(generalMapMethods.getMap(map));
471
+ },
472
+ // 修改位置
473
+ getBounds: function(target) {
474
+ return generalMapMethods.getBoundsExport(target);
475
+ },
476
+ // 圆形转多边形坐标
477
+ getLatLngs: function(target) {
478
+ const points = circleToPolygonPoints(
479
+ target.getLatLng(),
480
+ target.getRadius() / 1e3
481
+ );
482
+ return [latLngListCheckExport(points)];
483
+ }
484
+ };
485
+ return createMapProxy(circle, handlers);
486
+ }
487
+ // 自定义 popup
488
+ Popup(option) {
489
+ option = {
490
+ closeButton: false,
491
+ ...option
492
+ };
493
+ const popup = new this.BM.Popup(option);
494
+ const handlers = {
495
+ addTo: function(target, map) {
496
+ return target.addTo(generalMapMethods.getMap(map));
497
+ },
498
+ // 修改位置
499
+ getBounds: function(target) {
500
+ return generalMapMethods.getBoundsExport(target);
501
+ },
502
+ // 修改位置
503
+ setLatLng: function(target, latLngList) {
504
+ if (latLngList && latLngList.length !== 0) {
505
+ latLngList = latAndLngCheck(latLngList);
506
+ }
507
+ return target.setLatLng(latLngList);
508
+ }
509
+ };
510
+ return createMapProxy(popup, handlers);
511
+ }
512
+ // 自定义 线条
513
+ Polyline(latLngList = [], option = {}) {
514
+ if (latLngList && latLngList.length !== 0) {
515
+ latLngList = latLngListCheck(latLngList);
516
+ }
517
+ const polyline = this.BM.polyline(latLngList, option);
518
+ const wrappedHandlers = createWrappedHandlerStore();
519
+ const handlers = {
520
+ addTo: function(target, map) {
521
+ return target.addTo(generalMapMethods.getMap(map));
522
+ },
523
+ // 修改位置
524
+ getBounds: function(target) {
525
+ return generalMapMethods.getBoundsExport(target);
526
+ },
527
+ on: function(target, types, fn, context) {
528
+ if (types === "click") {
529
+ const customClickHandler = (e) => {
530
+ const newEvent = { ...e };
531
+ const { lat, lng } = latAndLngCheckExport(newEvent.latlng);
532
+ newEvent.latlng = { lat, lng };
533
+ fn.call(context || target, newEvent);
534
+ };
535
+ wrappedHandlers.remember(types, fn, customClickHandler);
536
+ return target.on(types, customClickHandler, context);
537
+ }
538
+ return target.on(types, fn, context);
539
+ },
540
+ off: function(target, types, fn, context) {
541
+ const wrappedFn = wrappedHandlers.take(types, fn);
542
+ return target.off(types, wrappedFn || fn, context);
543
+ }
544
+ };
545
+ return createMapProxy(polyline, handlers);
546
+ }
547
+ // 轨迹回放
548
+ TrackPlayer(latLngList = [], option = {}, map = null) {
549
+ let monitorTrack = null;
550
+ let speed = option.speed;
551
+ let polyline = this.Polyline(latLngList, {
552
+ color: option.notPassedLineColor || "#FF1875",
553
+ // 线颜色
554
+ weight: 4
555
+ }).addTo(map);
556
+ let passedPolyline = this.Polyline([], {
557
+ color: option.passedLineColor || "#2EE19E",
558
+ // 线颜色
559
+ weight: 4
560
+ }).addTo(map);
561
+ let marker = this.Marker({
562
+ position: latLngList[0],
563
+ icon: this.DivIcon({
564
+ html: option.svgContent,
565
+ className: "my-div-icon",
566
+ iconSize: option.iconSize || 0,
567
+ iconAnchor: option.iconAnchor || 0
568
+ })
569
+ }).addTo(map);
570
+ marker.on("update_position", (e) => {
571
+ passedPolyline.setLatLngs(e.path);
572
+ if (monitorTrack) {
573
+ clearTimeout(monitorTrack);
574
+ }
575
+ monitorTrack = setTimeout(() => {
576
+ if (option.onEnd) option.onEnd();
577
+ }, 500);
578
+ });
579
+ map.setView(latLngList[0], 18);
580
+ const moveAlong = () => {
581
+ if (!marker) return;
582
+ marker.moveAlong(latLngList, speed / 3.6, {
583
+ replay: false
584
+ });
585
+ };
586
+ const handlers = {
587
+ // 开始
588
+ startAnimation: function() {
589
+ moveAlong();
590
+ },
591
+ // 暂停
592
+ pauseAnimation: function() {
593
+ if (marker) {
594
+ marker.pauseMove();
595
+ if (monitorTrack) {
596
+ clearTimeout(monitorTrack);
597
+ }
598
+ }
599
+ },
600
+ // 恢复
601
+ resumeAnimation: function() {
602
+ if (marker) {
603
+ marker.resumeMove();
604
+ }
605
+ },
606
+ // 修改速度
607
+ motionSpeed: function(target, changeSpeed) {
608
+ speed = changeSpeed;
609
+ moveAlong();
610
+ },
611
+ // 移除轨迹回放
612
+ removeTrackPlayer: function() {
613
+ marker.remove();
614
+ polyline.remove();
615
+ passedPolyline.remove();
616
+ marker = null;
617
+ polyline = null;
618
+ passedPolyline = null;
619
+ if (monitorTrack) {
620
+ clearTimeout(monitorTrack);
621
+ monitorTrack = null;
622
+ }
623
+ }
624
+ };
625
+ return createMapProxy(marker, handlers);
626
+ }
627
+ /**
628
+ *
629
+ * @param {*} pmType 创建绘画工具 rectangle 正方形 circle 圆形 polygon 多边形
630
+ * @param {*} options circleClick 解决直接点击时圆形绘制无效问题,绘制电子围栏时为false防止与定点绘制冲突
631
+ * @param {*} map 地图实例
632
+ * @returns
633
+ */
634
+ CreatePm(pmType = "rectangle", options = { circleClick: true }, map) {
635
+ const rawMap = map.getRawMap ? map.getRawMap() : map;
636
+ const Draw = {};
637
+ Draw.draw = {
638
+ rectangle: new this.BM.Draw.Rectangle(rawMap),
639
+ circle: new this.BM.Draw.Circle(rawMap),
640
+ polygon: new this.BM.Draw.Polygon(rawMap)
641
+ };
642
+ let mouseToolName = pmType;
643
+ Draw.draw[`${pmType}`].enable();
644
+ Draw.current = pmType;
645
+ let layer = null;
646
+ let isEnd = false;
647
+ rawMap.on(this.BM.Draw.Event.CREATED, (e) => {
648
+ isEnd = true;
649
+ layer = e.layer;
650
+ if (!layer._latlngs) {
651
+ const center = latAndLngCheckExport(layer.getLatLng());
652
+ layer._latlngs = [
653
+ circleToPolygonPoints(center, layer.getRadius() / 1e3, true)
654
+ ];
655
+ } else {
656
+ layer._latlngs[0] = latLngListCheckExport(layer._latlngs[0]);
657
+ }
658
+ layer.addTo(rawMap);
659
+ if (options.onChange) {
660
+ options.onChange(layer._latlngs[0]);
661
+ }
662
+ });
663
+ const mapClick = () => {
664
+ if (mouseToolName === "circle" && !isEnd) {
665
+ Draw.draw[`${mouseToolName}`].disable();
666
+ setTimeout(() => {
667
+ Draw.draw[`${mouseToolName}`].enable();
668
+ Draw.current = mouseToolName;
669
+ });
670
+ }
671
+ isEnd = false;
672
+ };
673
+ if (options.circleClick) {
674
+ map.on("click", mapClick);
675
+ }
676
+ const handlers = {
677
+ remove: function(target) {
678
+ Draw.draw.rectangle.disable();
679
+ Draw.draw.circle.disable();
680
+ Draw.draw.polygon.disable();
681
+ rawMap.off(BM.Draw.Event.CREATED);
682
+ Draw.draw = null;
683
+ mouseToolName = null;
684
+ layer?.remove();
685
+ layer = null;
686
+ map.off("click", mapClick);
687
+ },
688
+ close: function(target) {
689
+ layer?.remove();
690
+ if (mouseToolName) {
691
+ Draw.draw[`${mouseToolName}`].disable();
692
+ }
693
+ },
694
+ setMouseTool: function(target, toolType) {
695
+ if (mouseToolName) {
696
+ Draw.draw[`${mouseToolName}`].disable();
697
+ }
698
+ setTimeout(() => {
699
+ mouseToolName = toolType;
700
+ Draw.draw[`${mouseToolName}`].enable();
701
+ Draw.current = mouseToolName;
702
+ isEnd = false;
703
+ });
704
+ }
705
+ };
706
+ return createMapProxy({}, handlers);
707
+ }
708
+ // 电子围栏
709
+ CreateFence(pmType = "rectangle", options = {}, map) {
710
+ let polygon = null;
711
+ const clearPolygon = () => {
712
+ if (polygon) {
713
+ polygon.remove();
714
+ polygon = null;
715
+ }
716
+ };
717
+ const setPolygon = (pointList) => {
718
+ clearPolygon();
719
+ polygon = this.Polygon(pointList, {
720
+ ...options,
721
+ fillColor: options.fillColor || "#00b0ff",
722
+ fillOpacity: options.fillOpacity || 0.5,
723
+ color: options.color || "#80d8ff",
724
+ weight: options.weight || 4,
725
+ opacity: options.opacity || 1,
726
+ zIndex: options.zIndex || 1e6
727
+ });
728
+ polygon.addTo(map);
729
+ map.fitBounds(polygon.getBounds());
730
+ polygon.editing.enable();
731
+ pm.close();
732
+ };
733
+ const onChange = (pointList) => {
734
+ setPolygon(latLngListCheck(pointList));
735
+ };
736
+ const pm = this.CreatePm(
737
+ pmType,
738
+ {
739
+ ...options,
740
+ onChange,
741
+ circleClick: false
742
+ },
743
+ map
744
+ );
745
+ pm.close();
746
+ const handlers = {
747
+ getPath: function() {
748
+ return polygon ? polygon.getLatLngs()[0] : [];
749
+ },
750
+ // 定点绘制(radius 为直径,故取半)
751
+ setFixedPoint: function(target, { lnglat, radius }) {
752
+ setPolygon(circleToPolygonPoints(lnglat, radius / 2e3));
753
+ },
754
+ setPolygon: function(target, pointList) {
755
+ setPolygon(latLngListCheck(pointList));
756
+ },
757
+ startDraw: function(target, toolType = "rectangle") {
758
+ clearPolygon();
759
+ target.setMouseTool(toolType);
760
+ },
761
+ clearDraw: function() {
762
+ clearPolygon();
763
+ },
764
+ remove: function(target) {
765
+ clearPolygon();
766
+ target.close(true);
767
+ target.remove();
768
+ },
769
+ close: function(target) {
770
+ target.close(true);
771
+ },
772
+ setMouseTool: function(target, toolType) {
773
+ target.setMouseTool(toolType);
774
+ }
775
+ };
776
+ return createMapProxy(pm, handlers);
777
+ }
778
+ // 测距工具 labelColor labelFillColor lineColor
779
+ RangingTool(options = {}, map) {
780
+ let rangingMarker = [];
781
+ let rangingPolylines = [];
782
+ let rangingPointsIng = [];
783
+ let rangingPointsEnd = [];
784
+ let rangingTrun = false;
785
+ const _this = this;
786
+ function rangingClick(res) {
787
+ setRangingTrun(res.latlng);
788
+ }
789
+ function calcTotalDistance(index, preIndex) {
790
+ const current = rangingMarker[index].options.extData.latlng;
791
+ const previous = rangingMarker[preIndex].options.extData.latlng;
792
+ const distance = parseFloat(
793
+ (map.distance(current, previous) / 1e3).toFixed(2)
794
+ );
795
+ const total = parseFloat(
796
+ rangingMarker[preIndex].options.extData.distance || 0
797
+ );
798
+ return (distance + total).toFixed(2);
799
+ }
800
+ function removeLineBetween(groupIndex, aIndex, bIndex) {
801
+ const latlngOne = rangingMarker[aIndex]?.options?.extData?.latlng;
802
+ const latlngTwo = rangingMarker[bIndex]?.options?.extData?.latlng;
803
+ const polygonIndex = rangingPolylines.findIndex((v) => {
804
+ const extData = v.options.extData;
805
+ return groupIndex === extData.index && extData.latlngs === "" + latlngOne.lat + latlngOne.lng + latlngTwo.lat + latlngTwo.lng;
806
+ });
807
+ rangingPolylines[polygonIndex] && rangingPolylines[polygonIndex].remove();
808
+ rangingPolylines.splice(polygonIndex, 1);
809
+ }
810
+ function setStartIcon(index) {
811
+ const markerItem = rangingMarker[index];
812
+ markerItem.setIcon({
813
+ divIcon: _this.DivIcon(
814
+ rangingStartIconOption(options, markerItem.options.extData.dicId)
815
+ )
816
+ });
817
+ markerItem.options.extData.distance = 0;
818
+ }
819
+ function setPointIcon(index, distance, showDeleteAll) {
820
+ const markerItem = rangingMarker[index];
821
+ const isLast = !rangingMarker[index + 1]?.options?.extData?.distance;
822
+ markerItem.setIcon({
823
+ divIcon: _this.DivIcon(
824
+ rangingPointIconOption(
825
+ options,
826
+ distance,
827
+ markerItem.options.extData.dicId,
828
+ isLast
829
+ )
830
+ )
831
+ });
832
+ markerItem.options.extData.distance = distance;
833
+ }
834
+ function setRangingTrun({ lat, lng }) {
835
+ const dicId = `${rangingPointsEnd.length}-${lat}-${lng}`;
836
+ if (!rangingPointsIng.length) {
837
+ const customIcon = _this.DivIcon(rangingStartIconOption(options, dicId));
838
+ const markerItem = _this.Marker({
839
+ position: { lat, lng },
840
+ icon: customIcon,
841
+ extData: {
842
+ latlng: { lat, lng },
843
+ index: rangingPointsEnd.length,
844
+ distance: 0,
845
+ dicId
846
+ }
847
+ });
848
+ markerItem.on("click", (res) => {
849
+ if (res.originalEvent.target.dataset?.id) {
850
+ clickItem();
851
+ }
852
+ });
853
+ markerItem.addTo(map);
854
+ rangingMarker.push(markerItem);
855
+ rangingPointsIng.push({ lat, lng });
856
+ } else {
857
+ const latlngs = [
858
+ [
859
+ rangingPointsIng[rangingPointsIng.length - 1].lat,
860
+ rangingPointsIng[rangingPointsIng.length - 1].lng
861
+ ],
862
+ [lat, lng]
863
+ ];
864
+ const polyline = _this.Polyline(latlngs, {
865
+ color: "#2df2ff",
866
+ weight: 2,
867
+ extData: {
868
+ latlngs: "" + latlngs[0][0] + latlngs[0][1] + latlngs[1][0] + latlngs[1][1],
869
+ index: rangingPointsEnd.length
870
+ }
871
+ });
872
+ polyline.addTo(map);
873
+ rangingPolylines.push(polyline);
874
+ let distance = map.distance(
875
+ { lat: latlngs[0][0], lng: latlngs[0][1] },
876
+ { lat: latlngs[1][0], lng: latlngs[1][1] }
877
+ );
878
+ distance = parseFloat((distance / 1e3).toFixed(2));
879
+ const total = parseFloat(
880
+ rangingMarker[rangingMarker.length - 1].options.extData.distance || 0
881
+ );
882
+ distance = (distance + total).toFixed(2);
883
+ const customIcon = _this.DivIcon(
884
+ rangingPointIconOption(options, distance, dicId)
885
+ );
886
+ const markerItem = _this.Marker({
887
+ position: { lat, lng },
888
+ icon: customIcon,
889
+ extData: {
890
+ latlng: { lat, lng },
891
+ index: rangingPointsEnd.length,
892
+ distance,
893
+ dicId
894
+ }
895
+ });
896
+ markerItem.on("click", (res) => {
897
+ if (res.originalEvent.target.dataset?.id === "delete-all") {
898
+ deleteAll();
899
+ } else if (res.originalEvent.target.dataset?.id) {
900
+ clickItem();
901
+ }
902
+ });
903
+ markerItem.addTo(map);
904
+ rangingMarker.push(markerItem);
905
+ rangingPointsIng.push({ lat, lng });
906
+ }
907
+ const rangEndIndex = rangingPointsEnd.length;
908
+ function clickItem() {
909
+ if (rangEndIndex === rangingPointsEnd.length) {
910
+ if (options.message) {
911
+ options.message({
912
+ type: "warning",
913
+ message: "\u8BF7\u5148\u5B8C\u6210\u672C\u6B21\u6D4B\u8DDD\uFF0C\u518D\u5220\u9664\u6D4B\u8DDD\u70B9"
914
+ });
915
+ }
916
+ return;
917
+ }
918
+ const index = rangingMarker.findIndex((v) => {
919
+ const extData = v?.options?.extData;
920
+ return extData?.index === rangEndIndex && extData?.latlng?.lat === lat && extData?.latlng?.lng === lng;
921
+ });
922
+ const distance = rangingMarker[index].options.extData.distance;
923
+ if (distance === 0) {
924
+ const nextMarker = rangingMarker[index + 1]?.options?.extData?.distance;
925
+ const nextTwo = rangingMarker[index + 2]?.options?.extData?.distance;
926
+ if (!(nextMarker && nextMarker !== 0 && nextTwo && nextTwo !== 0)) {
927
+ if (nextMarker) {
928
+ removeLineBetween(rangEndIndex, index, index + 1);
929
+ setTimeout(() => {
930
+ rangingMarker[index + 1].remove();
931
+ rangingMarker[index].remove();
932
+ rangingMarker.splice(index, 1);
933
+ setTimeout(() => {
934
+ rangingMarker.splice(index, 1);
935
+ });
936
+ });
937
+ } else {
938
+ setTimeout(() => {
939
+ rangingMarker[index].remove();
940
+ rangingMarker.splice(index, 1);
941
+ });
942
+ }
943
+ return;
944
+ } else {
945
+ removeLineBetween(rangEndIndex, index, index + 1);
946
+ let changeIndex = index + 1;
947
+ while (rangingMarker[changeIndex]?.options?.extData?.distance) {
948
+ if (changeIndex - 1 === index) {
949
+ setStartIcon(changeIndex);
950
+ } else {
951
+ setPointIcon(
952
+ changeIndex,
953
+ calcTotalDistance(changeIndex, changeIndex - 1)
954
+ );
955
+ }
956
+ changeIndex++;
957
+ }
958
+ setTimeout(() => {
959
+ rangingMarker[index].remove();
960
+ rangingMarker.splice(index, 1);
961
+ });
962
+ }
963
+ } else {
964
+ const nextDistance = rangingMarker[index + 1]?.options?.extData?.distance;
965
+ if (nextDistance) {
966
+ const latlngOne = rangingMarker[index - 1]?.options?.extData?.latlng;
967
+ const latlngTree = rangingMarker[index + 1]?.options?.extData?.latlng;
968
+ removeLineBetween(rangEndIndex, index - 1, index);
969
+ removeLineBetween(rangEndIndex, index, index + 1);
970
+ const latlngs = [
971
+ [latlngOne.lat, latlngOne.lng],
972
+ [latlngTree.lat, latlngTree.lng]
973
+ ];
974
+ const polyline = _this.Polyline(latlngs, {
975
+ color: "#2df2ff",
976
+ weight: 2,
977
+ extData: {
978
+ latlngs: "" + latlngs[0][0] + latlngs[0][1] + latlngs[1][0] + latlngs[1][1],
979
+ index: rangEndIndex
980
+ }
981
+ });
982
+ polyline.addTo(map);
983
+ rangingPolylines.push(polyline);
984
+ let changeIndex = index + 1;
985
+ while (rangingMarker[changeIndex]?.options?.extData?.distance) {
986
+ const disIndex = changeIndex - 1 === index ? changeIndex - 2 : changeIndex - 1;
987
+ setPointIcon(
988
+ changeIndex,
989
+ calcTotalDistance(changeIndex, disIndex)
990
+ );
991
+ changeIndex++;
992
+ }
993
+ setTimeout(() => {
994
+ rangingMarker[index].remove();
995
+ rangingMarker.splice(index, 1);
996
+ });
997
+ } else {
998
+ const beforeDistance = rangingMarker[index - 1]?.options?.extData?.distance;
999
+ if (beforeDistance) {
1000
+ const latlngOne = rangingMarker[index - 1]?.options?.extData?.latlng;
1001
+ const latlngTwo = rangingMarker[index]?.options?.extData?.latlng;
1002
+ const polygonIndex = rangingPolylines.findIndex((v) => {
1003
+ const extData = v.options.extData;
1004
+ return rangEndIndex === extData.index && extData.latlngs === "" + latlngOne.lat + latlngOne.lng + latlngTwo.lat + latlngTwo.lng;
1005
+ });
1006
+ rangingPolylines[polygonIndex] && rangingPolylines[polygonIndex].remove();
1007
+ rangingPolylines.splice(polygonIndex, 1);
1008
+ const lastMarker = rangingMarker[index - 1];
1009
+ const customIcon = _this.DivIcon({
1010
+ html: `<div style="width:12px;height:12px;border-radius:9999px;background-color:${options.labelFillColor || "#fff"};border:1px solid ${options.lineColor || "#2df2ff"};position:relative;">
1011
+ <div style="position:absolute;left:0;top:12px;padding-left:4px;padding-right:4px;font-size:12px;line-height:16px;background-color:#fff;border:1px solid #000;color:#000;white-space:nowrap;">${lastMarker.options.extData.distance}km
1012
+ <i data-id="${lastMarker.options.extData.dicId}" class="el-icon-close"></i>
1013
+ <i data-id="delete-all" class="el-icon-delete"></i>
1014
+ </div>
1015
+ </div>`,
1016
+ className: "my-div-icon",
1017
+ iconSize: [remToPx(0.75), remToPx(0.75)],
1018
+ iconAnchor: [remToPx(0.375), remToPx(0.375)]
1019
+ });
1020
+ lastMarker.setIcon({ divIcon: customIcon });
1021
+ setTimeout(() => {
1022
+ rangingMarker[index].remove();
1023
+ rangingMarker.splice(index, 1);
1024
+ });
1025
+ } else {
1026
+ const latlngOne = rangingMarker[index - 1]?.options?.extData?.latlng;
1027
+ const latlngTwo = rangingMarker[index]?.options?.extData?.latlng;
1028
+ const polygonIndex = rangingPolylines.findIndex((v) => {
1029
+ const extData = v.options.extData;
1030
+ return rangEndIndex === extData.index && extData.latlngs === "" + latlngOne.lat + latlngOne.lng + latlngTwo.lat + latlngTwo.lng;
1031
+ });
1032
+ rangingPolylines[polygonIndex] && rangingPolylines[polygonIndex].remove();
1033
+ rangingPolylines.splice(polygonIndex, 1);
1034
+ setTimeout(() => {
1035
+ rangingMarker[index - 1].remove();
1036
+ rangingMarker[index].remove();
1037
+ rangingMarker.splice(index, 1);
1038
+ rangingMarker.splice(index - 1, 1);
1039
+ });
1040
+ }
1041
+ }
1042
+ }
1043
+ }
1044
+ function deleteAll() {
1045
+ for (let i = 0; i < rangingPolylines.length; i++) {
1046
+ const polygon = rangingPolylines[i];
1047
+ if (polygon?.options?.extData?.index === rangEndIndex) {
1048
+ polygon.remove();
1049
+ rangingPolylines.splice(i, 1);
1050
+ i--;
1051
+ }
1052
+ }
1053
+ setTimeout(() => {
1054
+ let index = rangingMarker.findIndex((v) => {
1055
+ const extData = v?.options?.extData;
1056
+ return extData?.index === rangEndIndex && extData?.latlng?.lat === lat && extData?.latlng?.lng === lng;
1057
+ });
1058
+ while (rangingMarker[index]?.options?.extData?.distance) {
1059
+ rangingMarker[index].remove();
1060
+ rangingMarker.splice(index, 1);
1061
+ index--;
1062
+ }
1063
+ rangingMarker[index].remove();
1064
+ rangingMarker.splice(index, 1);
1065
+ });
1066
+ }
1067
+ }
1068
+ function setRangingTrunEnd() {
1069
+ const marker = rangingMarker[rangingMarker.length - 1];
1070
+ if (marker) {
1071
+ if (marker.options.extData.distance) {
1072
+ const customIcon = _this.DivIcon({
1073
+ html: `<div style="width:12px;height:12px;border-radius:9999px;background-color:${options.labelFillColor || "#fff"};border:1px solid ${options.lineColor || "#2df2ff"};position:relative;">
1074
+ <div style="position:absolute;left:0;top:12px;padding-left:4px;padding-right:4px;font-size:12px;line-height:16px;background-color:#fff;border:1px solid #000;color:#000;white-space:nowrap;">${marker.options.extData.distance}km
1075
+ <i data-id="${marker.options.extData.dicId}" class="el-icon-close"></i>
1076
+ <i data-id="delete-all" class="el-icon-delete"></i>
1077
+ </div>
1078
+ </div>`,
1079
+ className: "my-div-icon",
1080
+ iconSize: [remToPx(0.75), remToPx(0.75)],
1081
+ iconAnchor: [remToPx(0.375), remToPx(0.375)]
1082
+ });
1083
+ marker.setIcon({ divIcon: customIcon });
1084
+ } else {
1085
+ marker.remove();
1086
+ rangingMarker.splice(rangingMarker.length - 1, 1);
1087
+ }
1088
+ }
1089
+ rangingPointsEnd.push(rangingPointsIng);
1090
+ rangingPointsIng = [];
1091
+ }
1092
+ const handlers = {
1093
+ turnOn: function(target) {
1094
+ if (rangingTrun) return;
1095
+ map.on("click", rangingClick);
1096
+ map.on("contextmenu", setRangingTrunEnd);
1097
+ rangingTrun = true;
1098
+ },
1099
+ turnOff: function(target) {
1100
+ if (!rangingTrun) return;
1101
+ rangingMarker.forEach((marker) => {
1102
+ marker && marker?.remove();
1103
+ });
1104
+ rangingPolylines.forEach((polygon) => {
1105
+ polygon && polygon?.remove();
1106
+ });
1107
+ map.off("click", rangingClick);
1108
+ map.off("contextmenu", setRangingTrunEnd);
1109
+ rangingMarker = [];
1110
+ rangingPolylines = [];
1111
+ rangingPointsIng = [];
1112
+ rangingPointsEnd = [];
1113
+ rangingTrun = false;
1114
+ },
1115
+ remove: function(target) {
1116
+ if (!rangingTrun) return;
1117
+ rangingMarker.forEach((marker) => {
1118
+ marker && marker?.remove();
1119
+ });
1120
+ rangingPolylines.forEach((polygon) => {
1121
+ polygon && polygon?.remove();
1122
+ });
1123
+ map.off("click", rangingClick);
1124
+ map.off("contextmenu", setRangingTrunEnd);
1125
+ rangingTrun = false;
1126
+ rangingMarker = null;
1127
+ rangingPolylines = null;
1128
+ rangingPointsIng = null;
1129
+ rangingPointsEnd = null;
1130
+ }
1131
+ };
1132
+ return createMapProxy({}, handlers);
1133
+ }
1134
+ }
1135
+
1136
+ export { bigMap as default };