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

Custom styles

Custom styles

Default & Custom Style

The default style for Maps SDK is retrieved from the Map Style endpoint. This is a merged style constructed from layers of vector map, traffic flow and traffic incidents overlay. The details on generating such a style is described in the following sections "Merged style method" and "Merged sprite method" of the Map Style documentation

If you wish to create your own map style, we recommend the following:

  • download the default style from the Map Style endpoint

  • modify the style in the Map Styler

  • use the modified style in the SDK

Modify the default TomTom style

The best way to create a custom style is to modify the default TomTom style for vector maps using the Maputnik editor. You can find the JSON map style in the resources directory. The tutorial on how to modify the style is available for all Maps SDKs (for Android, iOS, and Web) at Creating custom vector map style. Note that after step 9 of the linked tutorial, you need to save the JSON file and place it in the resources directory of your app project.

Provide your style You can provide an external map style file on the server and provide the URL. Sprites and fonts should be stored locally in the application. Currently, we don’t support loading resources and fonts from a server.

Sample use case 1: You want to display a night-themed map with inverted logo colors at night or while in a tunnel.

_

tomtomMap.getUiSettings().setStyleUrl("asset://styles/night.json");
tomtomMap.getUiSettings().getLogoView().applyInvertedLogo();
tomtomMap.uiSettings.setStyleUrl("asset://styles/night.json")
tomtomMap.uiSettings.logoView.applyInvertedLogo()
tomtomMap.uiSettings.copyrightsView.applyInvertedColor()

Optionally, there is a possibility to load the style directly from JSON text:

_

String styleJson = [...];
tomtomMap.getUiSettings().setStyleJson(styleJson);
val styleJson: String = [...]
tomtomMap.uiSettings.setStyleJson(styleJson)

Sample use case 2: You want to switch back to the basic style for map and logo.

_

tomtomMap.getUiSettings().loadDefaultStyle();
tomtomMap.getUiSettings().getLogoView().applyDefaultLogo();
tomtomMap.uiSettings.loadDefaultStyle()
tomtomMap.uiSettings.logoView.applyDefaultLogo()
tomtomMap.uiSettings.copyrightsView.applyDefaultColor()

Sample use case 3: You want to use your own custom style not compliant with TomTom source names convention.

_

tomtomMap.getUiSettings().setStyleUrl(
        "asset://styles/custom-traffic.json",
        new LayerSetConfiguration.Builder()
                .mapTilesConfiguration(MAP_TILES_SOURCE_ID)
                .trafficFlowTilesConfiguration(TRAFFIC_FLOW_SOURCE_ID)
                .trafficIncidentsTilesConfiguration(TRAFFIC_INCIDENTS_SOURCE_ID)
                .build()
);
tomtomMap.uiSettings.setStyleUrl(
    "asset://styles/custom-traffic.json",
    LayerSetConfiguration.Builder()
        .mapTilesConfiguration(MAP_TILES_SOURCE_ID)
        .trafficFlowTilesConfiguration(TRAFFIC_FLOW_SOURCE_ID)
        .trafficIncidentsTilesConfiguration(TRAFFIC_INCIDENTS_SOURCE_ID)
        .build()
)

IMPORTANT: Reloading the style is an asynchronous operation. You need to ensure that no method modifies the style before this operation is done. TomtomMapCallback.OnMapChangedListener.onDidFinishLoadingStyle is called when reloading the style is finished. An OnMapChangedListener can be registered using TomTomMap.addOnMapChangedListener.

image

Basic style

image

Night custom style