This commit is contained in:
zengmingjie 2025-06-26 23:32:16 +08:00
parent 534baec75d
commit ce846cc58f
1 changed files with 16 additions and 13 deletions

View File

@ -70,20 +70,23 @@ export default {
watch: {
positionPoint: {
handler(newVal) {
if (newVal && this.latitude && this.longitude && window.olMap) {
const newLocation = fromLonLat(
[this.longitude, this.latitude],
"EPSG:3857"
);
this.$message.success("定位成功");
this.updateMapPosition(this.longitude, this.latitude);
window.olMap.getView().animate({
center: newLocation,
zoom: 13
});
if (newVal) {
if (newVal && this.latitude && this.longitude && window.olMap) {
const newLocation = fromLonLat(
[this.longitude, this.latitude],
"EPSG:3857"
);
this.$message.success("定位成功");
this.updateMapPosition(this.longitude, this.latitude);
window.olMap.getView().animate({
center: newLocation,
zoom: 13
});
}
if (this.latitude === "" && this.longitude === "") {
this.$message.error("定位失败,请稍后重试");
}
this.$store.commit("SET_POSITIONPOINT", false);
} else {
this.$message.error("定位失败,请稍后重试");
}
},
deep: true