|
|
|
@ -88,7 +88,6 @@ |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="地图位置" |
|
|
|
prop="longitude" |
|
|
|
label-width="150px" |
|
|
|
style="display: block"> |
|
|
|
<div style="width: 500px"> |
|
|
|
<el-select v-model="searchValue" |
|
|
|
@ -110,9 +109,15 @@ |
|
|
|
class="div_map"></div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="详细地址" |
|
|
|
prop="address"> |
|
|
|
<el-input style="width: 300px" |
|
|
|
v-model="dataForm.address" |
|
|
|
placeholder="详细地址"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<template slot="footer"> |
|
|
|
<el-button @click="visible = false">{{ $t("cancel") }}</el-button> |
|
|
|
<el-button @click="handleCancle">{{ $t("cancel") }}</el-button> |
|
|
|
<el-button type="primary" |
|
|
|
@click="dataFormSubmitHandle()">{{ |
|
|
|
$t("confirm") |
|
|
|
@ -134,6 +139,11 @@ import debounce from "lodash/debounce"; |
|
|
|
export default { |
|
|
|
data () { |
|
|
|
return { |
|
|
|
searchOptions: [], |
|
|
|
searchValue: '', |
|
|
|
resultList: [], |
|
|
|
loading: false, |
|
|
|
|
|
|
|
visible: false, |
|
|
|
keyWords: "", |
|
|
|
dataForm: { |
|
|
|
@ -168,6 +178,15 @@ export default { |
|
|
|
}; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
handleCancle () { |
|
|
|
this.resetData() |
|
|
|
this.visible = false |
|
|
|
}, |
|
|
|
resetData () { |
|
|
|
this.searchValue = '' |
|
|
|
this.searchOptions = [] |
|
|
|
this.resultList = [] |
|
|
|
}, |
|
|
|
init () { |
|
|
|
this.visible = true; |
|
|
|
this.agencyId = localStorage.getItem("agencyId"); |
|
|
|
@ -184,7 +203,15 @@ export default { |
|
|
|
this.getInfo(); |
|
|
|
} else { |
|
|
|
this.setPartyOrgType(); |
|
|
|
this.initMap(); |
|
|
|
let { latitude, longitude } = this.$store.state.user; |
|
|
|
this.$nextTick(() => { |
|
|
|
if (!map) { |
|
|
|
this.initMap(latitude, longitude); |
|
|
|
} else { |
|
|
|
map.setCenter(latitude, longitude); |
|
|
|
map.setMarker(latitude, longitude); |
|
|
|
} |
|
|
|
}) |
|
|
|
if (this.dataForm.orgId) { |
|
|
|
this.dataForm.mySelectOrg = this.dataForm.orgId; |
|
|
|
this.dataForm.orgPid = this.dataForm.orgId; |
|
|
|
@ -372,7 +399,15 @@ export default { |
|
|
|
this.getInfoAgencyLisy(); |
|
|
|
// 获取上级党组织 |
|
|
|
this.getOrgList(); |
|
|
|
this.initMap(); |
|
|
|
this.$nextTick(() => { |
|
|
|
if (!map) { |
|
|
|
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); |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
.catch(() => { }); |
|
|
|
}, |
|
|
|
@ -395,128 +430,84 @@ export default { |
|
|
|
.catch(() => { }); |
|
|
|
}, |
|
|
|
// 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
|
|
|
initMap () { |
|
|
|
document.getElementById("app").innerHTML = ""; |
|
|
|
if (document.getElementById("app")) { |
|
|
|
document.getElementById("mapSeach_id").style.display = "block"; |
|
|
|
// document.getElementById('lon_lat_id').style.display = "block" |
|
|
|
} |
|
|
|
initMap (latitude, longitude) { |
|
|
|
|
|
|
|
// 定义地图中心点坐标 |
|
|
|
var center = new window.TMap.LatLng( |
|
|
|
this.dataForm.latitude ? this.dataForm.latitude : 36.0722275, |
|
|
|
this.dataForm.longitude ? this.dataForm.longitude : 120.38945519 |
|
|
|
map = new daiMap( |
|
|
|
document.getElementById("app_icparty"), |
|
|
|
{ latitude, longitude }, |
|
|
|
{ |
|
|
|
zoom: 16.2, // 设置地图缩放级别 |
|
|
|
pitch: 43.5, // 设置俯仰角 |
|
|
|
rotation: 45, // 设置地图旋转角度 |
|
|
|
} |
|
|
|
); |
|
|
|
// 定义map变量,调用 TMap.Map() 构造函数创建地图 |
|
|
|
map = new window.TMap.Map(document.getElementById("app"), { |
|
|
|
center: center, // 设置地图中心点坐标 |
|
|
|
zoom: 16.2, // 设置地图缩放级别 |
|
|
|
pitch: 43.5, // 设置俯仰角 |
|
|
|
rotation: 45, // 设置地图旋转角度 |
|
|
|
}); |
|
|
|
|
|
|
|
search = new window.TMap.service.Search({ pageSize: 10 }); |
|
|
|
// 新建一个地点搜索类 |
|
|
|
markers = new TMap.MultiMarker({ |
|
|
|
map: map, |
|
|
|
geometries: [], |
|
|
|
// 监听地图平移结束 |
|
|
|
map.on("dragend", (e) => { |
|
|
|
this.handleMoveCenter(e); |
|
|
|
}); |
|
|
|
infoWindowList = Array(10); |
|
|
|
|
|
|
|
geocoder = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 |
|
|
|
map.setCenter(latitude, longitude); |
|
|
|
map.setMarker(latitude, longitude); |
|
|
|
|
|
|
|
// 监听地图平移结束 |
|
|
|
map.on("panend", () => { |
|
|
|
this.handleMoveCenter(); |
|
|
|
}); |
|
|
|
this.handleMoveCenter(); |
|
|
|
this.convert(); |
|
|
|
}, |
|
|
|
setMarker (lat, lng) { |
|
|
|
markers.setGeometries([]); |
|
|
|
markers.add([ |
|
|
|
{ |
|
|
|
id: "4", |
|
|
|
styleId: "marker", |
|
|
|
position: new TMap.LatLng(lat, lng), |
|
|
|
properties: { |
|
|
|
title: "marker4", |
|
|
|
}, |
|
|
|
}, |
|
|
|
]); |
|
|
|
}, |
|
|
|
|
|
|
|
handleSearchMap () { |
|
|
|
infoWindowList.forEach((infoWindow) => { |
|
|
|
infoWindow.close(); |
|
|
|
}); |
|
|
|
infoWindowList.length = 0; |
|
|
|
markers.setGeometries([]); |
|
|
|
// 在地图显示范围内以给定的关键字搜索地点 |
|
|
|
search |
|
|
|
.searchNearby({ |
|
|
|
keyword: this.keyWords, |
|
|
|
radius: 1000, |
|
|
|
autoExtend: true, |
|
|
|
center: map.getCenter(), |
|
|
|
}) |
|
|
|
.then((result) => { |
|
|
|
let { data } = result; |
|
|
|
if (Array.isArray(data) && data.length > 0) { |
|
|
|
const { |
|
|
|
location: { lat, lng }, |
|
|
|
} = data[0]; |
|
|
|
map.setCenter(new TMap.LatLng(lat, lng)); |
|
|
|
this.setMarker(lat, lng); |
|
|
|
this.dataForm.latitude = lat; |
|
|
|
this.dataForm.longitude = lng; |
|
|
|
this.convert(); |
|
|
|
} else { |
|
|
|
this.$message.error("未检索到相关位置坐标"); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
handleMoveCenter () { |
|
|
|
async handleMoveCenter () { |
|
|
|
//修改地图中心点 |
|
|
|
const center = map.getCenter(); |
|
|
|
const lat = center.getLat(); |
|
|
|
const lng = center.getLng(); |
|
|
|
if (lng === 120.38945519) { |
|
|
|
this.dataForm.latitude = ""; |
|
|
|
this.dataForm.longitude = ""; |
|
|
|
} else { |
|
|
|
this.dataForm.latitude = lat; |
|
|
|
this.dataForm.longitude = lng; |
|
|
|
const { lat, lng } = map.getCenter(); |
|
|
|
this.dataForm.latitude = lat; |
|
|
|
this.dataForm.longitude = lng; |
|
|
|
map.setMarker(lat, lng); |
|
|
|
|
|
|
|
let { msg, data } = await map.getAddress(lat, lng); |
|
|
|
if (msg == "success") { |
|
|
|
this.dataForm.address = data.address |
|
|
|
this.searchValue = data.address |
|
|
|
this.searchOptions = [] |
|
|
|
|
|
|
|
} |
|
|
|
this.setMarker(lat, lng); |
|
|
|
this.convert(lat, lng); |
|
|
|
}, |
|
|
|
|
|
|
|
convert (lat, lng) { |
|
|
|
markers.setGeometries([]); |
|
|
|
// var input = document.getElementById('location').value.split(':'); |
|
|
|
let location; |
|
|
|
if (lat && lng) { |
|
|
|
location = new TMap.LatLng(lat, lng); |
|
|
|
async remoteMethod (query) { |
|
|
|
|
|
|
|
if (query !== '') { |
|
|
|
this.loading = true; |
|
|
|
|
|
|
|
const { msg, data } = await map.searchNearby(query); |
|
|
|
this.loading = false; |
|
|
|
this.resultList = [] |
|
|
|
|
|
|
|
if (msg == "success" && data.resultList && data.resultList.length > 0) { |
|
|
|
|
|
|
|
if (data.resultList && data.resultList.length > 0) { |
|
|
|
this.resultList = data.resultList |
|
|
|
this.searchOptions = this.resultList.map(item => { |
|
|
|
return { value: `${item.hotPointID}`, label: `${item.address + item.name}` }; |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.searchOptions = [ |
|
|
|
{ |
|
|
|
value: '0', |
|
|
|
label: '未检索到结果' |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
} else { |
|
|
|
location = new TMap.LatLng( |
|
|
|
this.dataForm.latitude, |
|
|
|
this.dataForm.longitude |
|
|
|
); |
|
|
|
this.searchOptions = []; |
|
|
|
} |
|
|
|
// map.setCenter(location); |
|
|
|
markers.updateGeometries([ |
|
|
|
{ |
|
|
|
id: "main", // 点标注数据数组 |
|
|
|
position: location, |
|
|
|
}, |
|
|
|
]); |
|
|
|
// 将给定的坐标位置转换为地址 |
|
|
|
geocoder.getAddress({ location: location }).then((result) => { |
|
|
|
this.dataForm.address = result.result.address; |
|
|
|
// 显示搜索到的地址 |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
handleClickKey (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]; |
|
|
|
this.dataForm.address = selPosition.address + selPosition.name |
|
|
|
}, |
|
|
|
// 表单提交 |
|
|
|
dataFormSubmitHandle: debounce( |
|
|
|
@ -550,7 +541,9 @@ export default { |
|
|
|
type: "success", |
|
|
|
duration: 500, |
|
|
|
onClose: () => { |
|
|
|
this.resetData() |
|
|
|
this.visible = false; |
|
|
|
|
|
|
|
this.$emit("refreshDataList"); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|