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

    Type Alias FuzzySearchParams

    FuzzySearchParams: CommonSearchParams<GetObject, FuzzySearchResponseAPI> & CommonGeocodeAndFuzzySearchParams & {
        filters?: SearchFilters;
        maxFuzzyLevel?: number;
        minFuzzyLevel?: number;
    }

    Parameters for fuzzy search queries.

    Fuzzy search finds places and addresses from partial or misspelled text queries. It handles typos, abbreviations and incomplete input gracefully.

    Type Declaration

    • Optionalfilters?: SearchFilters

      The country and POI-attribute restrictions, together, on what may come back.

    • OptionalmaxFuzzyLevel?: number

      Maximum fuzziness level to use.

      It sets the upper limit of tolerance for character differences. Higher values allow more variations but may include irrelevant results.

      If no results are found at lower levels, the search tries increasingly fuzzy matching up to this level.

      2
      

      1

      4

      // Allow very fuzzy matching
      maxFuzzyLevel: 4

      // Strict matching only
      maxFuzzyLevel: 1
    • OptionalminFuzzyLevel?: number

      Minimum fuzziness level to use.

      It controls how tolerant the search is to character differences. Lower values require closer matches to the query text.

      Fuzziness levels correspond to Levenshtein edit distance. Each level, from 1 to 4, allows that many character differences.

      Higher minimum levels make the search more lenient but may return less relevant results.

      1
      

      1

      4

      minFuzzyLevel: 2  // Require at least moderate similarity
      

    Pass these to discoverPlaces, which picks the request variant from the params you give it. A route property selects along-route search, a geometries property selects geometry search, and neither selects fuzzy search.

    Fuzzy search tolerates typos and spelling mistakes, handles partial queries and abbreviations, and searches both addresses and POIs. Its fuzziness levels control precision, and it ranks results by relevance. Use it for search boxes, free-form text that users enter, recovery from autocomplete failures and broad exploratory searches.

    // Basic fuzzy search
    const params: FuzzySearchParams = {
    query: 'pizz', // Will find "pizza" restaurants
    geoBias: { position: [4.9041, 52.3676] }
    };

    // Fuzzy search with custom fuzziness
    const customParams: FuzzySearchParams = {
    query: 'restaurnt', // Misspelled "restaurant"
    minFuzzyLevel: 1,
    maxFuzzyLevel: 3,
    limit: 10
    };