Skip to content

MapTrip SDK Quick UI

Info

MapTrip SDK Quick UI is still in active development and interfaces may change. We are excited to share it already with you and are looking forward to your feedback.

About

The MapTrip SDK Quick UI library enables you to quickly set up a navigation view on top of the MapTrip SDK in your own application. It provides a Fragment to wrap the most common use cases for a navigation app.

QuickUiFragment

Features

  • Route information: remaining distance, remaining time, estimated time of arrival
  • Next instruction: direction and remaining distance
  • Display of current speed limit
  • Voice guidance with TextToSpeech or prerecorded audio files
  • Automatic toogle between day and night mode
  • Resume to location tracking button
  • Display of POI: Traffic events & Speed cams
  • Display of Traffic flow

Requirements

Add the dependency

  • Modify app/build.gradle to add the build rule additionally to the MapTrip SDK:
1
2
implementation "de.infoware:maptrip-sdk:9.9.7"
implementation "de.infoware:maptrip-sdk-quick-ui:9.9.7"

Integrate the QuickUiFragment

After adding a map you will need to add a FragmentContainerView to your layout.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <de.infoware.android.api.IwMapView
        android:id="@+id/map"
        xmlns:api="http://schemas.android.com/apk/res-auto"
        api:iwId="1"
        api:showVehicleIcon="true"
        api:enableLocationTracking="true"
        api:perspective="perspective_3d"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/quick_ui_fragment_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="@+id/map" />

</androidx.constraintlayout.widget.ConstraintLayout>

As demonstrated in the Navigation example you will now need to calculate a route. Next, you can create an Instance of QuickUiFragment. The required parameters can be passed by an instance of QuickUiOptions. Please open the fragment from your UI thread specifically. The result of the task will be in the SDK Runtime Thread.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var calculateRouteTask : Task<Void>? = null

navigation.registerTaskListener(object : TaskListener {
    override fun taskProgress(task: BaseTask) {
        // Not needed for now, use it for e.g. displaying a progress bar
    }

    override fun taskFinished(task: BaseTask) {
        // if the task originated from calculateRoute, start a navigation
        if (task == calculateRouteTask) {
          val retVal: Int = task.returnValue.intVal
          val apiError = ApiError.getByInt(retVal)

          navigation.removeTaskListener(this)

          // if the task was not successful, print an error
          if (retVal < ApiError.OK.intVal) {
            // Task-Callback: Route could not be calculated
          }

          if (retVal > ApiError.OK.intVal) {
            // Task-Callback: Route could be calculated, but there are warnings
          }

          // Set up the fragment from UI Thread  
          runOnUiThread {
              val options = QuickUiOptions.Builder()
                            .mapViewer(mapView.mapviewer)
                            .navigation(navigation)
                            .build()
              val fragment = QuickUiFragment.create(options)
              supportFragmentManager.beginTransaction()
                .replace(R.id.quick_ui_fragment_container, fragment)
                .commitNow()
          }
        }
    }

})

calculateRouteTask = navigation.calculateRoute()

The QuickUiFragment handles the start of the navigation and reaching the destination automatically. If the destination is reached, the fragment will be closed.

Attention

Currently, only itineraries with one destination waypoint are supported.