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

Map Styles Extensions

Map Styles Extensions

Maps SDK gives you a possibility to use either online or offline styles in your mobile application.

  • If you choose to use offline styles, they will be imported to your app with the Map SDK package.
    Thanks to that the style will be included in your app already at the app 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
    to displayed for the first time. Thanks to that, your mobile app size is smaller at the app download
    time so your app downloadable is lighter. In this case you need exclude offline styles from sdk.

Offline styles

To use offline style library you don’t have to do any action, because offline styles are attached to
the map by default. To use offline style library with your custom map, add the following dependency to
the build.gradle file:

implementation("com.tomtom.online:sdk-maps-styles-extensions:2.+")

When offline style are not attached to the project and online style is not setup for the map then black screen will instead a map.

 



image

Screen without style

 

Online styles

To exclude offline style from sdk-maps module use exclude declaration when sdk-maps module is
decelerated.

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

When offline style are excluded then the online style should be setup.
You can setup online style in MapFragment:

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

You can setup online style in MapView:

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

To use offline style library you don’t have to do any action, because offline style are
attached to the map by default.

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

implementation("com.tomtom.online:sdk-maps-styles-extensions:2.+")