THIS SDK ISDEPRECATED. We rolled out a new and better SDK for you.
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:
Copy 1 func search ( _ : TTSearch , completedWith response : TTSearchResponse ) {
2 guard let result = response . results . first else {
5 guard let additionalData = result . additionalDataSources else {
8 guard let geometryData = additionalData . geometryDataSource else {
11 let query = TTAdditionalDataSearchQueryBuilder . create ( with : geometryData ) . build ( )
12 searchAdditionalData . additionalDataSearch ( with : query )
14 func additionalDataSearch ( _ : TTAdditionalDataSearch , completedWith response : TTAdditionalDataSearchResponse ) {
16 guard let result = response . results . first else {
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 )
26 mapView . zoom ( toCoordinatesDataCollection : mapPolygons )
Copy 1 - (void)search:(TTSearch *)search completedWithResponse:(TTSearchResponse *)response {
2 TTSearchResult *result = response.results.firstObject
6 TTAdditionalDataSources *additionalData = result.additionalDataSources;
10 TTGeometryDataSource *geometryData = additionalData.geometryDataSource;
14 TTAdditionalDataSearchQuery *query = [[TTAdditionalDataSearchQueryBuilder createWithDataSource:geometryData] build];
15 [self.searchAdditionalData additionalDataSearchWithQuery:query];
17 - (void)additionalDataSearch:(TTAdditionalDataSearch *)additionalDataSearch completedWithResponse:(TTAdditionalDataSearchResponse *)response {
19 TTAdditionalDataSearchResult *result = response.results.firstObject;
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];
31 [self.mapView zoomToCoordinatesDataCollection:mapPolygons];
Sample views utilizing entities retrieved from the Additional Data service:
Boundaries for Amsterdam
Boundaries for Poland