修改媒体地图,添加测距等工具

This commit is contained in:
wangchengming 2025-09-24 16:18:24 +08:00
parent 37a07491b6
commit ed62b825cf
19 changed files with 534 additions and 103 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1644,4 +1644,59 @@ h6 {
background-image: url('../images/time-line-icon.png');
background-size: cover;
}
// PPT导出样式
.my_dialog_itemHeader {
width: 100%;
height: 36px;
background: #1a75e630;
padding: 6px 20px;
font-family: Microsoft YaHei;
font-weight: 600;
font-size: 18px;
color: #000000;
}
.chosedMediaNamsConter {
width: 100%;
min-height: 60px;
background: #ffffff;
padding: 10px 0;
}
.checkAllChose .el-checkbox__label {
display: inline-block;
font-size: var(--el-checkbox-font-size);
line-height: 1;
padding-left: 8px;
font-family: Microsoft YaHei;
font-weight: 400;
font-size: 16px;
color: #1E1E1E;
}
.checkAllChose .el-checkbox__input.is-checked .el-checkbox__inner,
.checkAllChose .el-checkbox__input.is-indeterminate .el-checkbox__inner {
background-color: #1A75E6;
border-color: #1A75E6;
}
.checkAllChose .el-checkbox__inner {
background: #ffffff;
border: 1px solid #ACACAC;
border-radius: 2px;
box-sizing: border-box;
display: inline-block;
height: 16px;
width: 16px;
}
.checkAllChose .el-checkbox__inner:after {
height: 8px;
left: 5px;
}
.checkAllChose .el-checkbox__input.is-checked+.el-checkbox__label {
color: #1E1E1E;
}

View File

