Search (autocomplete/fuzzy/geometry search)

The TomTom Maps SDK provides three powerful search services that help you find places, addresses, and points of interest with different search strategies optimized for various use cases. Each search type is designed to handle specific user interaction patterns and application requirements.

Available Search Types

Comprehensive search that handles typos, variations in queries, and natural language input. Fuzzy search is robust and forgiving, making it ideal for situations where users might not know exact spellings or when dealing with international locations.

import { search } from '@tomtom-org/maps-sdk/services';
const results = await search({
query: 'coffe shop near dam square', // Handles typos and variations
position: [4.9041, 52.3676]
});

Advanced Capabilities:

  • Tolerates spelling mistakes and variations in input
  • Supports natural language queries for intuitive user interaction
  • Category and POI search with intelligent matching
  • Flexible radius-based or bounding box search options

Ideal Applications:

  • General search functionality where user input quality varies
  • International applications with diverse language inputs
  • Voice-to-text search implementations

Find places within specific geographic boundaries or custom areas. Geometry search enables location discovery within precisely defined regions, making it perfect for area-specific applications and location-based services.

import { search } from '@tomtom-org/maps-sdk/services';
// Search within a circle
const results = await search({
query: 'restaurants',
geometries: [{
type: 'Circle',
coordinates: [4.9041, 52.3676], // [longitude, latitude]
radius: 5000 // meters
}]
});
// Search within a GeoJSON polygon
const results = await search({
query: 'museums',
geometries: [{
type: 'Polygon',
coordinates: [[[4.7, 52.2], [5.1, 52.2], [5.1, 52.5], [4.7, 52.5], [4.7, 52.2]]]
}]
});

The search() function automatically dispatches to geometry search when geometries is provided, and to fuzzy search otherwise.

Geometric Search Options:

  • Circle: Custom radius around a point (type: 'Circle', coordinates, radius)
  • Polygon: GeoJSON polygon for custom area boundaries
  • MultiPolygon: Multiple non-contiguous areas in a single query

Perfect For:

  • Location discovery within specific neighborhoods or districts
  • Delivery and service area applications
  • Tourism and local business discovery

Perfect for search-as-you-type experiences with instant suggestions, autocomplete search provides real-time results as users type their queries. This service is optimized for speed and relevance, making it ideal for interactive search interfaces.

import { autocompleteSearch } from '@tomtom-org/maps-sdk/services';
const suggestions = await autocompleteSearch({
query: 'coffee',
position: [4.9041, 52.3676], // Amsterdam
resultType: ['category', 'brand', 'plaintext']
});

Key Features:

  • Real-time suggestions as users type with minimal latency
  • Brand and category suggestions for enhanced user experience
  • Optimized for speed with lightweight responses
  • Perfect for search bars and interactive input fields

Parameter Reference

Common Parameters

These parameters apply to both fuzzy search and geometry search:

ParameterTypeDescription
querystring (optional)Search query text. Omit when searching purely by poiCategories, poiBrands, fuelTypes, or geometry.
position[longitude, latitude]Bias results toward this location. Required for radiusMeters.
limitnumberMaximum results to return (1–100, default: 10).
countriesstring[]Restrict results to specific countries using ISO 3166-1 alpha-2 or alpha-3 codes (e.g. ['NL', 'DE']).
poiCategoriesPOICategory[]Filter results by POI category. Use the getPOICategories service to discover available values. See POI Categories .
poiBrandsstring[]Filter by brand name (case-sensitive). Example: ['Starbucks', 'Costa Coffee'].
indexesSearchIndexType[]Which indexes to search. Options: 'Geo', 'PAD', 'Addr', 'Str', 'XStr', 'POI'. Defaults to all.
openingHoursOpeningHoursModeInclude opening hours in results (e.g. 'nextSevenDays').
timeZoneTimeZoneRequestInclude timezone info. Use 'iana' to receive IANA timezone IDs (e.g. 'Europe/Amsterdam').
relatedPoisRelatedPoisRequestInclude related POIs in results. Options: 'off' (default), 'child', 'parent', 'all'.
connectorsConnectorType[]Filter EV charging stations by connector type (e.g. ['IEC62196Type2CCS', 'Chademo']).
fuelTypesFuel[]Filter fuel stations by fuel type (e.g. ['Petrol', 'Diesel', 'E85']).
minPowerKWnumberMinimum EV charging power in kilowatts.
maxPowerKWnumberMaximum EV charging power in kilowatts.
viewViewGeopolitical view for disputed territories. Options: 'Unified', 'AR', 'IN', 'PK', 'IL', 'MA', 'RU', 'TR', 'CN'.
mapcodesMapcodeType[]Request mapcode formats in results: 'Local', 'International', 'Alternative'.
extendedPostalCodesForSearchIndexType[]Include extended postal codes for specific indexes (default: all except 'Geo').
geographyTypesGeographyType[]Filter results to specific geography types (e.g. ['Municipality', 'Neighbourhood']).

Fuzzy Search Parameters

In addition to all common parameters, fuzzy search supports:

