mapbox / mapbox/mapbox-maps-ios
After setting MapStyle from `.standard(lightPreset: .night)` to `.standard` it remains in night style
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Xcode version: Version 16.4 (16F6)
- iOS version: iOS 26.0 (23A343)
- Devices affected: iPhone
- Maps SDK Version: 11.15.1
## Observed behavior and steps to reproduce
After setting MapStyle from `.standard(lightPreset: .night)` to `.standard` it remains in night style
```swift
...
init()
mapView.mapboxMap.mapStyle = .standard
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if previousTraitCollection?.hasDifferentColorAppearance(comparedTo: traitCollection) == true {
if traitCollection.userInterfaceStyle == .dark {
mapView.mapboxMap.mapStyle = .standard(lightPreset: .night)
} else {
mapView.mapboxMap.mapStyle = .standard
}
}
}
```
## Expected behavior
Map style is set to same "standard" as it was in init.
## Notes / preliminary analysis
This behaviour seems to stem from fact that in `.standard` lightPreset is nil which later causes it to be ignored in `MapStyleReconciler` as value to be changed.
https://github.com/mapbox/mapbox-maps-ios/blob/0c92cef511d5b17d1eced72e78308c68fc01675b/Sources/MapboxMaps/ContentBuilders/MapContent/MapStyleReconciler.swift#L119
Is this actually expected behaviour from `.standard` use? Or is it a bug?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Sources/MapboxMaps/ContentBuilders/MapContent/MapStyleReconciler.swift around line 119 and reproduce the transition from .standard(lightPreset: .night) to .standard using the issue's iOS example. Trace how a nil lightPreset is handled; done means the map returns to the standard style after the trait changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100