首页地图修改

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">
<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
:key="item.proId"
:value="item.proId"
@ -54,30 +54,49 @@ export default {
resetQuery(){
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({
proId: this.queryParams.proId,
pageNum: 1,
pageSize: 1000,
})
this.$nextTick(() => {
if (!this.map) {
this.initMap()
} else {
this.map.clearOverlays(); //
}
this.map.clearOverlays()
if (res.length > 0) {
res.forEach((item) => {
this.addMarker(item)
})
if (res.length > 0) {
res.forEach((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)
// #002db6
// label
const label = new BMapGL.Label(item.proName, {
position: point,
@ -143,13 +160,14 @@ export default {
},
created() {
this.getProjectList()
this.getList()
//
this.$nextTick(() => {
this.initMapAndLoadMarkers()
})
},
updated() {
this.getProjectList()
},
// updated
}
</script>