We rolled out a new and better SDK for you.

Map centering

Center the map in your mobile app either at the current coordinates or any other location at the zoom level of your choice.

Sample use case: You want to display the maps for selected cities in specific zoom levels. Your users should be able to easily switch between different locations.

Use the following code snippets in your app to display maps of different locations (in this case, the current location and the TomTom offices in Amsterdam and Berlin).

The example shows how to center the map on Amsterdam using TTCameraPositionBuilder and its create method:

let cameraPosition = TTCameraPositionBuilder.create(withCameraPosition: TTCoordinate.AMSTERDAM()).withZoom(10).build()
TTCameraPosition *cameraPosition = [[[TTCameraPositionBuilder createWithCameraPosition:[TTCoordinate AMSTERDAM]] withZoom:10] build]
[self.mapView setCameraPosition:cameraPosition];

The example shows how to center the map on Amsterdam using TTCameraBoundingBoxBuilder and its create method:

1let boundingBox = TTBoundingBox(topLeft: TTCoordinate.AMSTERDAM_BOUNDINGBOX_LT(), withBottomRight: TTCoordinate.AMSTERDAM_BOUNDINGBOX_RB())
2let cameraPosition = TTCameraBoundingBoxBuilder.create(with: boundingBox!).build()
1TTBoundingBox *boundingBox = [[TTBoundingBox alloc] initWithTopLeft:[TTCoordinate AMSTERDAM_BOUNDINGBOX_LT] withBottomRight:[TTCoordinate AMSTERDAM_BOUNDINGBOX_RB]];
2TTCameraBoundingBox *cameraPosition = [[TTCameraBoundingBoxBuilder createWithBoundingBox:boundingBox] build];
3[self.mapView setCameraPosition:cameraPosition];


Map centered on Amsterdam with 10 zoom level


Map centered on GPS with 10 zoom level