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

Dynamic Layer Ordering

Dynamic Layer Ordering

You can dynamically change the z-order of the layers on the map to make the layers important to your use case visible on top of other layers.

Sample use case : You placed images on the map in your app but your users can bring the route and the road network on top of the images to see what the route looks like in detail.

image

Images layer moved to the front

_

// layersImages = tomtomMap.getStyleSettings().findLayersById(IMAGE_LAYER_ID + "[0-9]");
// Layer imgLayer = layersImages.get(...)
// tomtomMap.getStyleSettings().moveLayerBehind(layer.getId(), "");
layersHelper.moveLayerToFront(imgLayer);
//REFERENCE_LAYER = ""
tomtomMap.styleSettings.moveLayerBehind(layer.id, REFERENCE_LAYER)
image

GeoJson layer with line moved to the front

_

// layerGeoJson = tomtomMap.getStyleSettings().findLayerById("layer-line-id").orNull();
// tomtomMap.getStyleSettings().moveLayerBehind(layerGeoJson.getId(), "");
layersHelper.moveLayerToFront(layerGeoJson);
//REFERENCE_LAYER = ""
tomtomMap.styleSettings.moveLayerBehind(layer.id, REFERENCE_LAYER)
image

Roads layer moved to the front

_

// layersRoads = tomtomMap.getStyleSettings().findLayersById(".*[rR]oad.*|.*[mM]otorway.*");
// Layer roadLayer = layersRoads.get(...)
tomtomMap.getStyleSettings().moveLayerBehind(roadLayer.getId(), "");
//REFERENCE_LAYER = ""
tomtomMap.styleSettings.moveLayerBehind(layer.id, REFERENCE_LAYER)

You are here