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

    Function discoverPlaces

    • Finds places by text query, within geometries or along a route, from one universal function.

      It runs one of three searches, picked from its params:

      • Along-route search when route is given, for places within a detour budget of the route.
      • Geometry search when geometries is given, for places inside those areas.
      • Fuzzy search otherwise, for free text, optionally biased by geoBias.

      Returns Promise<DiscoverPlacesResponse>

      The matching places.

      The search service provides POI (Points of Interest) search, address search, geographic area search, category-based filtering and position-based relevance ranking. Results are ranked by relevance with scores and optional distances.

      // Free-text search near a location
      const results = await discoverPlaces({
      query: 'pizza restaurant',
      geoBias: { position: [4.9041, 52.3676] }, // Amsterdam
      limit: 10
      });

      // Search within a specific area
      const areaResults = await discoverPlaces({
      query: 'coffee shop',
      geometries: [polygon], // Search within this polygon
      limit: 20
      });

      // Category search
      const restaurants = await discoverPlaces({
      filters: { poiCategories: ['ITALIAN_RESTAURANT'] },
      geoBias: { position: [4.9041, 52.3676], radiusMeters: 5000 } // Within 5km
      });

      // The same, from a category in words
      const italian = await discoverPlaces({
      filters: { poiCategoryQuery: 'italian food' },
      geoBias: { position: [4.9041, 52.3676], radiusMeters: 5000 }
      });