TomTom Maps for JavaScript
    Preparing search index...

    Function getSearchSuggestions

    • Suggests places, brands and categories for one query.

      Parameters

      Returns Promise<SearchSuggestionsResponse>

      It calls autocomplete and search in parallel and blends them into one ranked list, so "pizz" gets the Pizzeria category and the pizzerias down the road together. A complete query works as well as a partial one.

      • The SDK's blend is modelled on Places Search v3. At most one brand or category leads, and only when the whole query names it. Places follow.
      • Each call makes two requests. Narrowing filters.kinds to one side of SearchSuggestionKind skips the other. There is no debouncing or caching, which belong in your input loop.
      • filters.boundingBox restricts results and geoBias.position measures distance. V2 takes one geographic input per request, so inside a box geoBias does not rank the places.
      • Both requests share signal, so aborting drops the pair.
      const { suggestions } = await getSearchSuggestions({ query: 'pizz' });

      for (const suggestion of suggestions) {
      if (suggestion.kind === 'category' || suggestion.kind === 'brand') {
      // A refinement: run the follow-up it describes.
      const narrowed = await suggestion.refine();
      } else {
      const place = await suggestion.resolve();
      map.mapLibreMap.flyTo({ center: place.geometry.coordinates as [number, number] });
      }
      }