Skip to main content

Android Compose

Android Compose (Jetpack Compose) is a toolkit for creating UI in Android applications developed in Kotlin. Unlike Android View, this framework follows the declarative approach to describing the interface.

You can use modules for Android Compose by 2GIS to add standard UI controls to your project:

  • compose-map for managing the map. The module is available for both Full and Map versions of the SDK.
  • compose-navigation for creating a navigator. The module is available only for the Full version of the SDK.

To add a module to your application, add the following elements to app/build.gradle and specify the number and type of the SDK version (both parameters are mandatory):

dependencies {

def sdkVersion = "13.0.0" // SDK version number

implementation("ru.dgis.sdk:sdk-map:$sdkVersion") // Specify sdk-map or sdk-full
implementation("ru.dgis.sdk:compose-map:$sdkVersion") // Map module
implementation("ru.dgis.sdk:compose-navigation:$sdkVersion") // Navigator module
}

See an example of a prepared app/build.gradle in the demo project on GitHub.

Map

Get the map using MapComposable. The map is then used when adding UI elements. See the map preparation example.

The standard set contains the following controls:

  1. IndoorComposable to switch floors.
  2. TrafficComposable to display the current traffic jam score and manage the visibility of traffic jams on the map.
  3. ZoomComposable to scale the map (zoom in and out).
  4. CompassComposable to display the current map rotation angle relative to the north.
  5. MyLocationComposable to fly to the current user location. This UI control displays the current camera follow state (CameraFollowState) and enables changing it.
  1. MinimapComposable to display a minimap during navigation.

The Full version of the SDK contains a set of UI controls for displaying and managing navigation. For convenience, all controls are combined in NavigationControlsComposable, which you can customize via DefaultNavigationControlsContent.

The standard set contains the following controls:

  1. TrafficLineComposable to display the traffic jam level on the route.
  2. ManeuverComposable to display information about the next maneuver.
  3. SpeedInfoComposable to display the current speed and the speed limit.
  4. TrafficAndParkingComposable - a container for UI controls to manage the visibility of traffic jams (NavigatorTrafficComposable) and parking lots (ParkingComposable) on the map.
  5. NavigationZoomComposable to scale the map (zoom in and out).
  6. NavigationCompassComposable to display the current map rotation angle relative to the north.
  7. NavigationFollowComposable to manage the following of the location marker.
  8. NavigationDashboardComposable to display information in the turn-by-turn mode.

 

  1. NavigationDashboardComposable to display information in the free-drive mode.
  2. NavigationDashboardComposable to display information in the indoor navigation mode.
  3. NavigationIndoorComposable to manage the floor list in the indoor navigation mode.

  

  1. BetterRoutePromptComposable to display a prompt to switch to the "better route".
  2. FinishRouteComposable to display information about route completion.
  3. RouteOverviewComposable to display general information about the route during navigation.