From 6a6a7c64d9caf41cdd9e3696a481a912f8707e64 Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Sat, 23 Sep 2023 13:59:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E7=BB=84=E7=BB=87=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=9C=B0=E5=9B=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../communityParty/partyOrg/create.vue | 39 +++++++++++-------- .../communityParty/partyOrg/update.vue | 4 -- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/views/modules/communityParty/partyOrg/create.vue b/src/views/modules/communityParty/partyOrg/create.vue index 36bca0a26..91cec9058 100644 --- a/src/views/modules/communityParty/partyOrg/create.vue +++ b/src/views/modules/communityParty/partyOrg/create.vue @@ -101,9 +101,9 @@ placeholder="请输入位置关键词" :remote-method="searchOnMap" :loading="mapLoading"> - @@ -148,7 +148,6 @@ export default { xingzhengSelectorVisible: true, // 行政组织是否可见 // 地图 - searchOptions: [], //用于展示的地图搜索结果列表 searchValue: '', mapLoading: false, // 地图加载 mapSearchResultList: [], // 地图搜索结果列表 @@ -191,7 +190,13 @@ export default { let { latitude, longitude } = this.$store.state.user; this.$nextTick(() => { + if(!map){ this.initMap(latitude, longitude); + + }else{ + map.setCenter(latitude, longitude); + map.setMarker(latitude, longitude); + } }) }, @@ -411,14 +416,12 @@ export default { if (msg == "success" && data.resultList && data.resultList.length > 0) { - if (data.resultList && data.resultList.length > 0) { - this.mapSearchResultList = data.resultList - this.searchOptions = this.mapSearchResultList.map(item => { - return { value: `${item.hotPointID}`, label: `${item.address + item.name}` }; + // this.mapSearchResultList = data.resultList + this.mapSearchResultList = data.resultList.map(item => { + return { value: `${item.id}`, label: `${item.address + item.name}`,location:item.location }; }); - } } else { - this.searchOptions = [ + this.mapSearchResultList = [ { value: '0', label: '未检索到结果' @@ -426,7 +429,7 @@ export default { ] } } else { - this.searchOptions = []; + this.mapSearchResultList = []; } }, @@ -442,7 +445,7 @@ export default { if (msg == "success") { this.dataForm.address = data.address this.searchValue = data.address - this.searchOptions = [] + this.mapSearchResultList = [] } }, @@ -452,12 +455,14 @@ export default { * @param index */ handleMapSearchResultSelected (index) { - let selPosition = this.resultList[index] - let lonlat = selPosition.lonlat.split(" ") - map.setCenter(lonlat[1], lonlat[0]); - map.setMarker(lonlat[1], lonlat[0]); - this.dataForm.latitude = lonlat[1]; - this.dataForm.longitude = lonlat[0]; + console.log(index) + console.log(this.mapSearchResultList);; + let selPosition = this.mapSearchResultList[index] + let {lat,lng} = selPosition.location + map.setCenter(lat, lng); + map.setMarker(lat, lng); + this.dataForm.latitude = lat; + this.dataForm.longitude = lng; this.dataForm.address = selPosition.address + selPosition.name }, diff --git a/src/views/modules/communityParty/partyOrg/update.vue b/src/views/modules/communityParty/partyOrg/update.vue index d0749957d..1d73a2fc1 100644 --- a/src/views/modules/communityParty/partyOrg/update.vue +++ b/src/views/modules/communityParty/partyOrg/update.vue @@ -165,19 +165,15 @@ export default { await this.loadPrincipals(); // 初始化地图 - this.$nextTick(() => { this.dataForm.principalId = partyOrgInfo.principalId; console.log(this.principals) console.log(this.dataForm.principalId ) - if (!map) { - // console.log("经纬度:", longitude, latitude); this.initMap(this.dataForm.latitude, this.dataForm.longitude); } else { map.setCenter(this.dataForm.latitude, this.dataForm.longitude); map.setMarker(this.dataForm.latitude, this.dataForm.longitude); } - }); }, // 初始化地图