优化媒体地图显示

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

@ -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
// //
@ -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) {
@ -622,13 +622,28 @@ 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 => {
@ -647,6 +662,16 @@ const renderMassMarks = () => {
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,12 +632,30 @@ 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 })
//
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) {
// MassMarks // MassMarks
massMarks.value = new AMap.MassMarks(points.value, { massMarks.value = new AMap.MassMarks(points.value, {
opacity: 1, opacity: 1,
@ -652,6 +671,18 @@ const renderMassMarks = () => {
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
const hideAmapLogo = () => { const hideAmapLogo = () => {