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.

- (void)performAddressSearchWithQuery:(NSString *)query {
    TTSearchQueryBuilder *queryBuilder = [TTSearchQueryBuilder
                                            createWithTerm:query];
    TTSearchQuery *searchQuery = [queryBuilder build];
    [self.search searchWithQuery:searchQuery withAsyncDelegate:self];
}

 

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.

- (void)performAddressSearchWithQuery:(NSString *)query
                             position:(CLLocationCoordinate2D)position {
    TTSearchQueryBuilder *queryBuilder = [TTSearchQueryBuilder
                                            createWithTerm:query];
    [queryBuilder withPosition:(CLLocationCoordinate2D)position withRadius:30000];
    TTSearchQuery *searchQuery = [queryBuilder build];
    [self.search searchWithQuery:searchQuery withAsyncDelegate:self];
}

 



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.

- (void)performCategorySearchWithQuery:(NSString *)query {
    TTSearchQueryBuilder *queryBuilder = [TTSearchQueryBuilder
                                            createWithTerm:query];
    [queryBuilder withCategory:YES];

    [queryBuilder withPosition:self.locationManager.location.coordinate];
    TTSearchQuery *searchQuery = [queryBuilder build];
    [self.search searchWithQuery:searchQuery withAsyncDelegate:self];
}

 

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.

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

- (void)performAddressSearchWithQuery:(NSString *)query
                             language:(TTLanguage)language {
    TTSearchQueryBuilder *queryBuilder = [TTSearchQueryBuilder
                                            createWithTerm:query];
    [queryBuilder withLanguage:language];
    TTSearchQuery *searchQuery = [queryBuilder build];
    [self.search searchWithQuery:searchQuery withAsyncDelegate:self];
}

 

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.

- (void)performAutocompleteSearchWithQuery:(NSString *)query {
    TTSearchQueryBuilder *queryBuilder = [[TTSearchQueryBuilder
                                             createWithTerm:query]
                                            withTypeAhead:true];
    TTSearchQuery *searchQuery = [queryBuilder build];
    [self.search searchWithQuery:searchQuery withAsyncDelegate:self];
}

 

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

- (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.

TTSearchQueryBuilder *queryBuilder = [[[[TTSearchQueryBuilder
                                        createWithTerm:query]
                                         withMaxFuzzyLevel:@(max)]
                                         withPosition:position]
                                        withMinFuzzyLevel:@(min)];
TTSearchQuery *searchQuery = [queryBuilder build];
[self.search searchWithQuery:searchQuery withAsyncDelegate:self];

 

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:

TTReverseGeocoderQuery *query =
[[[[[TTReverseGeocoderQueryBuilder createWithCLLocationCoordinate2D:coordinate]
    withReturnRoadUse:true]
   withReturnMatchType:true]
  withReturnSpeedLimit:true] build];

[self.mapView.annotationManager removeAllAnnotations];
self.result = NSLocalizedString(@"Loading ...", "");
TTAnnotation *annotation = [TTAnnotation annotationWithCoordinate:coordinate];
[self.mapView.annotationManager addAnnotation:annotation];

[self.reverseGeocoder reverseGeocoderWithQuery:query completionHandler:^(TTReverseGeocoderResult *result, TTResponseError *error) {

    TTReverseGeocoderFullAddress *fullAddress = [[result addresses] firstObject];
    if (fullAddress) {
        self.result = [self addressString: fullAddress.address];
        [self.mapView.annotationManager selectAnnotation:annotation];
    }
}];

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:

TTAlongRouteSearchQuery *alongRouteSearchQuery = [[[[TTAlongRouteSearchQueryBuilder alloc] initWithTerm:term withRoute:self.resoultRoute.routes.firstObject withMaxDetourTime:900] withLimit:10] build];

[self.alongRouteSearch searchWithQuery:alongRouteSearchQuery withAsyncDelegate:self];


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:

TTGeometrySearch *search = [[TTGeometrySearch alloc] init];
TTGeometrySearchQuery *query = [[[TTGeometrySearchQueryBuilder createWithTerm:term searchShapes:self.shapes] withLimit:30] build];
[search searchWithQuery:query completionHandler:^(TTGeometrySearchResponse *response, TTResponseError *error) {
    if(!error) {
        [self displayResponse:response];
    }
}];

 

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 (TTEntryPoint *entryPoint in searchResult.entryPoints) {
    CLLocationCoordinate2D coordinate = entryPoint.position;
    UIImage *image = [UIImage imageNamed:@"entry_point"];
    NSString *tag = [NSString stringWithFormat:@"Entry point type: %@", entryPoint.type];
    TTAnnotation *annotation = [TTAnnotation annotationWithCoordinate:coordinate
                                                                image:image
                                                                  tag:tag
                                                               anchor:TTAnnotationAnchorBottom
                                                                 type:TTAnnotationTypeFocal];
    [self.mapView.annotationManager addAnnotation:annotation];
    [annotations addObject:annotation];
}
[self.mapView zoomToAnnotations:annotations];

 

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 Online Search 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:

TTAdditionalDataSources *ads = [[searchResult firstObject] additionalDataSources];
TTGeometryDataSource *gds = [ads geometryDataSource];
TTAdditionalDataSearchQuery *query = [[TTAdditionalDataSearchQueryBuilder createWithDataSource:gds] build];
[[TTAdditionalDataSearch new] additionalDataSearchWithQuery:query completionHandler:^(TTAdditionalDataSearchResponse * _Nullable result, TTResponseError * _Nullable error) {
    PolygonAdditionalDataVisitior *visitior = [PolygonAdditionalDataVisitior new];
    [[[result results] firstObject] visitResult:visitior];
    [self drawingPolygonAdditionalDataVisitior:visitior];
}];

 

Sample views utilizing entities retrieved from the Additional Data service:



image

Boundaries for Amsterdam

image

Boundaries for Poland