From e5a958916e96951c309c141ca743a2f383a23c03 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Mon, 24 Apr 2023 12:31:08 -0700 Subject: [PATCH] edit: allow using precise location (fix #604) Signed-off-by: Varun Patil --- src/components/modal/EditLocation.vue | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/modal/EditLocation.vue b/src/components/modal/EditLocation.vue index 1d280a7d..ba19209a 100644 --- a/src/components/modal/EditLocation.vue +++ b/src/components/modal/EditLocation.vue @@ -74,8 +74,8 @@ import UndoIcon from 'vue-material-design-icons/UndoVariant.vue'; type NLocation = { osm_id: number; - type: string; - icon: string; + type?: string; + icon?: string; display_name: string; lat: string; lon: string; @@ -155,6 +155,21 @@ export default defineComponent({ return; } + // Check if searchbar is already a coordinate + const coords = this.searchBar.split(','); + if (coords.length === 2) { + const lat = Number(coords[0].trim()); + const lon = Number(coords[1].trim()); + if (!isNaN(lat) && !isNaN(lon)) { + return this.select({ + osm_id: 0, + display_name: `${lat.toFixed(6)}, ${lon.toFixed(6)}`, + lat: lat.toFixed(6), + lon: lon.toFixed(6), + }); + } + } + this.loading = true; const q = window.encodeURIComponent(this.searchBar); axios