首页地图修改

This commit is contained in:
cwchen 2026-01-28 13:19:16 +08:00
parent c6b4febb4d
commit 2e5f9029e7
1 changed files with 39 additions and 21 deletions

View File

@ -4,7 +4,7 @@
<div class="map-overlay" style="display: flex"> <div class="map-overlay" style="display: flex">
<el-row > <el-row >
<el-select v-model="queryParams.proId" placeholder="请选择工程" style="width: 100%" @change="getProjectList"> <el-select v-model="queryParams.proId" placeholder="请选择工程" style="width: 100%" @change="loadProjectMarkers">
<el-option <el-option
:key="item.proId" :key="item.proId"
:value="item.proId" :value="item.proId"
@ -54,30 +54,49 @@ export default {
resetQuery(){ resetQuery(){
this.queryParams.proId = undefined this.queryParams.proId = undefined
this.getProjectList() this.loadProjectMarkers()
}, },
// //
async getProjectList() { initMapAndLoadMarkers() {
if (!this.map) {
this.initMap()
}
// 使
const onTilesLoaded = () => {
this.loadProjectMarkers()
this.map.removeEventListener('tilesloaded', onTilesLoaded)
}
//
this.map.addEventListener('tilesloaded', onTilesLoaded)
},
//
async loadProjectMarkers() {
const {rows: res} = await listProject({ const {rows: res} = await listProject({
proId: this.queryParams.proId, proId: this.queryParams.proId,
pageNum: 1, pageNum: 1,
pageSize: 1000, pageSize: 1000,
}) })
this.$nextTick(() => { this.map.clearOverlays()
if (!this.map) {
this.initMap()
} else {
this.map.clearOverlays(); //
}
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach((item) => {
this.addMarker(item) this.addMarker(item)
}) })
//
if (res.length === 1) {
const point = new BMapGL.Point(res[0].longitude, res[0].latitude)
this.map.centerAndZoom(point, 15)
} }
}) }
},
//
async getProjectList() {
// loadProjectMarkers
}, },
// //
@ -102,8 +121,6 @@ export default {
this.map.addOverlay(marker) this.map.addOverlay(marker)
// #002db6
// label // label
const label = new BMapGL.Label(item.proName, { const label = new BMapGL.Label(item.proName, {
position: point, position: point,
@ -143,13 +160,14 @@ export default {
}, },
created() { created() {
this.getProjectList()
this.getList() this.getList()
//
this.$nextTick(() => {
this.initMapAndLoadMarkers()
})
}, },
updated() { // updated
this.getProjectList()
},
} }
</script> </script>