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