Map configuration

VERSION 2.1.2

The Map Display Compose module enables you to integrate the TomTom map into your Android application for visualization. To meet your use case requirements, you need to apply initial settings during map initialization. You can configure the following components:

Configuring map view state

When creating a MapViewState, you need to pass InitialCameraOptions, as it is a mandatory (non-nullable) parameter. This configuration defines the initial view of the map when it is first rendered, allowing you to set essential properties such as camera position, zoom level, and field of view. In addition to initialCameraOptions, you can also provide the initialStyle parameter, which allows you to specify the initial style of the map.

1val mapViewState = rememberMapViewState(
2 initialCameraOptions = InitialCameraOptions.LocationBased(
3 position = AMSTERDAM,
4 zoom = ZOOM,
5 tilt = TILT,
6 rotation = ROTATION,
7 fieldOfView = FIELD_OF_VIEW,
8 ),
9 initialStyle = StandardStyles.TomTomOrbisMaps.DRIVING, // Optional
10) {
11 // Optional configuration block. For example:
12
13 // Disable camera tracking
14 cameraState.trackingMode = CameraTrackingMode.None
15
16 // Set the dark style mode for the map
17 styleState.styleMode = StyleMode.DARK
18
19 // Define safe area padding around the map
20 safeArea = PaddingValues(PADDING)
21}
1companion object {
2 private val AMSTERDAM = GeoPoint(52.3676, 4.9041)
3 private val PADDING = 16.dp
4 private const val ZOOM = 15.0
5 private const val TILT = 0.0
6 private const val ROTATION = 0.0
7 private const val FIELD_OF_VIEW = 45.0
8}

The MapViewState also provides a lambda configuration block where various map options can be configured, such as CameraState and MapStyleState. Adjust these settings according to your application’s needs to ensure optimal performance and user experience.

Configuring map infrastructure

The MapDisplayInfrastructure groups the data layer entities of the map view. This includes data management and, optionally, the location service. Configuring it involves specifying the data source and additional settings.

1val mapDisplayInfrastructure = MapDisplayInfrastructure(TomTomSdk.sdkContext) {
2 // Optional configuration block. For example:
3
4 locationInfrastructure = MapLocationInfrastructure {
5 locationProvider = myLocationProvider
6 }
7}

Frame rate

By default, the map is rendered with a refresh rate of 60 FPS. You can change the frame rate, but note that the application will round the value to the nearest factor of 60 to ensure compatibility with standard displays. For example, if you set the frame rate to 24 FPS, it will be rounded down to 20 FPS.

mapViewState.frameRate = 30

Next steps

Since you have learned how to configure a map, here are recommendations for the next steps: