Switching Map Styles
Set Style When the Map Is Ready
Set your desired style in onMapReady. You can use the style-loaded callback to further customize layers and sources:
Recommendations
- Coordinate with tile switching: After changing the tile server, call
setStyle(...)to force a reload so the new base tiles are immediately reflected. - Performance: Style switches require re-loading of resources. It is recommended to do so at clear UX moments (e.g., theme toggle).
- Night mode: Consider aligning
MAP_TYPE_NIGHTwith system dark mode or your app’s theme.