This commit is contained in:
JS-LM
2023-05-10 09:16:09 +08:00
parent d2eed9ad3a
commit e89a9ebba5
4 changed files with 109 additions and 61 deletions

View File

@@ -43,6 +43,7 @@ window._AMapSecurityConfig = {
securityJsCode: "829b6b73f84682c2eb982eaa47a745b8",
};
export default {
props:['stationLat','stationLng'],
data() {
return {
dialogImageUrl: '',
@@ -68,7 +69,6 @@ export default {
};
},
methods: {
// 点击搜索按钮
send() {
this.searchPlaceInput = this.inputObject.userInput;
@@ -76,16 +76,16 @@ export default {
// 向表单 site-info传值
bus.$emit("inp", this.searchPlaceInput);
},
queryStationInfo() {
getStation(this.stationId).then((response) => {
this.lat = response.data.stationLat;
this.lng = response.data.stationLng;
console.log(this.lat, this.lng);
this.initMap(this.lat, this.lng);
});
},
// queryStationInfo() {
// getStation(this.stationId).then((response) => {
// this.lat = response.data.stationLat;
// this.lng = response.data.stationLng;
// console.log(this.lat, this.lng);
// this.initMap(this.lat, this.lng);
// });
// },
initMap(lat, lng) {
initMap() {
// console.log(lat, lng);
AMapLoader.load({
key: "61436c9c789d301a5b73853d176710cf", // 申请好的Web端开发者Key首次调用 load 时必填
@@ -97,7 +97,7 @@ export default {
//设置地图容器id
viewMode: "3D", //是否为3D地图模式
zoom: 15, //初始化地图级别
center: [+lng, +lat], //初始化地图中心点位置
center: [+this.stationLng, +this.stationLat], //初始化地图中心点位置
});
// this.map.addControl(new AMap.Geolocation());
// console.log("map", this.map);
@@ -105,12 +105,12 @@ export default {
this.map.setDefaultCursor("pointer");
// 点标记
let marker = new AMap.Marker({
position: new AMap.LngLat(+lng, +lat),
position: new AMap.LngLat(+this.stationLng, +this.stationLat),
});
// 将创建的点标记添加到已有的地图实例
this.map.add(marker);
AMap.plugin("AMap.AutoComplete", function () {
auto = new AMap.AutoComplete(this.autoOptions);
let auto = new AMap.AutoComplete(this.autoOptions);
//构造地点查询类
auto.on("select", this.select);
});
@@ -170,29 +170,10 @@ export default {
}
});
},
onFileChange(e) {
console.log(e,'上传图片')
// 1.获取用户选择的文件列表
const fileList = e.target.files;
console.log(fileList);
// 2.判断有没有选中图片
if (fileList.length !== 0) {
// 3.选择了图片
const reader = new FileReader();
reader.readAsDataURL(fileList[0]);
// 监听load事件,读取完成触发回调函数
reader.addEventListener("load", () => {
this.avatar = reader.result;
});
} else {
// 没有选择图片
this.avatar = "";
}
},
},
mounted() {
//DOM初始化完成进行地图初始化
// this.queryStationInfo();
// this.queryStationInfo()
},
created() {
// this.send();