|
|
@ -113,13 +113,13 @@ |
|
|
|
<div class="info-prop"> |
|
|
|
<span class="info-title-3">活动地图位置:</span> |
|
|
|
<div class="div_map2"> |
|
|
|
<div id="map_act_id"></div> |
|
|
|
<div id="app_heart_detail_act"></div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="info-prop"> |
|
|
|
<span class="info-title-3">签到地图位置:</span> |
|
|
|
<div class="div_map2"> |
|
|
|
<div id="map_signin_id"></div> |
|
|
|
<div id="app_heart_detail_signin"></div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
@ -227,10 +227,10 @@ export default { |
|
|
|
methods: { |
|
|
|
diaDestroy () { |
|
|
|
if (map_act) { |
|
|
|
map_act.destroy() |
|
|
|
// map_act.destroy() |
|
|
|
} |
|
|
|
if (map_signin) { |
|
|
|
map_signin.destroy() |
|
|
|
// map_signin.destroy() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
@ -242,9 +242,27 @@ export default { |
|
|
|
await this.loadFormData() |
|
|
|
|
|
|
|
this.initLoading = true |
|
|
|
|
|
|
|
let { latitude, longitude } = this.$store.state.user; |
|
|
|
console.log('lat' + latitude + ',lon' + longitude) |
|
|
|
if (this.formData.latitude && this.formData.longitude) { |
|
|
|
latitude = this.formData.latitude |
|
|
|
longitude = this.formData.longitude |
|
|
|
} |
|
|
|
if (!latitude || latitude == "" || latitude == "0") { |
|
|
|
latitude = 39.9088810666821; |
|
|
|
longitude = 116.39743841556731; |
|
|
|
} |
|
|
|
this.$nextTick(() => { |
|
|
|
this.initMap() |
|
|
|
if (!map_act) { |
|
|
|
this.initMap(this.formData.actLatitude, this.formData.actLongitude, this.formData.signInLatitude, this.formData.signInLongitude) |
|
|
|
} else { |
|
|
|
map_act.setCenter(this.formData.actLatitude, this.formData.actLongitude); |
|
|
|
map_act.setMarker(this.formData.actLatitude, this.formData.actLongitude); |
|
|
|
map_signin.setCenter(this.formData.signInLatitude, this.formData.signInLongitude); |
|
|
|
map_signin.setMarker(this.formData.signInLatitude, this.formData.signInLongitude); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
this.endLoading() |
|
|
|
|
|
|
@ -292,150 +310,44 @@ export default { |
|
|
|
return c || content |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
|
|
|
initMap () { |
|
|
|
// 定义地图中心点坐标 |
|
|
|
var centerAct = new window.TMap.LatLng(this.formData.actLatitude, this.formData.actLongitude); |
|
|
|
var centerSign = new window.TMap.LatLng(this.formData.signInLatitude, this.formData.signInLongitude); |
|
|
|
// 定义map变量,调用 TMap.Map() 构造函数创建地图 |
|
|
|
map_act = new window.TMap.Map(document.getElementById("map_act_id"), { |
|
|
|
center: centerAct, // 设置地图中心点坐标 |
|
|
|
zoom: 17.2, // 设置地图缩放级别 |
|
|
|
pitch: 43.5, // 设置俯仰角 |
|
|
|
rotation: 45, // 设置地图旋转角度 |
|
|
|
}); |
|
|
|
map_signin = new window.TMap.Map(document.getElementById("map_signin_id"), { |
|
|
|
center: centerSign, // 设置地图中心点坐标 |
|
|
|
zoom: 17.2, // 设置地图缩放级别 |
|
|
|
pitch: 43.5, // 设置俯仰角 |
|
|
|
rotation: 45, // 设置地图旋转角度 |
|
|
|
}); |
|
|
|
|
|
|
|
// search_act = new window.TMap.service.Search({ pageSize: 10 }); |
|
|
|
// 新建一个地点搜索类 |
|
|
|
markers_act = new TMap.MultiMarker({ |
|
|
|
map: map_act, |
|
|
|
geometries: [], |
|
|
|
}); |
|
|
|
infoWindowList_act = Array(10); |
|
|
|
|
|
|
|
geocoder_act = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 |
|
|
|
|
|
|
|
// search_signin = new window.TMap.service.Search({ pageSize: 10 }); |
|
|
|
// 新建一个地点搜索类 |
|
|
|
markers_signin = new TMap.MultiMarker({ |
|
|
|
map: map_signin, |
|
|
|
geometries: [], |
|
|
|
}); |
|
|
|
infoWindowList_signin = Array(10); |
|
|
|
|
|
|
|
geocoder_signin = new TMap.service.Geocoder(); // 新建一个正逆地址解析类 |
|
|
|
|
|
|
|
// 监听地图平移结束 |
|
|
|
map_act.on("panend", (e) => { |
|
|
|
this.handleMoveCenterAct(e); |
|
|
|
}); |
|
|
|
this.handleMoveCenterAct(); |
|
|
|
|
|
|
|
// 监听地图平移结束 |
|
|
|
map_signin.on("panend", (e) => { |
|
|
|
this.handleMoveCenterSignin(e); |
|
|
|
}); |
|
|
|
this.handleMoveCenterSignin(); |
|
|
|
}, |
|
|
|
initMap (latitude1, longitude1, latitude2, longitude2) { |
|
|
|
|
|
|
|
setMarkerAct (lat, lng) { |
|
|
|
markers_act.setGeometries([]); |
|
|
|
markers_act.add([ |
|
|
|
map_act = new daiMap( |
|
|
|
document.getElementById("app_heart_detail_act"), |
|
|
|
{ latitude1, longitude1 }, |
|
|
|
{ |
|
|
|
id: "4", |
|
|
|
styleId: "marker", |
|
|
|
position: new TMap.LatLng(lat, lng), |
|
|
|
properties: { |
|
|
|
title: "marker4", |
|
|
|
}, |
|
|
|
}, |
|
|
|
]); |
|
|
|
}, |
|
|
|
|
|
|
|
zoom: 16.2, // 设置地图缩放级别 |
|
|
|
pitch: 43.5, // 设置俯仰角 |
|
|
|
rotation: 45, // 设置地图旋转角度 |
|
|
|
} |
|
|
|
); |
|
|
|
map_signin = new daiMap( |
|
|
|
document.getElementById("app_heart_detail_signin"), |
|
|
|
{ latitude2, longitude2 }, |
|
|
|
{ |
|
|
|
zoom: 16.2, // 设置地图缩放级别 |
|
|
|
pitch: 43.5, // 设置俯仰角 |
|
|
|
rotation: 45, // 设置地图旋转角度 |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
// // 监听地图平移结束 |
|
|
|
// map_act.on("dragend", (e) => { |
|
|
|
// this.handleMoveCenterAct(e); |
|
|
|
// }); |
|
|
|
|
|
|
|
handleMoveCenterAct (e) { |
|
|
|
//修改地图中心点 |
|
|
|
const center = map_act.getCenter(); |
|
|
|
const lat = center.getLat(); |
|
|
|
const lng = center.getLng(); |
|
|
|
this.formData.actLatitude = lat; |
|
|
|
this.formData.actLongitude = lng; |
|
|
|
this.setMarkerAct(lat, lng); |
|
|
|
map_act.setCenter(latitude1, longitude1); |
|
|
|
map_act.setMarker(latitude1, longitude1); |
|
|
|
|
|
|
|
if (e && e.originalEvent) { |
|
|
|
geocoder_act |
|
|
|
.getAddress({ location: new TMap.LatLng(lat, lng) }) // 将给定的坐标位置转换为地址 |
|
|
|
.then((result) => { |
|
|
|
this.formData.actAddress = result.result.address; |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
setMarkerSignin (lat, lng) { |
|
|
|
markers_signin.setGeometries([]); |
|
|
|
markers_signin.add([ |
|
|
|
{ |
|
|
|
id: "4", |
|
|
|
styleId: "marker", |
|
|
|
position: new TMap.LatLng(lat, lng), |
|
|
|
properties: { |
|
|
|
title: "marker4", |
|
|
|
}, |
|
|
|
}, |
|
|
|
]); |
|
|
|
}, |
|
|
|
// // 监听地图平移结束 |
|
|
|
// map_signin.on("dragend", (e) => { |
|
|
|
// this.handleMoveCenterSignin(e); |
|
|
|
// }); |
|
|
|
|
|
|
|
handleSearchMapSignin () { |
|
|
|
infoWindowList_signin.forEach((infoWindow) => { |
|
|
|
infoWindow.close(); |
|
|
|
}); |
|
|
|
infoWindowList_signin.length = 0; |
|
|
|
markers_signin.setGeometries([]); |
|
|
|
// 在地图显示范围内以给定的关键字搜索地点 |
|
|
|
search_signin |
|
|
|
.searchRectangle({ |
|
|
|
keyword: this.formData.signInAddress, |
|
|
|
bounds: map_signin.getBounds(), |
|
|
|
}) |
|
|
|
.then((result) => { |
|
|
|
let { data } = result; |
|
|
|
if (Array.isArray(data) && data.length > 0) { |
|
|
|
const { |
|
|
|
location: { lat, lng }, |
|
|
|
} = data[0]; |
|
|
|
map_signin.setCenter(new TMap.LatLng(lat, lng)); |
|
|
|
this.setMarkerSignin(lat, lng); |
|
|
|
this.formData.signInLatitude = lat; |
|
|
|
this.formData.signInLongitude = lng; |
|
|
|
} else { |
|
|
|
this.$message.error("未检索到相关位置坐标"); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
map_signin.setCenter(latitude2, longitude2); |
|
|
|
map_signin.setMarker(latitude2, longitude2); |
|
|
|
|
|
|
|
handleMoveCenterSignin (e) { |
|
|
|
//修改地图中心点 |
|
|
|
const center = map_signin.getCenter(); |
|
|
|
const lat = center.getLat(); |
|
|
|
const lng = center.getLng(); |
|
|
|
this.formData.signInLatitude = lat; |
|
|
|
this.formData.signInLongitude = lng; |
|
|
|
this.setMarkerSignin(lat, lng); |
|
|
|
|
|
|
|
if (e && e.originalEvent) { |
|
|
|
geocoder_signin |
|
|
|
.getAddress({ location: new TMap.LatLng(lat, lng) }) // 将给定的坐标位置转换为地址 |
|
|
|
.then((result) => { |
|
|
|
this.formData.signInAddress = result.result.address; |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleCancle () { |
|
|
|