Sorry, you need to enable JavaScript to visit this website.

Getting started

Getting started

With the complete set of modules, we give you the possibility to develop map-based applications with stylable map, customizable UI, optimized footprint in your favorite technology.
The MAP module com.tomtom.online:sdk-maps:2.+@aar gives you functionalities for displaying different types and styles of map, map manipulation, map caching, etc.

You can use a comprehensive suite of Map Extensions:

Map UI Extensions – to display and customize UI controls for map (e.g. compass, zoom buttons)
Map ReactX Extensions – to use a ReactX technology in your code
Map Kotlin Extensions – to code in Kotlin
Static map image - renders a user-defined, rectangular image, containing a map sectio

The basic steps for adding the map are:

  • Add dependency to map library in build.gradle file:

implementation("com.tomtom.online:sdk-maps:2.+")
  • Enable Java 8 Support in build.gradle file:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
  • Edit AndroidManifest.xml and add the API key inside <application> tag:

<meta-data
            android:name="OnlineMaps.Key"
            android:value="your-tomtom-key" />
  • Embed 'MapFragment' inside your layout:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <fragment
        android:id="@+id/map_fragment"
        android:name="com.tomtom.online.sdk.map.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>
  • Obtain reference to the 'MapFragment' and register 'OnMapReadyCallback':

mapFragment = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment);
mapFragment.getAsyncMap(onMapReadyCallback);
  • Forward permissions callbacks from 'Activity' to 'TomtomMap':

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    tomtomMap.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
  • Configure the map once it is ready:

private final OnMapReadyCallback onMapReadyCallback =
        new OnMapReadyCallback() {
            @Override
            public void onMapReady(TomtomMap map) {
                //Map is ready here
                tomtomMap = map;
                tomtomMap.setMyLocationEnabled(true);
                tomtomMap.collectLogsToFile(SampleApp.LOGCAT_PATH);
            }
        };

Logging

TomTom SDK Log level

In TomTom we are constantly working on our products quality. That is why it is very important to have as detailed logs
as possible for our support team to provide accurate help or bugfixes. Maps SDK for Android has advanced mechanism
to gather and send logs to our support team. To enable logging and specify log level please add below code to your app:

Example:

@Override
public void onCreate() {
    super.onCreate();
    LogUtils.enableLogs(Log.VERBOSE);
  • android.util.Log.VERBOSE will print all logs from TomTom SDK.

  • android.util.Log.DEBUG will print debug logs from TomTom SDK.

Logs from SDK libraries are disabled by default.

Collecting logs

TomTom log

Logs from application can be collected into file on SD card.

LogUtils.LogFileCollector.collectLogsToFile(logsFilePath);

Special permission should be added into your AndroidManifest.xml to save logs on sdcard:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

and runtime permission should be handled on your side for android version 26 or above.

When sdk-maps module is used the problem with supporting runtime permissions is handled by sdk by method:

@Override
public void onMapReady(@NonNull TomtomMap tomtomMap) {
    tomtomMap.collectLogsToFile(SampleApp.LOGCAT_PATH);
}

Important: Since Android API level 23 it is required to ask user for runtime permission to write into SD card.

Register crash observer

With usage of crash observer it is possible to automate process of preparing email massage with attached
logs which were already collected and stored on SD card. To do so, please register crash handler with below code:
Crash observer doesn’t brake your already used handlers ( like Crashlitics).

LogUtils.registerCrashObserver(getApplicationContext(), Uri.parse("file://" + LOGCAT_PATH));

Bug report

To enable advanced logging mechanism which collects detailed data from logcat like: threads, services and phone states, please use below code:

adb bugreport issue01

This produce a issue01.zip.