Skip to content

After setting MapStyle from .standard(lightPreset: .night) to .standard it remains in night style #2372

@alvar-bolt

Description

@alvar-bolt

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

...
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.

Is this actually expected behaviour from .standard use? Or is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something is broken!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions