diff --git a/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue b/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue
index 750db97..9a9861e 100644
--- a/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue
+++ b/ruoyi-ui/src/views/cesiumMap/LocateDialog.vue
@@ -61,7 +61,7 @@
@@ -70,7 +70,7 @@
@@ -78,7 +78,7 @@
@@ -107,6 +107,10 @@ export default {
visible: {
type: Boolean,
default: false
+ },
+ coordinateFormat: {
+ type: String,
+ default: 'dms' // 'decimal' 或 'dms'
}
},
data() {
@@ -137,9 +141,44 @@ export default {
this.loadScenarios()
}
this.$emit('update:visible', newVal)
+ },
+ coordinateFormat: {
+ handler(newVal) {
+ this.updateCoordinateFormat(newVal)
+ }
}
- },
+ },
methods: {
+ updateCoordinateFormat(newFormat) {
+ if (!this.formData.lng || !this.formData.lat) return
+
+ let lngDegrees, latDegrees
+
+ if (this.coordinateFormat === 'dms') {
+ lngDegrees = this.dmsToDegrees(this.formData.lng)
+ latDegrees = this.dmsToDegrees(this.formData.lat)
+ } else {
+ lngDegrees = parseFloat(this.formData.lng)
+ latDegrees = parseFloat(this.formData.lat)
+ }
+
+ if (lngDegrees !== null && latDegrees !== null && !isNaN(lngDegrees) && !isNaN(latDegrees)) {
+ if (newFormat === 'dms') {
+ this.formData.lng = this.degreesToDMS(lngDegrees)
+ this.formData.lat = this.degreesToDMS(latDegrees)
+ } else {
+ this.formData.lng = lngDegrees.toFixed(6)
+ this.formData.lat = latDegrees.toFixed(6)
+ }
+ }
+ },
+ formatCoordinate(value) {
+ if (this.coordinateFormat === 'dms') {
+ return this.degreesToDMS(value)
+ } else {
+ return value.toFixed(6)
+ }
+ },
degreesToDMS(decimalDegrees) {
const degrees = Math.floor(decimalDegrees)
const minutesDecimal = (decimalDegrees - degrees) * 60
@@ -157,12 +196,22 @@ export default {
return sign * (Math.abs(degrees) + minutes / 60 + seconds / 3600)
},
resetForm() {
- this.formData = {
- scenarioId: null,
- routeId: null,
- waypointId: null,
- lng: '116°23\'48.64"',
- lat: '39°54\'33.48"'
+ if (this.coordinateFormat === 'dms') {
+ this.formData = {
+ scenarioId: null,
+ routeId: null,
+ waypointId: null,
+ lng: '116°23\'48.64"',
+ lat: '39°54\'33.48"'
+ }
+ } else {
+ this.formData = {
+ scenarioId: null,
+ routeId: null,
+ waypointId: null,
+ lng: '116.396844',
+ lat: '39.909289'
+ }
}
this.routeList = []
this.waypointList = []
@@ -214,8 +263,8 @@ export default {
if (value) {
const waypoint = this.waypointList.find(w => w.id === value)
if (waypoint) {
- this.formData.lng = this.degreesToDMS(waypoint.lng)
- this.formData.lat = this.degreesToDMS(waypoint.lat)
+ this.formData.lng = this.formatCoordinate(waypoint.lng)
+ this.formData.lat = this.formatCoordinate(waypoint.lat)
}
}
},
@@ -233,12 +282,24 @@ export default {
return
}
- const lngDegrees = this.dmsToDegrees(lng)
- const latDegrees = this.dmsToDegrees(lat)
+ let lngDegrees, latDegrees
- if (lngDegrees === null || latDegrees === null || isNaN(lngDegrees) || isNaN(latDegrees)) {
- this.$message.error('请输入有效的度分秒格式!格式:116°23\'48.64"')
- return
+ if (this.coordinateFormat === 'dms') {
+ lngDegrees = this.dmsToDegrees(lng)
+ latDegrees = this.dmsToDegrees(lat)
+
+ if (lngDegrees === null || latDegrees === null || isNaN(lngDegrees) || isNaN(latDegrees)) {
+ this.$message.error('请输入有效的度分秒格式!格式:116°23\'48.64"')
+ return
+ }
+ } else {
+ lngDegrees = parseFloat(lng)
+ latDegrees = parseFloat(lat)
+
+ if (isNaN(lngDegrees) || isNaN(latDegrees)) {
+ this.$message.error('请输入有效的十进制格式!')
+ return
+ }
}
if (lngDegrees < -180 || lngDegrees > 180 || latDegrees < -90 || latDegrees > 90) {
diff --git a/ruoyi-ui/src/views/cesiumMap/index.vue b/ruoyi-ui/src/views/cesiumMap/index.vue
index 5802ace..6c8c1df 100644
--- a/ruoyi-ui/src/views/cesiumMap/index.vue
+++ b/ruoyi-ui/src/views/cesiumMap/index.vue
@@ -43,6 +43,7 @@