Switch to dark mode inside tunnels

In this example, we illustrate how to modify the map display (between light and dark modes) based on the location within a specific route.

To mimic the movement of a vehicle, we employ an animated point along the route. In this scenario, we simulate the vehicle entering a tunnel, prompting a switch to the dark map style. Subsequently, when the vehicle exits the tunnel, we revert back to the light map style. You can download the vehicle image, and obtain the route geoJSON file.



Related examples

An extension of MapLibre GL JS