Sorry, you need to enable JavaScript to visit this website.

Search examples

Have a look at our functional examples to see how easy it is to implement search features with the TomTomOnlineSDKSearch.
Speed up development by using our sample code snippets in your app. Try all of this out with the Maps SDK Examples app!

Allow your users to easily search for addresses and POIs in a single step.
Implement global search or near-me search in your mobile app so that it returns the best search results for your needs.
Global search uses the search functionality’s default settings . It doesn’t use the user’s position or other search parameters.
Sample use case: You use an app to search for a place. This search should not be limited in any way.

Use the code snippet below in your app to list general search results or display them on the map.

_

let query = TTSearchQueryBuilder.create(withTerm: term)
    .build()
search.search(with: query)
TTSearchQuery *query = [[TTSearchQueryBuilder createWithTerm:term] build];
[self.search searchWithQuery:query];

 

Add the code snippet presented below to your app to get search results that are geo-biased for a
given location in a range specified by a radius.

_

let query = TTSearchQueryBuilder.create(withTerm: term)
    .withPosition(coordinate)
    .build()
search.search(with: query)
TTSearchQuery *query = [[[TTSearchQueryBuilder createWithTerm:term]
    withPosition:coordinate] build];
[self.search searchWithQuery:query];

 



image

Global address search.

image

Near me address search.

Help your users search for specific types of places with category search.
Sample use case: You are preparing for a long drive and would like to find gas stations nearby.

Use the code snippet below to try this in your app.

_

let query = TTSearchQueryBuilder.create(withTerm: "parking")
    .withCategory(true)
    .withPosition(locationManager.lastLocation!.coordinate)
    .build()
search.search(with: query)
TTSearchQuery *query =
    [[[[TTSearchQueryBuilder createWithTerm:@"parking"] withCategory:YES]
        withPosition:self.locationManager.lastLocation.coordinate] build];
[self.search searchWithQuery:query];

 
For category search we use Online search - LowBandwidthSearch as in “Address and POI search”.
The difference is in endpoint:



Category search

GET https://<baseURL>/search/<versionNumber>/cS/<category>...

For complete description go to:

Below we present a exemplary application view utilizing Category Search.



image

Address search with category: Parking

image

Address search with category: Gas

Language parameter

Develop an international app that can be used in different languages. Enhance the search functionality with the language parameter so that the search returns results in a specific language.
Sample use case: If your mobile device is set to a particular language, you see it in your app as well.

List of the supported languages can be found
here.

Use the code snippet presented below to try this in your app.

_

let query = TTSearchQueryBuilder.create(withTerm: term)
    .withLang(language)
    .build()
search.search(with: query)
TTSearchQuery *query =
    [[[TTSearchQueryBuilder createWithTerm:term] withLang:language] build];
[self.search searchWithQuery:query];

 

Typeahead parameter

Offer your users search suggestions while they type with the “typeahead” flag.
Sample use case: You were recommended a place to visit, but you can’t remember its name.
You start searching in your app. After a few letters you see the place you’re looking for!

Use the code snippet below to try this in your app.

_

let query = TTSearchQueryBuilder.create(withTerm: term)
    .withTypeAhead(true)
    .build()
search.search(with: query)
TTSearchQuery *query =
    [[[TTSearchQueryBuilder createWithTerm:term] withTypeAhead:YES] build];
[self.search searchWithQuery:query];

 

To cancel a pending search request in the object, call:

_

func cancelSearch() {
    self.search.cancel()
}
- (void)cancelSearch {
  [self.search cancel];
}

 

Fuzziness parameter

Help your users even more with fuzzy search. Use the right fuzziness levels in your app to make it less sensitive to typos.
Sample use case: You occasionally make mistakes when typing. Your app still returns the desired search results.

Use the code snippet below to try this in your app.

  • Level 1 no spell checking

  • Level 2 is using normal n-gram spell checking. For example query "restrant" can be matched to
    "restaurant".

  • Level 3 is using sound-like spell checking, and shingle spell checking. Sound-like spell checking
    is for "rstrnt" to "restaurant" matching. Shingle spell checking is for "mountainview" to
    "mountain view" matching.

  • Level 4 doesn’t add any more spell checking function.

The search engine will start looking for a match on the level defined by minFuzzyLevel and will
stop searching at the level specified by maxFuzzyLevel.

_

