Map configuration
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:
- MapViewState: To define the initial view and state of the map.
- MapDisplayInfrastructure: To set up the underlying infrastructure for map rendering and location services.
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, // Optional10) {11 // Optional configuration block. For example:1213 // Disable camera tracking14 cameraState.trackingMode = CameraTrackingMode.None1516 // Set the dark style mode for the map17 styleState.styleMode = StyleMode.DARK1819 // Define safe area padding around the map20 safeArea = PaddingValues(PADDING)21}
1companion object {2 private val AMSTERDAM = GeoPoint(52.3676, 4.9041)3 private val PADDING = 16.dp4 private const val ZOOM = 15.05 private const val TILT = 0.06 private const val ROTATION = 0.07 private const val FIELD_OF_VIEW = 45.08}
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:34 locationInfrastructure = MapLocationInfrastructure {5 locationProvider = myLocationProvider6 }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: