THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Map Styles Extensions

The TomTom Maps SDK gives you the ability to use either online or offline styles in your mobile application.

IMPORTANT: The Map Display API comes with a built-in offline style, but this approach was deprecated in May 2020. In one year, the offline style will be removed from the package and replaced with an URL to the style from Style Merger.

  • If you choose to use offline styles, they will be imported to your app with the Maps SDK package. Thanks to that, the styles will already be included in your app at download time. The styles are added to the Maps SDK package by default.
  • If you choose to use online styles, they will be downloaded into your application when the map is displayed for the first time. Thanks to that, your mobile app size is smaller at the app’s download time so your app downloadable is lighter. In this case you need to exclude offline styles from the SDK.

Online styles

IMPORTANT: The Map Display API comes with a built-in offline style, but this approach was deprecated in May 2020. In one year, the offline style will be removed from the package and replaced with an URL to the style from Style Merger.

To exclude offline styles from the sdk-maps module, use an exclude declaration when the sdk-maps module is declared as shown in the following code example.

1api("com.tomtom.online:sdk-maps:.internalVersions.sdk@aar") {
2 transitive = true
3 exclude module: 'sdk-maps-styles-extensions'
4 }

When offline styles are excluded, then the online styles should be set up. You can set up online styles in MapFragment:

1<fragment
2 android:id="@+id/map_fragment"
3 android:name="com.tomtom.online.sdk.map.MapFragment"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 tomtom:customStyleUrl="http://your-server:port/style/example-merged.json" />

You can set up online styles in MapView:

1<?xml version="1.0" encoding="utf-8"?>
2<com.tomtom.online.sdk.map.MapView xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:tomtom="http://schemas.android.com/apk/res-auto"
4 android:id="@+id/map_view"
5 android:layout_height="match_parent"
6 android:layout_width="match_parent"
7 tomtom:styleUrl="asset://styles/night.json"
8 >
9</com.tomtom.online.sdk.map.MapView>

To use the offline style library, no actions are required because the offline styles are attached to the map by default.

To use the offline style library with your custom map, add the following dependency to the build.gradle file:

implementation("com.tomtom.online:sdk-maps-styles-extensions:{libversion}")