let query = TTSearchQueryBuilder.create(withTerm: term)
    .withMinFuzzyLevel(1)
    .withMaxFuzzyLevel(maxFuzzyLevel)
    .withPosition(locationManager.lastLocation!.coordinate)
    .build()
search.search(with: query)
TTSearchQuery *query = [[[[[TTSearchQueryBuilder createWithTerm:term]
    withMinFuzzyLevel:1] withMaxFuzzyLevel:maxFuzzyLevel]
    withPosition:self.locationManager.lastLocation.coordinate] build];
[self.search searchWithQuery:query];

 

Reverse geocoding

Sometimes you need to translate a coordinate into a human-readable street address.
This is often used in tracking applications that receive a GPS feed from a device or asset and need to obtain the corresponding address.
The reverse geocoding endpoint returns the address information described in the Reverse Geocoding API documentation on the Developer Portal.
Sample use case: You want to know the address of a place on the map. You press your finger on the map display,
and address information appears in a balloon on the screen.

Use the code below to try this in your app:

_

let query = TTReverseGeocoderQueryBuilder.create(with: coordinate)
    .build()
reverseGeocoder.reverseGeocoder(with: query)
TTReverseGeocoderQuery *query = [[TTReverseGeocoderQueryBuilder
    createWithCLLocationCoordinate2D:coordinate] build];
[self.reverseGeocoder reverseGeocoderWithQuery:query];

 

Polygons for reverse geocoding

Combine Additional Data Provider queries with Reverse Geocoding queries to obtain extra data about specific
entity Type like:

  • Country

  • CountrySubdivision

  • CountrySecondarySubdivision

  • CountryTertiarySubdivision

  • Municipality

  • MunicipalitySubdivision

  • Neighbourhood

  • PostalCodeArea

Sample use case: You want to display Country or Municipality boundaries.

Use the code below to try this in your app:

Create TTReverseGeocoderQuery with the entityType parameter and use reverse geocoder search.

_

let query = TTReverseGeocoderQueryBuilder.create(with: coordinate).withEntityType(entityType)
    .build()
reverseGeocoder.reverseGeocoder(with: query)
TTReverseGeocoderQuery *query = [[[TTReverseGeocoderQueryBuilder
    createWithCLLocationCoordinate2D:coordinate]
    withEntityType:self.entityType] build];
[self.reverseGeocoder reverseGeocoderWithQuery:query];

 

Get TTGeometryDataSource object from response.

_

guard let address = response.result.addresses.first else { return }
guard let additionalDataSources = address.additionalDataSources else { return }
guard let geometryDataSource = additionalDataSources.geometryDataSource else { return }
- (TTGeometryDataSource *_Nullable)geometryDataSourceFromResponse:
    (TTReverseGeocoderResponse *)response {
  if (response.result.addresses.firstObject != nil) {
    TTReverseGeocoderFullAddress *addressValue =
        [TTReverseGeocoderFullAddress alloc];
    addressValue = response.result.addresses.firstObject;
    if (addressValue.additionalDataSources) {
      TTAdditionalDataSources *additionalDataSources =
          [TTAdditionalDataSources alloc];
      additionalDataSources = addressValue.additionalDataSources;
      if (additionalDataSources.geometryDataSource) {
        return additionalDataSources.geometryDataSource;
      }
    }
  }
  return nil;
}

 

Use the TTAdditionalDataSearchQuery object for sending requests with the TTGeometryDataSource object supported by Additional Data API.

_

let query = TTAdditionalDataSearchQueryBuilder.create(with: geometryDataSource).build()
searchAdditionalData.additionalDataSearch(with: query)
if ([self geometryDataSourceFromResponse:response] != nil) {
  TTAdditionalDataSearchQuery *query = [[TTAdditionalDataSearchQueryBuilder
      createWithDataSource:[self geometryDataSourceFromResponse:response]]
      build];
  [_searchAdditionalData additionalDataSearchWithQuery:query];
}

 

Sample views utilizing entities retrieved by combining both services:



image

Boundaries for selected country

image

Boundaries for selected municipality

=== Search along the route

Allow your users to search for POI along a planned route so they can add places to their rides optimally.
The Along Route Search endpoint allows you to perform a fuzzy search for POIs along a specified route. This search is constrained by specifying the detour time and limiting the number of results. The minimum number of route points is 2.

Sample use case 1: You are driving from Amsterdam to Haarlem and you would like to find a gas station or EV station to fuel or charge your car during your drive.
Sample use case 2: Planning your next trip you would like add a car repair station so you can fix something in your vehicle to drive safely.

