This is the documentation of version 0.62.1. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Function getSearchSuggestions

    • One query surface over places, brands and categories.

      Parameters

      Returns Promise<SearchSuggestionsResponse>

      Fans out to 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.

      • Blend: the SDK's, modelled on Places Search v3. At most one brand or category leads, and only when the whole query names it; places follow.
      • Cost: two requests per call; narrowing filters.kinds to one side of SearchSuggestionKind skips the other. No debouncing or caching, which belong in the caller's input loop.
      • Geography: filters.boundingBox restricts and origin measures distance. V2 takes one geographic input per request, so inside a box origin does not rank the places.
      • Cancellation: 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.flyTo({ center: place.geometry.coordinates });
      }
      }