@ -663,57 +663,4 @@ onMounted(() => {
color: #ffffff90;
}
.my_dialog_itemHeader {
width: 100%;
height: 36px;
background: #1a75e630;
padding: 6px 20px;
font-family: Microsoft YaHei;
font-weight: 600;
font-size: 18px;
color: #000000;
}
.chosedMediaNamsConter {
width: 100%;
min-height: 60px;
background: #ffffff;
padding: 10px 0;
}
.checkAllChose .el-checkbox__label {
display: inline-block;
font-size: var(--el-checkbox-font-size);
line-height: 1;
padding-left: 8px;
font-family: Microsoft YaHei;
font-weight: 400;
font-size: 16px;
color: #1E1E1E;
}
.checkAllChose .el-checkbox__input.is-checked .el-checkbox__inner,
.checkAllChose .el-checkbox__input.is-indeterminate .el-checkbox__inner {
background-color: #1A75E6;
border-color: #1A75E6;
}
.checkAllChose .el-checkbox__inner {
background: #ffffff;
border: 1px solid #ACACAC;
border-radius: 2px;
box-sizing: border-box;
display: inline-block;
height: 16px;
width: 16px;
}
.checkAllChose .el-checkbox__inner:after {
height: 8px;
left: 5px;
}
.checkAllChose .el-checkbox__input.is-checked+.el-checkbox__label {
color: #1E1E1E;
}
</style>

View File

@ -227,6 +227,7 @@ import AMapLoader from "@amap/amap-jsapi-loader"; // 引入地图服务
import { sysMediaTypeListByPid } from "@/api/system/mediaType"
import { useBackgroundStore } from '@/store/modules/background'
import otherbg from '@/assets/images/otherbg.png'
import dragTool from '@/assets/images/dragTool.png'
import { mediaByMap, mediaDetail } from "@/api/mediaLibrary"
import { pptTemplatePage } from "@/api/system/pptTemplate"
@ -256,6 +257,8 @@ const previewImg = ref([])
const mapInstance = ref(null)
const massMarks = ref(null)
const centerMarker = ref(null)
//
const activeTool = ref(null)
// 2D/3D
const mapMode = ref('2D')
//
@ -407,20 +410,20 @@ const currentSelect = (val) => {
}
//
const addCenterMark = (val) => {
if (centerMarker.value) mapInstance.value.remove(centerMarker.value);
centerMarker.value = new AMap.Marker({
position: [val.x, val.y],
title: val.mediaName,
zIndex: 100,
draggable: false, //
cursor: 'move'
});
//
mapInstance.value.add(centerMarker.value);
mapInstance.value.setFitView(centerMarker.value);
}
// //
// const addCenterMark = (val) => {
// if (centerMarker.value) mapInstance.value.remove(centerMarker.value);
// centerMarker.value = new AMap.Marker({
// position: [val.x, val.y],
// title: val.mediaName,
// zIndex: 100,
// draggable: false, //
// cursor: 'move'
// });
// //
// mapInstance.value.add(centerMarker.value);
// mapInstance.value.setFitView(centerMarker.value);
// }
//
const createCircle = (val) => {
//
@ -459,8 +462,7 @@ const createCircleHandle = () => {
position: [handlePosition.lng, handlePosition.lat],
icon: new AMap.Icon({
size: new AMap.Size(20, 20),
// image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
image: otherbg,
image: dragTool,
imageSize: new AMap.Size(20, 20)
}),
offset: new AMap.Pixel(-10, -10),
@ -543,7 +545,7 @@ const loadMap = () => {
};
AMapLoader.load({
key: apiKey,
plugins: ["AMap.PlaceSearch"],
plugins: ["AMap.PlaceSearch", "AMap.MouseTool"],
version: '2.0', // API
AMapUI: {
plugins: []
@ -596,6 +598,13 @@ const loadMap = () => {
});
}
// 使
const stopActiveTool = () => {
if (activeTool.value !== null) {
clearAll()
activeTool.value = null; // 便
}
};
//
const addCustomControls = (AMap) => {
//
@ -612,8 +621,51 @@ const addCustomControls = (AMap) => {
fullscreenBtn.className = isFullscreen.value === true ? 'map-control-btn map-full-screen' : 'map-control-btn map-nofull-screen';
fullscreenBtn.onclick = toggleFullscreen;
//
const toolRangingBtn = document.createElement('div');
toolRangingBtn.className = 'map-control-btn map-ranging';
toolRangingBtn.onclick = startRuler;
//
const toolMeasureAreaBtn = document.createElement('div');
toolMeasureAreaBtn.className = 'map-control-btn map-measureAreaBtn';
toolMeasureAreaBtn.onclick = startMeasureArea;
//
const toolPointBtn = document.createElement('div');
toolPointBtn.className = 'map-control-btn map-addPointBtn';
toolPointBtn.onclick = startDrawMarker;
// 线
const toolLineBtn = document.createElement('div');
toolLineBtn.className = 'map-control-btn map-addLineBtn';
toolLineBtn.onclick = startDrawPolyline;
//
const toolCircleBtn = document.createElement('div');
toolCircleBtn.className = 'map-control-btn map-addCircleBtn';
toolCircleBtn.onclick = startDrawCircle;
//
const toolRactBtn = document.createElement('div');
toolRactBtn.className = 'map-control-btn map-addRactBtn';
toolRactBtn.onclick = startDrawRectangle;
//
const toolClearAllBtn = document.createElement('div');
toolClearAllBtn.className = 'map-control-btn map-clearAllBtn';
toolClearAllBtn.onclick = clearAll;
controlContainer.appendChild(toggle2D3DBtn);
controlContainer.appendChild(fullscreenBtn);
controlContainer.appendChild(toolRangingBtn);
controlContainer.appendChild(toolMeasureAreaBtn);
controlContainer.appendChild(toolPointBtn);
controlContainer.appendChild(toolLineBtn);
controlContainer.appendChild(toolCircleBtn);
controlContainer.appendChild(toolRactBtn);
controlContainer.appendChild(toolClearAllBtn);
//
document.getElementById('mapContainer').appendChild(controlContainer);
@ -665,6 +717,101 @@ const toggleFullscreen = () => {
}
}
}
//
const startRuler = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.rule({
startMarkerOptions: {//
icon: new AMap.Icon({
size: new AMap.Size(19, 31),//
imageSize: new AMap.Size(19, 31),
image: "//webapi.amap.com/theme/v1.3/markers/b/start.png"
}),
offset: new AMap.Pixel(-9, -31)
},
endMarkerOptions: {//
icon: new AMap.Icon({
size: new AMap.Size(19, 31),//
imageSize: new AMap.Size(19, 31),
image: "//webapi.amap.com/theme/v1.3/markers/b/end.png"
}),
offset: new AMap.Pixel(-9, -31)
},
midMarkerOptions: {//
icon: new AMap.Icon({
size: new AMap.Size(19, 31),//
imageSize: new AMap.Size(19, 31),
image: "//webapi.amap.com/theme/v1.3/markers/b/mid.png"
}),
offset: new AMap.Pixel(-9, -31)
},
lineOptions: {//
strokeStyle: "solid",
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 2
}
});
}
//
const startMeasureArea = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.measureArea({
strokeColor: '#80d8ff',
fillColor: '#80d8ff',
fillOpacity: 0.3
// Polygon Option
});
}
//
const startDrawMarker = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.marker({
//MarkerOption
});
}
// 线
const startDrawPolyline = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.polyline({
strokeColor: '#80d8ff'
//PolylineOption
});
}
//
const startDrawCircle = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.circle({
fillColor: '#00b0ff',
strokeColor: '#80d8ff'
//CircleOption
});
}
//
const startDrawRectangle = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.rectangle({
fillColor: '#00b0ff',
strokeColor: '#80d8ff'
//PolygonOption
});
}
//
const clearAll = () => {
activeTool.value.close(true)//
}
//
document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
@ -824,7 +971,6 @@ const showContextMenu = (pixel) => {
};
contextMenuVisible.value = true;
}
const hideContextMenu = () => {
contextMenuVisible.value = false;
}
@ -887,6 +1033,7 @@ const handleCloseTag = (tag) => {
multipleChoseArr.value.splice(rowIndex, 1)
}
onUnmounted(() => {
stopActiveTool()
if (mapInstance.value) {
mapInstance.value.destroy();
}
@ -1077,6 +1224,78 @@ onMounted(() => {
background: url('../../assets/images/icon-map-nofull-screen-active.png');
}
.map-ranging {
width: 40px;
height: 40px;
background: url('../../assets/images/mapRanging.png');
}
.map-ranging:hover {
width: 40px;
height: 40px;
background: url('../../assets/images/mapRanginghover.png');
}
.map-measureAreaBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapArea.png');
}
.map-measureAreaBtn:hover {
background: url('../../assets/images/mapAreaHover.png');
}
.map-addPointBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapPoint.png');
}
.map-addPointBtn:hover {
background: url('../../assets/images/mapPointHover.png');
}
.map-addLineBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapLine.png');
}
.map-addLineBtn:hover {
background: url('../../assets/images/mapLineHover.png');
}
.map-addCircleBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapCircle.png');
}
.map-addCircleBtn:hover {
background: url('../../assets/images/mapCircleHover.png');
}
.map-addRactBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapRect.png');
}
.map-addRactBtn:hover {
background: url('../../assets/images/mapRectHover.png');
}
.map-clearAllBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapClearAll.png');
}
.map-clearAllBtn:hover {
background: url('../../assets/images/mapClearAllHover.png');
}
/* 全屏样式 */
.mapContainer:-webkit-full-screen {
width: 100% !important;
@ -1098,11 +1317,6 @@ onMounted(() => {
height: 100% !important;
}
// .one-text {
// height: 50px;
// padding-top: 4px;
// }
// 线
.splineBar {
width: 100%;

View File

@ -212,12 +212,19 @@ const { queryParams } = toRefs(data)
// map
const mapInstance = ref(null)
const massMarks = ref(null)
//
const activeTool = ref(null)
// 2D/3D
const mapMode = ref('2D')
//
const isFullscreen = ref(false)
//
const points = ref([])
//
let minLng = Infinity; // 西
let minLat = Infinity; //
let maxLng = -Infinity; //
let maxLat = -Infinity; //
//
const exportForm = ref({
@ -362,16 +369,27 @@ const handleFlod = () => {
const getOutMediaPageList = () => {
loading.value = true
outMediaPageList(queryParams.value).then(res => {
res.data.rows.forEach(element => {
element.currentImageSrc = defaultImageSrc.value;
points.value = []
res.data.rows.forEach(itemPoint => {
itemPoint.currentImageSrc = defaultImageSrc.value;
if (itemPoint.dataScopeDeptId == 220) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 0 })
else if (itemPoint.dataScopeDeptId == 219) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 1 })
//
const lng = itemPoint.mapX;
const lat = itemPoint.mapY;
if (lng < minLng) minLng = lng;
if (lat < minLat) minLat = lat;
if (lng > maxLng) maxLng = lng;
if (lat > maxLat) maxLat = lat;
});
outdoorMediaList.value = res.data.rows
total.value = res.data.total
loading.value = false
}).then(res => {
//
renderMassMarks();
})
}
/** 搜索按钮操作 */
@ -426,7 +444,8 @@ const loadMap = () => {
AMapLoader.load({
key: apiKey,
plugins: ["AMap.PlaceSearch"],
plugins: ["AMap.PlaceSearch", "AMap.MouseTool"],
version: '2.0', // API
AMapUI: {
plugins: []
}
@ -480,6 +499,13 @@ const handleZoomChange = () => {
return;
}
}
// 使
const stopActiveTool = () => {
if (activeTool.value !== null) {
clearAll()
activeTool.value = null; // 便
}
};
//
const addCustomControls = (AMap) => {
//
@ -496,8 +522,50 @@ const addCustomControls = (AMap) => {
fullscreenBtn.className = isFullscreen.value === true ? 'map-control-btn map-full-screen' : 'map-control-btn map-nofull-screen';
fullscreenBtn.onclick = toggleFullscreen;
//
const toolRangingBtn = document.createElement('div');
toolRangingBtn.className = 'map-control-btn map-ranging';
toolRangingBtn.onclick = startRuler;
//
const toolMeasureAreaBtn = document.createElement('div');
toolMeasureAreaBtn.className = 'map-control-btn map-measureAreaBtn';
toolMeasureAreaBtn.onclick = startMeasureArea;
//
const toolPointBtn = document.createElement('div');
toolPointBtn.className = 'map-control-btn map-addPointBtn';
toolPointBtn.onclick = startDrawMarker;
// 线
const toolLineBtn = document.createElement('div');
toolLineBtn.className = 'map-control-btn map-addLineBtn';
toolLineBtn.onclick = startDrawPolyline;
//
const toolCircleBtn = document.createElement('div');
toolCircleBtn.className = 'map-control-btn map-addCircleBtn';
toolCircleBtn.onclick = startDrawCircle;
//
const toolRactBtn = document.createElement('div');
toolRactBtn.className = 'map-control-btn map-addRactBtn';
toolRactBtn.onclick = startDrawRectangle;
//
const toolClearAllBtn = document.createElement('div');
toolClearAllBtn.className = 'map-control-btn map-clearAllBtn';
toolClearAllBtn.onclick = clearAll;
controlContainer.appendChild(toggle2D3DBtn);
controlContainer.appendChild(fullscreenBtn);
controlContainer.appendChild(toolRangingBtn);
controlContainer.appendChild(toolMeasureAreaBtn);
controlContainer.appendChild(toolPointBtn);
controlContainer.appendChild(toolLineBtn);
controlContainer.appendChild(toolCircleBtn);
controlContainer.appendChild(toolRactBtn);
controlContainer.appendChild(toolClearAllBtn);
//
document.getElementById('mapContainer').appendChild(controlContainer);
@ -549,6 +617,101 @@ const toggleFullscreen = () => {
}
}
}
//
const startRuler = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.rule({
startMarkerOptions: {//
icon: new AMap.Icon({
size: new AMap.Size(19, 31),//
imageSize: new AMap.Size(19, 31),
image: "//webapi.amap.com/theme/v1.3/markers/b/start.png"
}),
offset: new AMap.Pixel(-9, -31)
},
endMarkerOptions: {//
icon: new AMap.Icon({
size: new AMap.Size(19, 31),//
imageSize: new AMap.Size(19, 31),
image: "//webapi.amap.com/theme/v1.3/markers/b/end.png"
}),
offset: new AMap.Pixel(-9, -31)
},
midMarkerOptions: {//
icon: new AMap.Icon({
size: new AMap.Size(19, 31),//
imageSize: new AMap.Size(19, 31),
image: "//webapi.amap.com/theme/v1.3/markers/b/mid.png"
}),
offset: new AMap.Pixel(-9, -31)
},
lineOptions: {//
strokeStyle: "solid",
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 2
}
});
}
//
const startMeasureArea = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.measureArea({
strokeColor: '#80d8ff',
fillColor: '#80d8ff',
fillOpacity: 0.3
// Polygon Option
});
}
//
const startDrawMarker = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.marker({
//MarkerOption
});
}
// 线
const startDrawPolyline = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.polyline({
strokeColor: '#80d8ff'
//PolylineOption
});
}
//
const startDrawCircle = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.circle({
fillColor: '#00b0ff',
strokeColor: '#80d8ff'
//CircleOption
});
}
//
const startDrawRectangle = () => {
if (!mapInstance.value) return;
stopActiveTool();
activeTool.value = new AMap.MouseTool(mapInstance.value);
activeTool.value.rectangle({
fillColor: '#00b0ff',
strokeColor: '#80d8ff'
//PolygonOption
});
}
//
const clearAll = () => {
activeTool.value.close(true)//
}
//
document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
@ -633,29 +796,8 @@ const renderMassMarks = () => {
},
];
//
let minLng = Infinity; // 西
let minLat = Infinity; //
let maxLng = -Infinity; //
let maxLat = -Infinity; //
//
points.value = []
outdoorMediaList.value.forEach(itemPoint => {
if (itemPoint.dataScopeDeptId == 220) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 0 })
else if (itemPoint.dataScopeDeptId == 219) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 1 })
//
const lng = itemPoint.mapX;
const lat = itemPoint.mapY;
if (lng < minLng) minLng = lng;
if (lat < minLat) minLat = lat;
if (lng > maxLng) maxLng = lng;
if (lat > maxLat) maxLat = lat;
});
// MassMarks
if (points.value.length > 0) {
if (points.value.length > 0 && mapInstance.value) {
// MassMarks
massMarks.value = new AMap.MassMarks(points.value, {
opacity: 1,
@ -695,6 +837,7 @@ const hideAmapLogo = () => {
}
onUnmounted(() => {
stopActiveTool()
if (mapInstance.value) {
mapInstance.value.destroy();
}
@ -782,6 +925,78 @@ onMounted(() => {
background: url('../../assets/images/icon-map-nofull-screen-active.png');
}
.map-ranging {
width: 40px;
height: 40px;
background: url('../../assets/images/mapRanging.png');
}
.map-ranging:hover {
width: 40px;
height: 40px;
background: url('../../assets/images/mapRanginghover.png');
}
.map-measureAreaBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapArea.png');
}
.map-measureAreaBtn:hover {
background: url('../../assets/images/mapAreaHover.png');
}
.map-addPointBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapPoint.png');
}
.map-addPointBtn:hover {
background: url('../../assets/images/mapPointHover.png');
}
.map-addLineBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapLine.png');
}
.map-addLineBtn:hover {
background: url('../../assets/images/mapLineHover.png');
}
.map-addCircleBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapCircle.png');
}
.map-addCircleBtn:hover {
background: url('../../assets/images/mapCircleHover.png');
}
.map-addRactBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapRect.png');
}
.map-addRactBtn:hover {
background: url('../../assets/images/mapRectHover.png');
}
.map-clearAllBtn {
width: 40px;
height: 40px;
background: url('../../assets/images/mapClearAll.png');
}
.map-clearAllBtn:hover {
background: url('../../assets/images/mapClearAllHover.png');
}
/* 全屏样式 */
.mapContainer:-webkit-full-screen {
width: 100% !important;