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,683 @@
1
+ import { EventEmitter } from 'events';
2
+ import { createMapProxy, createWrappedHandlerStore } from '../js/mapProxy.mjs';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
7
+ const createClickHandler = (fn, context, target) => {
8
+ return (e) => {
9
+ const newEvent = { ...e };
10
+ newEvent.latlng = newEvent.lnglat;
11
+ delete newEvent.lnglat;
12
+ fn.call(context || target, newEvent);
13
+ };
14
+ };
15
+ const wrapBounds = (target, withTarget = false) => {
16
+ const bounds = target.getBounds();
17
+ bounds._southWest = bounds.southwest;
18
+ bounds._northEast = bounds.northeast;
19
+ if (withTarget) {
20
+ bounds.getSouthWest = () => bounds.southwest;
21
+ bounds.getNorthEast = () => bounds.northeast;
22
+ bounds.target = target;
23
+ }
24
+ delete bounds.southwest;
25
+ delete bounds.northeast;
26
+ return bounds;
27
+ };
28
+ const toStrokeStyle = (option = {}) => {
29
+ return {
30
+ ...option,
31
+ strokeColor: option.color,
32
+ strokeOpacity: option.opacity,
33
+ strokeWeight: option.weight
34
+ };
35
+ };
36
+ class Google extends EventEmitter {
37
+ constructor(request) {
38
+ super();
39
+ /* 绘画多边形覆盖物 */
40
+ __publicField(this, "Polygon", (pathList = [], option) => {
41
+ option = {
42
+ ...option,
43
+ strokeColor: option.color,
44
+ strokeOpacity: option.opacity,
45
+ strokeWeight: option.weight,
46
+ fillColor: option.fillColor,
47
+ fillOpacity: option.fillOpacity
48
+ };
49
+ const lngLatList = [];
50
+ pathList.forEach((val) => {
51
+ lngLatList.push([val.lng, val.lat]);
52
+ });
53
+ const polygon = new window.AMap.Polygon({
54
+ path: lngLatList,
55
+ ...option
56
+ });
57
+ const wrappedHandlers = createWrappedHandlerStore();
58
+ const handlers = {
59
+ setStyle: function(target, setStyleOption) {
60
+ target.setOptions({
61
+ ...toStrokeStyle(setStyleOption),
62
+ fillColor: setStyleOption.fillColor,
63
+ fillOpacity: setStyleOption.fillOpacity
64
+ });
65
+ },
66
+ addTo: function(target, map) {
67
+ target.map = map;
68
+ map.add(target);
69
+ },
70
+ // 删除图形
71
+ remove: function(target) {
72
+ target.map.remove(target);
73
+ },
74
+ // 四个角
75
+ getBounds: function(target) {
76
+ return wrapBounds(target, true);
77
+ },
78
+ getLatLngs: function(target) {
79
+ return [target.getPath()];
80
+ },
81
+ on: function(target, types, fn, context) {
82
+ if (types === "click") {
83
+ const customClickHandler = createClickHandler(fn, context, target);
84
+ wrappedHandlers.remember(types, fn, customClickHandler);
85
+ return target.on(types, customClickHandler, context);
86
+ }
87
+ return target.on(types, fn, context);
88
+ },
89
+ off: function(target, types, fn, context) {
90
+ const wrappedFn = wrappedHandlers.take(types, fn);
91
+ return target.off(types, wrappedFn || fn, context);
92
+ }
93
+ };
94
+ return createMapProxy(polygon, handlers);
95
+ });
96
+ this.initParams = request;
97
+ }
98
+ InitMap(domId, option) {
99
+ const { center } = option;
100
+ const newMap = new window.AMap.Map(domId, {
101
+ defaultMapStyle: this.initParams.defaultMapStyle,
102
+ mapStyle: option.mapStyle,
103
+ zooms: [option.minZoom, option.maxZoom],
104
+ // 设置缩放级别范围 3-20 级
105
+ center: [center.lng, center.lat],
106
+ zoom: option.zoom,
107
+ // 其他配置项
108
+ layers: [],
109
+ pitch: 0,
110
+ resizeEnable: true
111
+ });
112
+ newMap.on("complete", (e) => {
113
+ if (option.completeCallbacks) {
114
+ option.completeCallbacks(e);
115
+ }
116
+ });
117
+ newMap.plugin(
118
+ [
119
+ "AMap.MarkerClusterer",
120
+ "AMap.Scale",
121
+ "AMap.LayerGroup",
122
+ "AMap.Circle",
123
+ "AMap.TileLayer",
124
+ "AMap.GeometryUtil",
125
+ "AMap.MouseTool"
126
+ ],
127
+ () => {
128
+ }
129
+ );
130
+ const wrappedHandlers = createWrappedHandlerStore();
131
+ const handlers = {
132
+ // return 单位:m
133
+ distance: function(target, latAndlng1, latAndlng2) {
134
+ return AMap.GeometryUtil.distance(
135
+ [latAndlng1.lng, latAndlng1.lat],
136
+ [latAndlng2.lng, latAndlng2.lat]
137
+ );
138
+ },
139
+ // 删除地图
140
+ removeMap: function(target) {
141
+ target.clearMap();
142
+ target.destroy();
143
+ },
144
+ panTo: function(target, latAndLng) {
145
+ target.panTo([latAndLng.lng, latAndLng.lat]);
146
+ },
147
+ // 移动至目标位置并缩放图层
148
+ setView: function(target, latAndLng, zoom) {
149
+ target.setZoom(zoom);
150
+ target.panTo([latAndLng.lng, latAndLng.lat]);
151
+ },
152
+ // 自定义地图
153
+ on: function(target, types, fn, context) {
154
+ if (types === "click") {
155
+ const customClickHandler = createClickHandler(fn, context, target);
156
+ wrappedHandlers.remember(types, fn, customClickHandler);
157
+ return target.on(types, customClickHandler, context);
158
+ }
159
+ return target.on(types, fn, context);
160
+ },
161
+ off: function(target, types, fn, context) {
162
+ const wrappedFn = wrappedHandlers.take(types, fn);
163
+ return target.off(types, wrappedFn || fn, context);
164
+ },
165
+ // // 获取中心点
166
+ getCenter: function(target) {
167
+ return target.getCenter();
168
+ },
169
+ fitBounds: function(target, params) {
170
+ if (!Array.isArray(params)) {
171
+ params = [params];
172
+ }
173
+ target.setFitView(params.map((item) => item.target));
174
+ },
175
+ // // 四个角
176
+ getBounds: function(target) {
177
+ return wrapBounds(target);
178
+ }
179
+ };
180
+ return createMapProxy(newMap, handlers);
181
+ }
182
+ // 地图图层
183
+ layerGroup(map, markers = []) {
184
+ const layerGroup = new window.AMap.LayerGroup(markers);
185
+ layerGroup.setMap(map);
186
+ return layerGroup;
187
+ }
188
+ // 自定义图标
189
+ DivIcon(option) {
190
+ return { option, _initHooksCalled: true };
191
+ }
192
+ Marker(markerOptions) {
193
+ const { position = {} } = markerOptions;
194
+ let offset = null;
195
+ const { html, iconSize, iconAnchor } = markerOptions.icon.option;
196
+ if (markerOptions.offset) {
197
+ offset = new window.AMap.Pixel(
198
+ markerOptions.offset[0],
199
+ markerOptions.offset[1]
200
+ );
201
+ } else {
202
+ const offsetX = iconAnchor[0] - iconSize[0] / 2;
203
+ const offsetY = -iconAnchor[1];
204
+ offset = new window.AMap.Pixel(offsetX, offsetY);
205
+ }
206
+ markerOptions = {
207
+ visible: true,
208
+ anchor: "top-center",
209
+ ...markerOptions,
210
+ position: [position.lng, position.lat],
211
+ content: html,
212
+ zIndex: markerOptions.zIndexOffset,
213
+ extData: markerOptions.extData || null,
214
+ offset
215
+ };
216
+ const marker = new window.AMap.Marker(markerOptions);
217
+ const handlers = {
218
+ addTo: function(target, map) {
219
+ target.map = map;
220
+ target.setMap(map);
221
+ },
222
+ remove: function(target) {
223
+ target.map.remove(target);
224
+ },
225
+ // 更改标记位置。
226
+ setLatLng: function(target, lngAndLat) {
227
+ target.setPosition([lngAndLat.lng, lngAndLat.lat]);
228
+ },
229
+ // 更改标记图标。
230
+ setIcon: function(target, iconParams) {
231
+ const { html: html2, iconSize: iconSize2, iconAnchor: iconAnchor2 } = iconParams.divIcon.option;
232
+ target.setContent(html2);
233
+ let setOffset = null;
234
+ if (iconParams.offset) {
235
+ setOffset = new window.AMap.Pixel(
236
+ iconParams.offset[0],
237
+ iconParams.offset[1]
238
+ );
239
+ } else {
240
+ const offsetX = iconAnchor2[0] - iconSize2[0] / 2;
241
+ const offsetY = -iconAnchor2[1];
242
+ setOffset = new window.AMap.Pixel(offsetX, offsetY);
243
+ }
244
+ target.setOffset(setOffset);
245
+ }
246
+ };
247
+ return createMapProxy(marker, handlers);
248
+ }
249
+ MarkerClusterGroup(map, markerList, option) {
250
+ const iconCreateFunction = (cluster) => {
251
+ cluster.getChildCount = () => {
252
+ return cluster.count;
253
+ };
254
+ const divIcon = option.iconCreateFunction(cluster);
255
+ const { html, iconSize, iconAnchor } = divIcon.option;
256
+ const offsetX = iconAnchor[0] - iconSize[0] / 2;
257
+ const offsetY = -iconAnchor[1];
258
+ cluster.marker.setContent(html);
259
+ cluster.marker.setOffset(new window.AMap.Pixel(offsetX, offsetY));
260
+ };
261
+ option = {
262
+ minClusterSize: 2,
263
+ // 聚合的最小数量
264
+ averageCenter: true,
265
+ ...option,
266
+ renderClusterMarker: iconCreateFunction,
267
+ maxZoom: option.disableClusteringAtZoom,
268
+ // 聚合的最大层级
269
+ gridSize: option.maxClusterRadius
270
+ // 聚合计算时网格的像素大小,默认60
271
+ };
272
+ const displayCluster = new window.AMap.MarkerClusterer(
273
+ map,
274
+ markerList,
275
+ option
276
+ );
277
+ const handlers = {
278
+ // 清除聚合点
279
+ remove: function(target) {
280
+ target.clearMarkers();
281
+ },
282
+ // 删除单个 marker
283
+ removeLayer: function(target, marker) {
284
+ target.removeMarkers([marker]);
285
+ },
286
+ // 删除多个个 【marker】
287
+ removeLayers: function(target, markerArray = []) {
288
+ target.removeMarkers(markerArray);
289
+ },
290
+ // 添加单个 marker
291
+ addLayer: function(target, marker) {
292
+ target.addMarkers([marker]);
293
+ },
294
+ // 添加多个个 【marker】
295
+ addLayers: function(target, markerArray = []) {
296
+ target.addMarkers(markerArray);
297
+ }
298
+ };
299
+ return createMapProxy(displayCluster, handlers);
300
+ }
301
+ /* 绘画圆 */
302
+ Circle(latLngList = {}, option = {}) {
303
+ option = {
304
+ ...option,
305
+ center: new window.AMap.LngLat(latLngList.lng, latLngList.lat),
306
+ // 圆心位置
307
+ radius: option.radius,
308
+ strokeColor: option.color,
309
+ strokeOpacity: option.opacity,
310
+ strokeWeight: option.weight,
311
+ fillColor: option.fillColor,
312
+ fillOpacity: option.fillOpacity
313
+ };
314
+ const circle = new window.AMap.Circle(option);
315
+ const handlers = {
316
+ addTo: function(target, map) {
317
+ target.map = map;
318
+ target.setMap(map);
319
+ },
320
+ // 删除图形
321
+ remove: function(target) {
322
+ target.map.remove(target);
323
+ },
324
+ // 四个角
325
+ getBounds: function(target) {
326
+ return wrapBounds(target, true);
327
+ },
328
+ // 获取位置
329
+ getLatLngs: function(target) {
330
+ return [target.getPath()];
331
+ }
332
+ };
333
+ return createMapProxy(circle, handlers);
334
+ }
335
+ // 自定义 popup
336
+ Popup(option) {
337
+ option = {
338
+ anchor: "bottom-center",
339
+ closeWhenClickMap: option.closeOnClick,
340
+ ...option
341
+ };
342
+ const popup = new window.AMap.InfoWindow(option);
343
+ const handlers = {
344
+ remove: function(target) {
345
+ target.close();
346
+ },
347
+ setLatLng: function(target, latLng) {
348
+ target.lat = latLng.lat;
349
+ target.lng = latLng.lng;
350
+ },
351
+ openOn: function(target, map) {
352
+ console.log(map, [target.lng, target.lat]);
353
+ target.open(map, [target.lng, target.lat]);
354
+ },
355
+ // 四个角
356
+ getBounds: function(target) {
357
+ return wrapBounds(target, true);
358
+ },
359
+ // 获取位置
360
+ getLatLngs: function(target) {
361
+ return [target.getPath()];
362
+ }
363
+ };
364
+ return createMapProxy(popup, handlers);
365
+ }
366
+ // 自定义 线条
367
+ Polyline(pathList = [], option = {}) {
368
+ if (option.dashArray) {
369
+ const dashArrayList = option.dashArray.split(",");
370
+ option.strokeStyle = "dashed";
371
+ option.strokeDasharray = [dashArrayList[0], dashArrayList[1]];
372
+ }
373
+ option = {
374
+ lineJoin: "round",
375
+ // 线段连接处为圆角
376
+ lineCap: "round",
377
+ // 线段端点为圆形
378
+ showDir: false,
379
+ ...option,
380
+ strokeColor: option.color,
381
+ strokeOpacity: option.opacity,
382
+ strokeWeight: option.weight
383
+ };
384
+ const lngLatList = [];
385
+ pathList.forEach((val) => {
386
+ lngLatList.push([val.lng, val.lat]);
387
+ });
388
+ const polyline = new AMap.Polyline({
389
+ path: lngLatList,
390
+ ...option
391
+ });
392
+ const wrappedHandlers = createWrappedHandlerStore();
393
+ const handlers = {
394
+ setStyle: function(target, setStyleOption) {
395
+ target.setOptions(toStrokeStyle(setStyleOption));
396
+ },
397
+ addTo: function(target, map) {
398
+ target.map = map;
399
+ map.add(target);
400
+ },
401
+ remove: function(target) {
402
+ target.map.remove(target);
403
+ },
404
+ // 四个角
405
+ getBounds: function(target) {
406
+ return wrapBounds(target, true);
407
+ },
408
+ getLatLngs: function(target) {
409
+ return [target.getPath()];
410
+ },
411
+ on: function(target, types, fn, context) {
412
+ if (types === "click") {
413
+ const customClickHandler = createClickHandler(fn, context, target);
414
+ wrappedHandlers.remember(types, fn, customClickHandler);
415
+ return target.on(types, customClickHandler, context);
416
+ }
417
+ return target.on(types, fn, context);
418
+ },
419
+ off: function(target, types, fn, context) {
420
+ const wrappedFn = wrappedHandlers.take(types, fn);
421
+ return target.off(types, wrappedFn || fn, context);
422
+ }
423
+ };
424
+ return createMapProxy(polyline, handlers);
425
+ }
426
+ // 轨迹回放
427
+ TrackPlayer(latLngList = [], option = {}, map = null) {
428
+ let monitorTrack = null;
429
+ let speed = option.speed;
430
+ let marker = this.Marker({
431
+ zIndex: 1,
432
+ position: latLngList[0],
433
+ icon: {
434
+ option: {
435
+ iconSize: option.iconSize,
436
+ iconAnchor: option.iconAnchor,
437
+ html: option.svgContent
438
+ }
439
+ }
440
+ });
441
+ marker.addTo(map);
442
+ let polyline = this.Polyline(latLngList, {
443
+ showDir: true,
444
+ opacity: 1,
445
+ weight: 4,
446
+ // 线宽
447
+ color: option.notPassedLineColor || "#FF1875"
448
+ // 线颜色
449
+ });
450
+ polyline.addTo(map);
451
+ let passedPolyline = this.Polyline([], {
452
+ color: option.passedLineColor || "#2EE19E",
453
+ // 线颜色
454
+ opacity: 1,
455
+ weight: 4
456
+ // 线宽
457
+ });
458
+ passedPolyline.addTo(map);
459
+ marker.on("moving", (e) => {
460
+ if (monitorTrack) {
461
+ clearTimeout(monitorTrack);
462
+ }
463
+ const passedPath = e.passedPath || [];
464
+ monitorTrack = setTimeout(() => {
465
+ if (option.onEnd) option.onEnd();
466
+ }, 500);
467
+ if (passedPolyline) {
468
+ passedPolyline.setPath(passedPath);
469
+ }
470
+ });
471
+ const moveAlong = () => {
472
+ if (!marker) return;
473
+ marker.moveAlong(
474
+ latLngList.map((v) => [v.lng, v.lat]),
475
+ speed - 0
476
+ );
477
+ };
478
+ const handlers = {
479
+ // 开始
480
+ startAnimation: function() {
481
+ moveAlong();
482
+ },
483
+ // 暂停
484
+ pauseAnimation: function() {
485
+ if (marker) {
486
+ marker.pauseMove();
487
+ if (monitorTrack) {
488
+ clearTimeout(monitorTrack);
489
+ }
490
+ }
491
+ },
492
+ // 恢复
493
+ resumeAnimation: function() {
494
+ if (marker) {
495
+ marker.resumeMove();
496
+ }
497
+ },
498
+ // 修改速度
499
+ motionSpeed: function(target, changeSpeed) {
500
+ speed = changeSpeed;
501
+ moveAlong();
502
+ },
503
+ // 移除轨迹回放
504
+ removeTrackPlayer: function() {
505
+ marker.remove();
506
+ polyline.remove();
507
+ passedPolyline.remove();
508
+ marker = null;
509
+ polyline = null;
510
+ passedPolyline = null;
511
+ if (monitorTrack) {
512
+ clearTimeout(monitorTrack);
513
+ monitorTrack = null;
514
+ }
515
+ }
516
+ };
517
+ return createMapProxy(marker, handlers);
518
+ }
519
+ // rectangle 正方形 circle 圆形 polygon 多边形
520
+ CreatePm(pmType = "rectangle", options = {}, map) {
521
+ let mouseToolObj = new AMap.MouseTool(map);
522
+ const drawStyle = {
523
+ fillColor: options.fillColor || "#00b0ff",
524
+ strokeColor: options.color || "#80d8ff"
525
+ };
526
+ mouseToolObj.on("draw", ({ obj }) => {
527
+ map.setFitView();
528
+ if (options.onChange) {
529
+ options.onChange(obj.getPath());
530
+ }
531
+ });
532
+ mouseToolObj[`${pmType}`](drawStyle);
533
+ const handlers = {
534
+ remove: function(target) {
535
+ target.close(true);
536
+ mouseToolObj = null;
537
+ },
538
+ close: function(target) {
539
+ target.close(true);
540
+ },
541
+ setMouseTool: function(target, toolType) {
542
+ target[`${toolType}`](drawStyle);
543
+ }
544
+ };
545
+ return createMapProxy(mouseToolObj, handlers);
546
+ }
547
+ // 电子围栏
548
+ CreateFence(pmType = "rectangle", options = {}, map) {
549
+ let polygon = null;
550
+ const _this = this;
551
+ const onChange = (pointList) => {
552
+ setPolygon(pointList);
553
+ };
554
+ const pm = this.CreatePm(
555
+ pmType,
556
+ {
557
+ ...options,
558
+ onChange
559
+ },
560
+ map
561
+ );
562
+ pm.close();
563
+ const setPolygon = (pointList) => {
564
+ polygon = this.Polygon(pointList, {
565
+ ...options,
566
+ fillColor: options.fillColor || "#00b0ff",
567
+ fillOpacity: options.fillOpacity || 0.5,
568
+ color: options.color || "#80d8ff",
569
+ weight: options.weight || 4,
570
+ opacity: options.opacity || 1,
571
+ zIndex: options.zIndex || 1e6
572
+ });
573
+ polygon.addTo(map);
574
+ map.fitBounds(polygon.getBounds());
575
+ const polyEditor = new AMap.PolyEditor(
576
+ map,
577
+ map.getAllOverlays("polygon")[map.getAllOverlays("polygon").length - 1]
578
+ );
579
+ polyEditor.open();
580
+ pm.close();
581
+ };
582
+ const handlers = {
583
+ getPath: function(target) {
584
+ return polygon ? polygon.getPath() : [];
585
+ },
586
+ setFixedPoint: function(target, { lnglat, radius }) {
587
+ map.clearMap();
588
+ polygon = null;
589
+ let circle = _this.Circle(lnglat, {
590
+ radius: radius / 2,
591
+ // 半径
592
+ strokeColor: "#FF33FF",
593
+ // 线颜色
594
+ strokeOpacity: 0.7,
595
+ // 线透明度
596
+ strokeWeight: 3,
597
+ // 线宽
598
+ fillColor: "#1791fc",
599
+ // 填充色
600
+ fillOpacity: 0.5
601
+ // 填充透明度
602
+ });
603
+ circle.addTo(map);
604
+ const path = circle.getLatLngs();
605
+ circle.remove();
606
+ circle = null;
607
+ setPolygon(path[0]);
608
+ },
609
+ setPolygon: function(target, pointList) {
610
+ map.clearMap();
611
+ polygon = null;
612
+ setPolygon(pointList);
613
+ },
614
+ startDraw: function(target, toolType = "rectangle") {
615
+ map.clearMap();
616
+ polygon = null;
617
+ target[`${toolType}`]({
618
+ fillColor: options.fillColor || "#00b0ff",
619
+ strokeColor: options.color || "#80d8ff"
620
+ });
621
+ },
622
+ clearDraw: function(target) {
623
+ map.clearMap();
624
+ polygon = null;
625
+ },
626
+ remove: function(target) {
627
+ map.clearMap();
628
+ target.close(true);
629
+ target.remove();
630
+ polygon = null;
631
+ },
632
+ close: function(target) {
633
+ target.close(true);
634
+ },
635
+ setMouseTool: function(target, toolType) {
636
+ target[`${toolType}`]({
637
+ fillColor: "#00b0ff",
638
+ strokeColor: "#80d8ff"
639
+ });
640
+ }
641
+ };
642
+ return createMapProxy(pm, handlers);
643
+ }
644
+ // 测距工具 labelColor labelFillColor lineColor
645
+ RangingTool(options = {}, map) {
646
+ let rangingTool = new AMap.RangingTool(map, {
647
+ startMarkerOptions: {
648
+ content: `<div style="width: 32px; height: 32px; border-radius: 50%; background: ${options.labelColor || "#2df2ff88"}; display: flex; justify-content: center; align-items: center;">
649
+ <div style="width: 12px; height: 12px; border-radius: 50%; background: ${options.labelFillColor || "#fff"}; border: 1px solid ${options.lineColor || "#2df2ff"};"></div>
650
+ </div>`,
651
+ offset: new AMap.Pixel(-16, -16)
652
+ },
653
+ midMarkerOptions: {
654
+ content: `<div style="width: 12px; height: 12px; border-radius: 50%; background: ${options.labelFillColor || "#fff"}; border: 1px solid ${options.lineColor || "#2df2ff"};"></div>`,
655
+ offset: new AMap.Pixel(-6, -6)
656
+ },
657
+ endMarkerOptions: {
658
+ content: `<div style="width: 12px; height: 12px; border-radius: 50%; background: ${options.labelFillColor || "#fff"}; border: 1px solid ${options.lineColor || "#2df2ff"};"></div>`,
659
+ offset: new AMap.Pixel(-6, -6)
660
+ },
661
+ lineOptions: {
662
+ strokeColor: options.lineColor || "#2df2ff"
663
+ },
664
+ tmpLineOptions: {
665
+ strokeColor: options.lineColor || "#2df2ff"
666
+ }
667
+ });
668
+ const handlers = {
669
+ turnOn: function(target) {
670
+ target.turnOn();
671
+ },
672
+ turnOff: function(target) {
673
+ target.turnOff(true);
674
+ },
675
+ remove: function() {
676
+ rangingTool = null;
677
+ }
678
+ };
679
+ return createMapProxy(rangingTool, handlers);
680
+ }
681
+ }
682
+
683
+ export { Google as default };