优化媒体地图显示

This commit is contained in:
wangchengming 2025-09-17 23:51:08 +08:00
parent e22f400293
commit 9d18548ed3
2 changed files with 82 additions and 26 deletions

View File

@ -13,7 +13,7 @@
<div style="height: 24px; line-height: 24px;font-size: 16px;">{{ item.name }}</div> <div style="height: 24px; line-height: 24px;font-size: 16px;">{{ item.name }}</div>
<div style="color: #8492a6; font-size: 12px;height: 18px; line-height: 18px;">{{ <div style="color: #8492a6; font-size: 12px;height: 18px; line-height: 18px;">{{
item.address item.address
}}</div> }}</div>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -147,7 +147,7 @@ const placeSearch = ref(null)
// //
const circle = ref(null); const circle = ref(null);
const circleRadius = ref(2000); // const circleRadius = ref(500); //
const circleHandle = ref(null); // const circleHandle = ref(null); //
// //
@ -190,7 +190,7 @@ const resetQuery = () => {
distanceLable.value = '请选择' distanceLable.value = '请选择'
// //
activeLableIndex.value = null activeLableIndex.value = null
circleRadius.value = 2000; // circleRadius.value = 500; //
selectConfig.value = null selectConfig.value = null
// //
@ -216,7 +216,7 @@ const handleViewMedia = (_mediaId) => {
mediaDetail({ mediaId: _mediaId }).then(res => { mediaDetail({ mediaId: _mediaId }).then(res => {
detailForm.value = res.data detailForm.value = res.data
if (detailForm.value.mediaFile && detailForm.value.mediaFile.length > 0) { if (detailForm.value.mediaFile && detailForm.value.mediaFile.length > 0) {
fileList.value = detailForm.value.mediaFile.filter(item => item.fileType == 6) fileList.value = detailForm.value.mediaFile.filter(item => item.fileType == 6)
} }
open.value = true open.value = true
}) })
@ -237,7 +237,7 @@ const getLocaleListList = (searchValue) => {
} }
} }
// //
const currentSelect = (val) => { const currentSelect = (val) => {
selectConfig.value = val selectConfig.value = val
centerPointName.value = val.name centerPointName.value = val.name
// queryParams.value.keyword = val.name // queryParams.value.keyword = val.name
@ -246,9 +246,9 @@ const currentSelect = (val) => {
queryParams.value.distance = circleRadius.value queryParams.value.distance = circleRadius.value
// //
distanceLable.value = circleRadius.value == 2000 ? '2000米' : circleRadius.value + '米' distanceLable.value = circleRadius.value == 500 ? '500米' : circleRadius.value + '米'
// //
activeLableIndex.value = circleRadius.value == 2000 ? 2000 : circleRadius.value activeLableIndex.value = circleRadius.value == 500 ? 500 : circleRadius.value
// //
if (circle.value) { if (circle.value) {
@ -312,7 +312,7 @@ const createCircleHandle = () => {
const handlePosition = new AMap.LngLat( const handlePosition = new AMap.LngLat(
center.lng + radius / (111320 * Math.cos(center.lat * Math.PI / 180)), center.lng + radius / (111320 * Math.cos(center.lat * Math.PI / 180)),
center.lat center.lat
); );
// //
circleHandle.value = new AMap.Marker({ circleHandle.value = new AMap.Marker({
position: [handlePosition.lng, handlePosition.lat], position: [handlePosition.lng, handlePosition.lat],
@ -622,16 +622,31 @@ const renderMassMarks = () => {
size: new AMap.Size(18, 18) size: new AMap.Size(18, 18)
}, },
]; ];
//
let minLng = Infinity; // 西
let minLat = Infinity; //
let maxLng = -Infinity; //
let maxLat = -Infinity; //
// //
points.value = [] points.value = []
mediaByMap(queryParams.value).then(res => { mediaByMap(queryParams.value).then(res => {
if (res.code == 200) { if (res.code == 200) {
res.data.forEach(itemPoint => { res.data.forEach(itemPoint => {
if (itemPoint.dataScopeDeptId == 220) points.value.push({ "lnglat": [itemPoint.x, itemPoint.y], "mediaId": itemPoint.mediaId, "style": 0 }) if (itemPoint.dataScopeDeptId == 220) points.value.push({ "lnglat": [itemPoint.x, itemPoint.y], "mediaId": itemPoint.mediaId, "style": 0 })
if (itemPoint.dataScopeDeptId == 219) points.value.push({ "lnglat": [itemPoint.x, itemPoint.y], "mediaId": itemPoint.mediaId, "style": 1 }) else if (itemPoint.dataScopeDeptId == 219) points.value.push({ "lnglat": [itemPoint.x, itemPoint.y], "mediaId": itemPoint.mediaId, "style": 1 })
//
const lng = itemPoint.x;
const lat = itemPoint.y;
if (lng < minLng) minLng = lng;
if (lat < minLat) minLat = lat;
if (lng > maxLng) maxLng = lng;
if (lat > maxLat) maxLat = lat;
}); });
} }
}).then(res => { }).then(res => {
// MassMarks // MassMarks
massMarks.value = new AMap.MassMarks(points.value, { massMarks.value = new AMap.MassMarks(points.value, {
opacity: 1, opacity: 1,
@ -644,9 +659,19 @@ const renderMassMarks = () => {
massMarks.value.setMap(mapInstance.value); massMarks.value.setMap(mapInstance.value);
// //
massMarks.value.on('click', function (e) { massMarks.value.on('click', function (e) {
handleViewMedia(e.data.mediaId) handleViewMedia(e.data.mediaId)
}); });
// ==================================================
//
// ==================================================
const southWest = new AMap.LngLat(minLng, minLat); // 西
const northEast = new AMap.LngLat(maxLng, maxLat); //
const bounds = new AMap.Bounds(southWest, northEast);
//
mapInstance.value.setBounds(bounds);
}) })
} }
// Logo // Logo

View File

@ -371,6 +371,7 @@ const getOutMediaPageList = () => {
// //
renderMassMarks(); renderMassMarks();
}) })
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -631,27 +632,57 @@ const renderMassMarks = () => {
size: new AMap.Size(18, 18) size: new AMap.Size(18, 18)
}, },
]; ];
//
let minLng = Infinity; // 西
let minLat = Infinity; //
let maxLng = -Infinity; //
let maxLat = -Infinity; //
// //
points.value = [] points.value = []
outdoorMediaList.value.forEach(itemPoint => { outdoorMediaList.value.forEach(itemPoint => {
if (itemPoint.dataScopeDeptId == 220) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 0 }) if (itemPoint.dataScopeDeptId == 220) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 0 })
if (itemPoint.dataScopeDeptId == 219) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 1 }) else if (itemPoint.dataScopeDeptId == 219) points.value.push({ "lnglat": [itemPoint.mapX, itemPoint.mapY], "name": itemPoint.mediaName, "mediaId": itemPoint.id, "style": 1 })
});
// MassMarks //
massMarks.value = new AMap.MassMarks(points.value, { const lng = itemPoint.mapX;
opacity: 1, const lat = itemPoint.mapY;
zIndex: 111, if (lng < minLng) minLng = lng;
cursor: 'pointer', if (lat < minLat) minLat = lat;
style: styles if (lng > maxLng) maxLng = lng;
if (lat > maxLat) maxLat = lat;
}); });
// // MassMarks
massMarks.value.setMap(mapInstance.value); if (points.value.length > 0) {
// MassMarks
massMarks.value = new AMap.MassMarks(points.value, {
opacity: 1,
zIndex: 111,
cursor: 'pointer',
style: styles
});
//
massMarks.value.setMap(mapInstance.value);
//
massMarks.value.on('click', function (e) {
handleViewMedia(e.data.mediaId)
});
// ==================================================
//
// ==================================================
const southWest = new AMap.LngLat(minLng, minLat); // 西
const northEast = new AMap.LngLat(maxLng, maxLat); //
const bounds = new AMap.Bounds(southWest, northEast);
//
mapInstance.value.setBounds(bounds);
}
//
massMarks.value.on('click', function (e) {
handleViewMedia(e.data.mediaId)
});
} }
// Logo // Logo
const hideAmapLogo = () => { const hideAmapLogo = () => {