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.
![]() Images layer moved to the front |
_
// layersImages = tomtomMap.getStyleSettings().findLayersById(IMAGE_LAYER_ID + "[0-9]");
// Layer imgLayer = layersImages.get(...)
tomtomMap.getStyleSettings().moveLayerBehind(imgLayer.getId(), "");
//REFERENCE_LAYER = ""
tomtomMap.styleSettings.moveLayerBehind(layer.id, REFERENCE_LAYER)
![]() GeoJson layer with line moved to the front |
_
// layerGeoJson = tomtomMap.getStyleSettings().findLayerById("layer-line-id").orNull();
tomtomMap.getStyleSettings().moveLayerBehind(layerGeoJson.getId(), "");
//REFERENCE_LAYER = ""
tomtomMap.styleSettings.moveLayerBehind(layer.id, REFERENCE_LAYER)
![]() 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)