Use the code below to display 10 POIs along a route with maximum detour time of 900 sec:

_

let query = TTAlongRouteSearchQueryBuilder(term: "REPAIR_FACILITY", withRoute: mapRoute, withMaxDetourTime: 900)
    .withLimit(10)
    .build()
alongRouteSearch.search(with: query)
  TTAlongRouteSearchQuery *query =
      [[[TTAlongRouteSearchQueryBuilder withTerm:@"REPAIR_FACILITY"
                                       withRoute:self.mapRoute
                               withMaxDetourTime:900] withLimit:10] build];
  [self.alongRouteSearch searchWithQuery:query];
--
{nbsp}


image

With term "REPAIR_FACILITY"
 

image

With term "PETROL_STATION"
 

image

With term "ELECTRIC_VEHICLE_STATION"
 

Allow your users to perform a free text search inside geometries specified by circlers and/or polygons.

Sample use case: You are planing to visit the area of Amsterdam.  You need find a parking, an ATM and a grocery store in the city centre in Amsterdam and/or in the west part of the city.

Use the code snippet below to code this in your app:

_

let query = TTGeometrySearchQueryBuilder.create(withTerm: "Parking", searchShapes: geometryShape)
    .withLimit(30)
    .build()
geometrySearch.search(with: query)
TTGeometrySearchQuery *query = [[[TTGeometrySearchQueryBuilder
    createWithTerm:@"Parking"
      searchShapes:self.geometryShape] withLimit:30] build];
[self.geometrySearch searchWithQuery:query];

 

Below we present an exemplary application that shows Geometry Search.



image

Geometry search with term: Parking

image

Geometry search with term: ATM

Entry points

Allow your users to display entry points using fuzzy search results.

Sample use case: A taxi driver wants to pick up a passenger from the specific entry point at the airport.

Use the code below to try this in your app:

_

for entryPoint in entryPoints {
    let annotation = CustomAnnotation(coordinate: entryPoint.position,
                                      annotationImage: TTAnnotationImage.createPNG(withName: "entry_point")!,
                                      anchor: TTAnnotationAnchor.bottom,
                                      type: TTAnnotationType.focal)
    annotation.title = "Entry point type: \(entryPoint.type!)"
    mapView.annotationManager.add(annotation)
}
mapView.zoomToAllAnnotations()
for (TTEntryPoint *entryPoint in entryPoints) {
  CustomAnnotation *annotation = [[CustomAnnotation alloc]
      initWithCoordinate:entryPoint.position
         annotationImage:[TTAnnotationImage createPNGWithName:@"entry_point"]
                  anchor:TTAnnotationAnchorBottom
                    type:TTAnnotationTypeFocal];
  annotation.title =
      [NSString stringWithFormat:@"Entry point type %@", entryPoint.type];
  [self.mapView.annotationManager addAnnotation:annotation];
}
[self.mapView zoomToAllAnnotations];

 

Sample views utilizing entry points:



image

Entry points for the Amsterdam airport

image

Entry points for the Kalvertoren mall

Additional data

Allow your users to request for a set of extra entities, like city or country outline, previously
retrieved from the Search API service. For more information, refer to the Additional Data service
documentation.

Sample use case: You want to apply colors to geographic-boundary areas such as countries, cities or districts.

Use the code below to try this in your app:

_

