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

    Function discoverPlaces

    • Universal search function for finding places by text query, within geometries or along a route.

      Runs one of three searches, picked from its params:

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

      Returns Promise<DiscoverPlacesResponse>

      Promise resolving to a collection of matching places

      The search service provides:

      • POI (Points of Interest) search
      • Address search
      • Geographic area search
      • Category-based filtering
      • 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 }
      });