From e7356b3c3c934deaa73b2aca01f67e414d94ec85 Mon Sep 17 00:00:00 2001 From: SRP-mango Date: Thu, 14 Sep 2023 23:57:18 +0700 Subject: [PATCH 1/2] hide search bar after search --- src/views/Home.vue | 53 ++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index 27f4625..03a2106 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -14,30 +14,36 @@ - - + +
+ +
+ + mdi-crosshairs-gps +
-
- -
+
+ +
{ - // Extract latitude and longitude from the selected result const lat = parseFloat(result.lat); const lon = parseFloat(result.lon); - - // Update the center coordinates to move the camera to the selected location center.value = [lon, lat]; + hideSearchResults.value = true; }; const performSearch = async () => { @@ -100,14 +107,14 @@ const performSearch = async () => { `https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(searchQuery.value)}` ); - // Process the search results and limit to, let's say, 5 results searchResults.value = response.data.slice(0, 5); + + hideSearchResults.value = false; } catch (error) { console.error("Error fetching search results:", error); } }; - //Show API const handleMapClick = async event => { const clickedCoordinate = event.coordinate; From cab24874f74713586277cb087a827c18d82bc58d Mon Sep 17 00:00:00 2001 From: SRP-mango Date: Fri, 15 Sep 2023 01:36:47 +0700 Subject: [PATCH 2/2] toggle search bar --- src/views/Home.vue | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index 03a2106..e392d98 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -20,6 +20,7 @@ v-model="searchQuery" @keyup.enter="performSearch" @input="performSearch" + @click="toggleSearchBar()" density="compact" variant="solo" prepend-inner-icon="mdi-magnify" @@ -37,13 +38,28 @@ -
-
    -
  • - {{ result.display_name }} -
  • -
-
+ + + + + + + mdi-map-marker + + {{ result.display_name }} + + + { + showSearchBar.value = !showSearchBar.value; +}; const moveToLocation = (result) => { const lat = parseFloat(result.lat); const lon = parseFloat(result.lon); center.value = [lon, lat]; - hideSearchResults.value = true; + showSearchBar.value = false; }; const performSearch = async () => { @@ -108,8 +126,6 @@ const performSearch = async () => { ); searchResults.value = response.data.slice(0, 5); - - hideSearchResults.value = false; } catch (error) { console.error("Error fetching search results:", error); }