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

Map layers visibility

Map layers visibility

Allow your users to dynamically toggle the visibility of map entities. You can hide map layers to get
the level of detail you need and highlight the layers that are important for your use case.

Sample use case: You want to provide a clear map view for driving that focuses on the road network
in your app. You can achieve that by switching off some map layers e.g. woodland, build-up areas, etc.
You can turn these layers back on at run time to bring back the details for a better map viewing experience.

The following articles provide more information on map layer visibility and map layers available in
the default style: Map layers, Default style.

You can retrieve all layers available in the style or only those that match provided regex.
To filter, you can use layer ID or source layer ID properties, as shown below:

_

//ROADS_NETWORK_LAYER_REGEX = "[mM]otorway.*|.*[rR]oad.*"
List<Layer> layers = tomtomMap.getStyleSettings().findLayersBySourceLayerId(ROADS_NETWORK_LAYER_REGEX);
//regex = e.g. "[mM]otorway.*|.*[rR]oad.*" or "[wW]oodland" or "Built-up area"
val layers = tomtomMap.styleSettings.findLayersBySourceLayerId(String.format(regex))

Once you have a list of layers, you can modify their visibility:

_

for (Layer layer : layers) {
    layer.setVisibility(visibility);
}
layers.forEach { layer -> layer.visibility = visibility }


image

Road network hidden

image

Woodland and build-up shown

You are here