THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Use style from Style Merger

Starting with version 2.4.537, we are switching bundled-in styles and sprite, to using TomTom hosted styles and sprites. More information about the new approach is available in Map Initialization. Thanks to integration with Merged Style method provided by Map Display API you can generate and use one style for map and traffic display. The main benefits of TomTom hosted display resources are as following:

  • It makes application download size MB smaller in comparison to using bundled-in resources.
  • It allows you to get the newest look and feel of the map and traffic.

Maps SDK will work with the bundled-in style until June 2021 but we recommend to switch to using hosted assets sooner.

Until version 2.4.537, the style in the SDK has been included in the map package and consisted of layers from: Vector tiles, Traffic Flow, Traffic Incidents and Raster tiles. The approach of using a single style that contains multiple Traffic Flow tiles types was deprecated. After the deprecation period is over, it will not be possible to switch between Traffic Flow tiles types without reloading the style. Until deprecation is over in June 2021, the default map style which contains both raster and vector tiles is using SDK_BUNDLED, as a default value for the enum MapStyleSource.

Deprecated methods include UiSettings with all of its methods and TrafficSettings:

  • ** UiSettings:** setMapLayersType(MapLayersType mapLayersType) getMapLayersType() setMapTilesType(MapTilesType mapTilesType) getMapTilesType()
  • ** TrafficSettings:** turnOnVectorTrafficFlowTiles() turnOnRasterTrafficFlowTiles() turnOnVectorTrafficFlowTiles(TrafficFlowType.VectorTrafficFlowType trafficFlowTilesStyle) turnOnRasterTrafficFlowTiles(TrafficFlowType.RasterTrafficFlowType trafficFlowTilesStyle) turnOnVectorTrafficIncidents() turnOnRasterTrafficIncidents() isTrafficVectorFlowEnabled() isTrafficRasterFlowEnabled() getTrafficVectorFlowStyle() getTrafficRasterFlowStyle()

We encourage you to switch to the Merged Style method. It offers the following advantages to a proposed solution:

  • Each style has its own sprite sheet and is now fully independent.
  • A user can mix and match all sources of tiles in any manner as styles and sprite sheets are now merged on the server side. The selection of a particular style combination is done by providing custom Style Merger URL parameters.
  • It is easier to style traffic in the Map Styler as it can be easily loaded together with a map by using a merged version of the styles. However, the style from the Style Merger can only be used as a base for a custom style. Using this edited style and the Style Merger at the same time is not possible.
  • SDKs do not merge styles in runtime (e.g., it is required to have some hard-coded values to put traffic below the label layers in a map).

In case you have your own custom style that is not compliant with the TomTom sourcing names convention, you will use LayerSetConfiguration, which provides custom IDs for sources in the style. LayerSetConfiguration should only be used with the MapStyleSource set to STYLE_MERGER.

Map initialization with the Style Merger endpoint using Merged Style functionality is described in section "Map properties". To the new functionality you need to implement a builder as described in the following example: MapStyleSource is used to determine if the default and loaded style should support Style Merger. Setting it to STYLE_MERGER results in the default style only supporting vector tiles:

1MapProperties.Builder()
2 .mapStyleSource(MapStyleSource.STYLE_MERGER)
3 .build()

When MapStyleSource.STYLE_MERGER is selected, the method related to directly switching between raster and vector tiles will throw an exception. MapProperties can be also be declared in the XML by adding the following line:

tomtom:mapStyleSource="STYLE_MERGER"

to the snippet:

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:mapBackgroundColor="@color/solid_black"
7 tomtom:styleUrl="http://your-server:port/style/example-merged.json"
8 tomtom:mapStyleSource="STYLE_MERGER" />

In case you have your own custom style that is not compliant with the TomTom sourcing names convention, you will use LayerSetConfiguration which provides custom IDs for sources in the style.

LayerSetConfiguration should be used only with the MapStyleSource set to STYLE_MERGER.

1val layerSetConfiguration = LayerSetConfiguration.Builder()
2 .mapTilesConfiguration(MAP_TILES_SOURCE_ID)
3 .trafficIncidentsTilesConfiguration(TRAFFIC_INCIDENTS_SOURCE_ID)
4 .trafficFlowTilesConfiguration(TRAFFIC_FLOW_SOURCE_ID)
5 .build()
6MapProperties.Builder()
7 .mapStyleSource(MapStyleSource.STYLE_MERGER)
8 .layerSetConfiguration(layerSetConfiguration)
9 .build()

or

1tomtomMap.getUiSettings().setStyleUrl(
2 "asset://styles/custom-traffic.json",
3 new LayerSetConfiguration.Builder()
4 .mapTilesConfiguration(MAP_TILES_SOURCE_ID)
5 .trafficFlowTilesConfiguration(TRAFFIC_FLOW_SOURCE_ID)
6 .trafficIncidentsTilesConfiguration(TRAFFIC_INCIDENTS_SOURCE_ID)
7 .build()
8)
1tomtomMap.uiSettings.setStyleUrl(
2 "asset://styles/custom-traffic.json",
3 LayerSetConfiguration.Builder()
4 .mapTilesConfiguration(MAP_TILES_SOURCE_ID)
5 .trafficFlowTilesConfiguration(TRAFFIC_FLOW_SOURCE_ID)
6 .trafficIncidentsTilesConfiguration(TRAFFIC_INCIDENTS_SOURCE_ID)
7 .build()
8)