Skip to content
View source

Search

useSearch wraps MapKit's search service with promise-based autocomplete and search methods. Type to get live suggestions, then pick one to drop results on the map.

Search.vue
<script setup lang="ts">
  import { VMap, VMarkerAnnotation, useSearch } from '@geoql/v-mapkit';

  const { autocomplete, search } = useSearch();
  const suggestions = shallowRef([]);

  // live autocomplete as the user types
  async function onInput(value) {
    const res = await autocomplete(value);
    suggestions.value = res.results;
  }

  // full search → place results
  async function runSearch(value) {
    const res = await search(value);
    results.value = res.places;
  }
</script>