func search(_: TTSearch, completedWith response: TTSearchResponse) {
    guard let result = response.results.first else {
        return
    }
    guard let additionalData = result.additionalDataSources else {
        return
    }
    guard let geometryData = additionalData.geometryDataSource else {
        return
    }
    let query = TTAdditionalDataSearchQueryBuilder.create(with: geometryData).build()
    searchAdditionalData.additionalDataSearch(with: query)
}
func additionalDataSearch(_: TTAdditionalDataSearch, completedWith response: TTAdditionalDataSearchResponse) {
    progress.hide()
    guard let result = response.results.first else {
        return
    }
    let visitor = PolygonAdditionalDataVisitior()
    result.visitGeoJSONResult(visitor)
    var mapPolygons: [TTPolygon] = []
    for lineString in visitor.lineStrings {
        let mapPolygon = TTPolygon(coordinatesData: lineString, opacity: 0.7, color: TTColor.Red(), colorOutline: TTColor.Red())
        mapPolygons.append(mapPolygon)
        mapView.annotationManager.add(mapPolygon)
    }
    mapView.zoom(toCoordinatesDataCollection: mapPolygons)
}
- (void)search:(TTSearch *)search
    completedWithResponse:(TTSearchResponse *)response {
  TTSearchResult *result = response.results.firstObject;
  if (!result) {
    return;
  }
  TTAdditionalDataSources *additionalData = result.additionalDataSources;
  if (!additionalData) {
    return;
  }
  TTGeometryDataSource *geometryData = additionalData.geometryDataSource;
  if (!geometryData) {
    return;
  }
  TTAdditionalDataSearchQuery *query = [[TTAdditionalDataSearchQueryBuilder
      createWithDataSource:geometryData] build];
  [self.searchAdditionalData additionalDataSearchWithQuery:query];
}
- (void)additionalDataSearch:(TTAdditionalDataSearch *)additionalDataSearch
       completedWithResponse:(TTAdditionalDataSearchResponse *)response {
  [self.progress hide];
  TTAdditionalDataSearchResult *result = response.results.firstObject;
  if (!result) {
    return;
  }
  PolygonAdditionalDataVisitior *visitor = [PolygonAdditionalDataVisitior new];
  [result visitGeoJSONResult:visitor];
  NSMutableArray<TTPolygon *> *mapPolygons = [NSMutableArray new];
  for (TTGeoJSONLineString *lineString in visitor.lineStrings) {
    TTPolygon *mapPolygon =
        [TTPolygon polygonWithCoordinatesData:lineString
                                      opacity:0.7
                                        color:[TTColor Red]
                                 colorOutline:[TTColor Red]];
    [mapPolygons addObject:mapPolygon];
    [self.mapView.annotationManager addOverlay:mapPolygon];
  }
  [self.mapView zoomToCoordinatesDataCollection:mapPolygons];
}

 

Sample views utilizing entities retrieved from the Additional Data service:



image

Boundaries for Amsterdam

image

Boundaries for Poland

Allow your users to process synchronous batch search calls with the Batch Search
service integrated. When the service receives a request, it will respond as soon as the batch items
are calculated and there will be no possibility to retrieve the results later on.

Supported types of requests

  1. Geometry Search

  2. Fuzzy Search

  3. Reverse Geocoder

Different types of requests can be mixed in one batch request. The information about the limit of
queries, request processing time and other details are described in Batch Search
service documentation. An error in one of the batch requests causes the whole batch to fail.

Sample use case: You want to simultaneously search for different categories within different locations.

Use the code below to try this in your app:

_

let query1 = TTSearchQueryBuilder.create(withTerm: term)
    .withCategory(true)
    .withPosition(TTCoordinate.AMSTERDAM_CENTER_LOCATION())
    .withLimit(10)
    .build()
let query2 = TTSearchQueryBuilder.create(withTerm: term)
    .withCategory(true)
    .withPosition(TTCoordinate.HAARLEM())
    .withLimit(15)
    .build()
let geometry = TTSearchCircle(center: TTCoordinate.HOOFDDORP(), radius: 4000)
let geometryQuery = TTGeometrySearchQueryBuilder.create(withTerm: term, searchShapes: [geometry])
    .build()
let batchQuery = TTBatchQueryBuilder.createSearchQuery(query1)
    .add(query2)
    .addGeometryQuery(geometryQuery)
    .build()
batchSearch.batchSearch(with: batchQuery)
TTSearchQuery *query1 =
    [[[[[TTSearchQueryBuilder createWithTerm:term] withCategory:YES]
        withPosition:[TTCoordinate AMSTERDAM_CENTER_LOCATION]] withLimit:10]
        build];
TTSearchQuery *query2 =
    [[[[[TTSearchQueryBuilder createWithTerm:term] withCategory:YES]
        withPosition:[TTCoordinate HAARLEM]] withLimit:15] build];
TTSearchCircle *geometry =
    [TTSearchCircle circleWithCenter:[TTCoordinate HOOFDDORP] radius:4000];
TTGeometrySearchQuery *geometryQuery =
    [[TTGeometrySearchQueryBuilder createWithTerm:term
                                     searchShapes:@[ geometry ]] build];
TTBatchQuery *batchQuery = [[[[TTBatchQueryBuilder createSearchQuery:query1]
    addSearchQuery:query2] addGeometryQuery:geometryQuery] build];
[self.batchSearch batchSearchWithQuery:batchQuery];

 

Sample views utilizing data retrieved using Batch Search service:


image

Search results for different locations

You are here