THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Additional data

Allow your users to request a set of extra entities, like a 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 following code to try this in your app:

1func search(_: TTSearch, completedWith response: TTSearchResponse) {
2 guard let result = response.results.first else {
3 return
4 }
5 guard let additionalData = result.additionalDataSources else {
6 return
7 }
8 guard let geometryData = additionalData.geometryDataSource else {
9 return
10 }
11 let query = TTAdditionalDataSearchQueryBuilder.create(with: geometryData).build()
12 searchAdditionalData.additionalDataSearch(with: query)
13}
14func additionalDataSearch(_: TTAdditionalDataSearch, completedWith response: TTAdditionalDataSearchResponse) {
15 progress.hide()
16 guard let result = response.results.first else {
17 return
18 }
19 let visitor = PolygonAdditionalDataVisitior()
20 result.visitGeoJSONResult(visitor)
21 var mapPolygons: [TTPolygon] = for lineString in visitor.lineStrings {
22 let mapPolygon = TTPolygon(coordinatesData: lineString, opacity: 0.7, color: TTColor.Red(), colorOutline: TTColor.Red())
23 mapPolygons.append(mapPolygon)
24 mapView.annotationManager.add(mapPolygon)
25 }
26 mapView.zoom(toCoordinatesDataCollection: mapPolygons)
27}
1- (void)search:(TTSearch *)search completedWithResponse:(TTSearchResponse *)response {
2 TTSearchResult *result = response.results.firstObject
3 if (!result) {
4 return;
5 }
6 TTAdditionalDataSources *additionalData = result.additionalDataSources;
7 if (!additionalData) {
8 return;
9 }
10 TTGeometryDataSource *geometryData = additionalData.geometryDataSource;
11 if (!geometryData) {
12 return;
13 }
14 TTAdditionalDataSearchQuery *query = [[TTAdditionalDataSearchQueryBuilder createWithDataSource:geometryData] build];
15 [self.searchAdditionalData additionalDataSearchWithQuery:query];
16}
17- (void)additionalDataSearch:(TTAdditionalDataSearch *)additionalDataSearch completedWithResponse:(TTAdditionalDataSearchResponse *)response {
18 [self.progress hide];
19 TTAdditionalDataSearchResult *result = response.results.firstObject;
20 if (!result) {
21 return;
22 }
23 PolygonAdditionalDataVisitior *visitor = [PolygonAdditionalDataVisitior new];
24 [result visitGeoJSONResult:visitor];
25 NSMutableArray<TTPolygon *> *mapPolygons = [NSMutableArray new];
26 for (TTGeoJSONLineString *lineString in visitor.lineStrings) {
27 TTPolygon *mapPolygon = [TTPolygon polygonWithCoordinatesData:lineString opacity:0.7 color:[TTColor Red] colorOutline:[TTColor Red]];
28 [mapPolygons addObject:mapPolygon];
29 [self.mapView.annotationManager addOverlay:mapPolygon];
30 }
31 [self.mapView zoomToCoordinatesDataCollection:mapPolygons];
32}

Sample views utilizing entities retrieved from the Additional Data service:

image

Boundaries for Amsterdam

image

Boundaries for Poland