Maps SDK for Web

tt.services.alongRouteSearch

Makes a search request using the TomTom Search API - Along Route Search.

The Search Along Route endpoint allows you to perform a fuzzy search for POIs along a specified route. This search is constrained by specifying the Detour Time limiting measure.

To send the route points, this service will use a POST request with the route encoded as a JSON payload. The minimum number of route points is 2.

Parameters need to be passed to the constructor. The method go performs the actual call.

Constructor

tt.services.alongRouteSearch([options])

Example
tt.services.alongRouteSearch({
    key: <Your API key>,
    limit: 20,
    maxDetourTime: 120,
    query: 'gas station',
    route: [
        {
            'lat': 37.7524152343544,
            'lon':-122.43576049804686
        },
        {
            'lat': 37.70660472542312,
            'lon':-122.43301391601562
        },
        [-122.36434936523438, 37.712059855877314], // Another valid format
    ]
  })
  .go()
  .then(function(response) {
    console.log('SUMMARY:');
    console.table(response.summary);
    console.log('RESULTS:');
    console.table(response.results);
  });

For a list of all available formats for routes, read the documentation for the route option.

Parameters
Name Description
options
Object
default:None
options.brandSet
String
default:None

A list of brands divided by commas.


This option specifies brands to use for the search.
Example
// search for TomTom and Foobar facilities
tt.fuzzySearch({
  query: 'office',
  brandSet: 'TomTom,Foobar'
})
.go()
.then(handleResults);
// search for TomTom offices
tt.fuzzySearch({
  query: 'office',
  brandSet: 'TomTom'
})
.go()
.then(handleResults);
options.categorySet
String
default:None

A list of categories codes divided by commas.


This option specifies categories codes to use for the search. For more info about category codes, please refer to POI Categories documentation .
Example
// search places of category Restaurant
tt.fuzzySearch({
  query: 'food',
  categorySet: '7315'
})
.go()
.then(handleResults);
// search places of category either Italian or French Restaurant
tt.fuzzySearch({
  query: 'food',
  categorySet: '7315025,7315017'
})
.go()
.then(handleResults);
options.connectorSet
String
default:None

A list of Electrical Vehicle connector types divided by commas.


This option specifies connector types, which could be used to restrict the result to Points Of Interest of type Electric Vehicle Station supporting specific connector types. For more info about EV connector names, please refer to Supported Connector Types documentation page.
Example
// search for Electric Vehicle Station supporting IEC62196Type1
tt.fuzzySearch({
  query: 'station',
  connectorSet: 'IEC62196Type1'
})
.go()
.then(handleResults);
// search for Electric Vehicle Station supporting IEC62196Type1 or GBT20234Part2
tt.fuzzySearch({
  query: 'station',
  connectorSet: 'IEC62196Type1,GBT20234Part2'
})
.go()
.then(handleResults);
options.key
String
default:None

A valid API Key for the requested service.


A valid API Key is required to make use of the given service. It can be issued in the Developer Portal.
options.limit
Number
default:10

The maximum number of elements in the response. The maximum number is 20.


options.maxDetourTime
Number
default:None

New maximum detour time in seconds.


The maximum allowed value is 3600.
options.openingHours
String
default:None

The only available option is 'nextSevenDays'.


This option shows the opening hours for the next week, starting with the current day in the local time of the POI.
Example
// search for cinemas inculding their opening hours.
tt.fuzzySearch({
  query: 'cinema',
  openingHours: 'nextSevenDays'
})
.go()
.then(handleResults);
options.query
String
default:None

The query string. This value will be properly encoded during the creation of the request.


This option represents the text that will be searched.
options.route
Array
default:None

Route representation.


The following formats are supported:
  • String[] (longitude/latitude pairs)
    • ["4.8,52.3", "4.8,52.3"]
  • Array[] (longitude/latitude pairs)
    • [ [4.8,52.3], [4.8,52.3] ]
  • Object[]
    • {lon: 4.8, lat: 52.3}
    • {lng: 5.8, lat: 53.3}
    • {x: 53.3, y: 5.8}
    • {longitude: 5.8, latitude: 53.3}
    • {lng: Function, lat: Function} The functions should return a numeric value.
Example
function callbackFn(response) {
  console.log(response);
}

tomtom.alongRouteSearch({
  route:[
    {
        lat: 37.7524152343544,
        lon:-122.43576049804686
    },
    {
        lat: 37.70660472542312,
        lon:-122.43301391601562
    }
  ]
})
.go()
.then(callbackFn);
options.spreadingMode
String
default:None

Enables the spreading of returned results evenly along the route.


Methods

go( ): Promise

Executes a predefined asynchronous task using the current configuration.

Returns