MapPolyline stroke gradient doesn't work

The code in this example to add a gradient to a map polyline from WWDC doesn't work.

https://developer.apple.com/videos/play/wwdc2023/10043/?time=1360

The polyline is rendered as a solid colour from as the first colour in the given array. Does anyone have any suggestions?

Code for convenience:

let coordinates = [
        CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194),
        CLLocationCoordinate2D(latitude: 37.3352, longitude: -122.0322),
        CLLocationCoordinate2D(latitude: 34.0522, longitude: -118.2437)
    ]

    let gradient = LinearGradient(colors: [.red, .green, .blue], startPoint: .leading, endPoint: .trailing)

    let stroke = StrokeStyle(lineWidth: 5, lineCap: .round, lineJoin: .round, dash: [10, 10])

    var body: some View {
        Map {
            MapPolyline(coordinates: coordinates)
                .stroke(gradient, style: stroke)
            
        }
    }

Replies

Any solution?