ParameterTypeDescription
radiusMetersnumberConstrain results to this radius around position (in meters). Requires position.
boundingBox[minLng, minLat, maxLng, maxLat]Restrict results to a rectangular geographic area.
typeaheadbooleanEnable predictive/autocomplete mode for partial queries (default: false).
offsetnumberPagination offset, zero-based (default: 0).
minFuzzyLevelnumberMinimum fuzziness level (1–4, default: 1). Lower values require closer matches.
maxFuzzyLevelnumberMaximum fuzziness level (1–4, default: 2). Higher values tolerate more typos.

Geometry Search Parameters

In addition to all common parameters, geometry search requires:

ParameterTypeDescription
geometriesSearchGeometryInput[]Required. One or more geometries to search within. Supports Circle, Polygon, and MultiPolygon.

Autocomplete Search Parameters

ParameterTypeDescription
querystringPartial user input to autocomplete.
position[longitude, latitude]Bias suggestions toward this location.
limitnumberMaximum suggestions to return (1–100, default: 10).
radiusMetersnumberConstrain suggestions to this radius around position.
countriesstring[]Restrict to specific countries.
resultTypeAutocompleteSearchSegmentType[]Filter suggestion types: 'brand', 'category', 'plaintext'.

POI Categories

Use poiCategories to filter results to specific types of places. Each value must be a POICategory enum constant. Use the getPOICategories service to search and browse available categories by name or synonym, then pass the resulting code values directly here.

import { search, getPOICategoryCodes } from '@tomtom-org/maps-sdk/services';
// Filter to a known category
const italian = await search({
position: [4.9041, 52.3676],
radiusMeters: 1000,
poiCategories: ['ITALIAN_RESTAURANT']
});
// Discover categories first, then search
const restaurantCodes = await getPOICategoryCodes({ filters: ['restaurant'] });
const restaurants = await search({
position: [4.9041, 52.3676],
radiusMeters: 1000,
poiCategories: restaurantCodes
});
// EV charging with connector and power filtering
const evChargers = await search({
position: [4.9041, 52.3676],
radiusMeters: 5000,
poiCategories: ['ELECTRIC_VEHICLE_STATION'],
connectors: ['IEC62196Type2CCS', 'Tesla'],
minPowerKW: 50
});

Example category values: ITALIAN_RESTAURANT, GAS_STATION, HOTEL, PHARMACY, MUSEUM, PARKING_GARAGE, ELECTRIC_VEHICLE_STATION, SHOPPING_CENTER. See the POICategory type for the full list, or use the getPOICategories service to search and explore them at runtime.

Working with Search Results

Search results follow a GeoJSON FeatureCollection structure. Each feature is a GeoJSON Feature<Point> with place data in properties:

const results = await search({
query: 'coffee',
position: [4.9041, 52.3676]
});
results.features.forEach(place => {
console.log(place.properties.poi?.name); // Business name (POI results)
console.log(place.properties.address.freeformAddress);// Formatted address
console.log(place.geometry.coordinates); // [longitude, latitude]
console.log(place.properties.poi?.categories); // POICategory[] (e.g. ['CAFE'])
console.log(place.properties.poi?.localizedCategories); // string[] (e.g. ['café'])
console.log(place.properties.score); // Relevance score
console.log(place.properties.distance); // Distance in meters (if position was given)
});

To retrieve only the first result, use searchOne():

import { searchOne } from '@tomtom-org/maps-sdk/services';
const place = await searchOne({ query: 'Eiffel Tower', position: [2.3522, 48.8566] });
if (place) {
console.log(place.properties.poi?.name); // 'Eiffel Tower'
}

Examples

Find Bus Stops in an Area (Node.js)

Use boundingBox to search for all bus stops within a rectangular geographic area. This example searches the Amsterdam city area:

import { search } from '@tomtom-org/maps-sdk/services';
const results = await search({
poiCategories: ['BUS_STOP'],
boundingBox: [4.72, 52.27, 5.07, 52.43], // [minLng, minLat, maxLng, maxLat]
limit: 100
});
results.features.forEach(stop => {
const [lng, lat] = stop.geometry.coordinates;
console.log(`${stop.properties.poi?.name} — ${lng}, ${lat}`);
});

Integration with Map Visualization

Search results can be directly integrated with the TomTom Maps SDK for immediate visual representation:

import { TomTomMap, PlacesModule } from '@tomtom-org/maps-sdk/map';
const map = new TomTomMap({ mapLibre: { container: 'map' } });
const placesModule = await PlacesModule.get(map);
const results = await search({
query: 'museums',
position: [4.9041, 52.3676]
});
// Display search results as markers on the map
await placesModule.show(results);

Performance Optimization

For optimal performance in production applications, consider these best practices:

Search Strategy Selection:

  • Use autocomplete for real-time search interfaces
  • Use fuzzy search for comprehensive location finding
  • Use geometry search for area-specific discovery

Result Limiting:

  • Set appropriate limit values based on UI requirements
  • Use offset for pagination of large result sets
  • Cache frequent search results for faster response times

For complete search implementation examples and advanced usage patterns, go to http://docs.tomtom.com/maps-sdk-js/examples .

Map Integration

  • Places Module - Display search results as interactive places on the map with customizable styling and user interactions
  • POIs - Advanced point-of-interest visualization and filtering for search results
  • Geocoding - Convert search result addresses to precise coordinates for enhanced accuracy
  • Reverse Geocoding - Get address information for search result coordinates