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