THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Map Initialization

The Maps SDK for iOS allows you to initialize the map with a previously setup configuration. For this purpose, use the init method TTMapView with frame and mapConfiguration. The TTMapConfiguration object allows you to set initial map values with the following method:

  • viewportTransform: The TTViewportTransform object allows you to set an initial viewport transform for the map configuration.
  • mapStyleConfiguration: The TTStyleConfiguration object allows you to add your own style configuration.
  • TomTomLogoPosition: The TTLogoPosition object allows you to place the logo on the map where you wish by using enumerations containing positions and Offset information.

Use the following code snippets in your app to display maps of different locations (in this case, the current location by placing a bounding box on Amsterdam and by centering the point to the TomTom office in Łódź).

Centering the map on load using bounding box:

1let transform = TTCenterOnGeometryBuilder.create(withGeometry: [
2 .init(TTCoordinate.AMSTERDAM_BOUNDINGBOX_LT()),
3 .init(TTCoordinate.AMSTERDAM_BOUNDINGBOX_RT()),
4 .init(TTCoordinate.AMSTERDAM_BOUNDINGBOX_LB()),
5 .init(TTCoordinate.AMSTERDAM_BOUNDINGBOX_RB()),
6], withPadding: .zero)
7 .withPitch(30)
8 .withBearing(-90)
9 .build()
10let config = TTMapConfigurationBuilder.create().withViewportTransform(transform).withMapKey(Key.Map).withTrafficKey(Key.Traffic)
1NSArray *arrayCoordinates = [NSArray
2 arrayWithObjects:[[CLLocation alloc] init:[TTCoordinate AMSTERDAM_BOUNDINGBOX_LT]], [[CLLocation alloc] init:[TTCoordinate AMSTERDAM_BOUNDINGBOX_RT]], [[CLLocation alloc] init:[TTCoordinate AMSTERDAM_BOUNDINGBOX_LB]], [[CLLocation alloc] init:[TTCoordinate AMSTERDAM_BOUNDINGBOX_RB]], nil]
3TTCenterOnGeometry *transform = [[[[TTCenterOnGeometryBuilder createWithGeometry:arrayCoordinates withPadding:UIEdgeInsetsZero] withPitch:30] withBearing:-90] build];
4TTMapConfigurationBuilder *config = [[[[TTMapConfigurationBuilder createBuilder] withViewportTransform:transform] withMapKey:Key.Map] withTrafficKey:Key.Traffic];

Centering the map on load using center on point:

1let builder = TTMapConfigurationBuilder.create().withTrafficKey(Key.Traffic).withMapKey(Key.Map)
2let transform = TTCenterOnPointBuilder.create(withCenter: TTCoordinate.LODZ_ZEROMSKIEGO()).withZoom(15).build()
3let config = builder.withViewportTransform(transform)
TTCenterOnPoint *transform = [[[TTCenterOnPointBuilder createWithCenter:[TTCoordinate LODZ_ZEROMSKIEGO]] withZoom:15] build];
TTMapConfigurationBuilder *config = [[[[TTMapConfigurationBuilder createBuilder] withViewportTransform:transform] withMapKey:Key.Map] withTrafficKey:Key.Traffic];

You can also set the positions of the TomTom logo, but remember that the logo must fully fit into the bounds of mapview. Otherwise there is an exception due to an error in displaying the logo on the map.

let position = TTLogoPosition(verticalPosition: .bottom, horizontalPosition: .right, verticalOffset: -65, horizontalOffset: -170)
config.withTomTomLogoPosition(position)
TTLogoPosition *position = [[TTLogoPosition alloc] initWithVerticalPosition:bottom horizontalPosition:right verticalOffset:-65 horizontalOffset:-170];
[config withTomTomLogoPosition:position];

Use the configuration object to initialize the map with the following code:

1let style = TTMapStyleDefaultConfiguration()
2config.withMapStyleConfiguration(style)
3map = TTMapView(mapConfiguration: config.build())
1TTMapStyleDefaultConfiguration *style = [[TTMapStyleDefaultConfiguration alloc] init];
2[config withMapStyleConfiguration:style];
3self.map = [[TTMapView alloc] initWithMapConfiguration:[config build]];

image

Bounding Box

image

Starting point