Post

Replies

Boosts

Views

Activity

ForEach loop in a Map doesn't work
Hi all, here's a tiny litte demo app import SwiftUI import MapKit struct MarkerData: Identifiable { var id = UUID() var coordinate: CLLocationCoordinate2D } struct MapView2: View { @State private var markers: [MarkerData] = [] var body: some View { ForEach(markers) { marker in Text("\(marker.coordinate)") } Map { ForEach(markers) { marker in MapMarker(coordinate: marker.coordinate) } } } } The ForEach loop inside the Map gives the error: "Generic parameter 'V' could not be inferred" The one above seems to be fine. What is wrong with the loop inside the map? (I'm working with XCode Version 16.2) Best!
4
0
451
Mar ’25
ForEach loop in a Map doesn't work
Hi all, here's a tiny litte demo app import SwiftUI import MapKit struct MarkerData: Identifiable { var id = UUID() var coordinate: CLLocationCoordinate2D } struct MapView2: View { @State private var markers: [MarkerData] = [] var body: some View { ForEach(markers) { marker in Text("\(marker.coordinate)") } Map { ForEach(markers) { marker in MapMarker(coordinate: marker.coordinate) } } } } The ForEach loop inside the Map gives the error: "Generic parameter 'V' could not be inferred" The one above seems to be fine. What is wrong with the loop inside the map? (I'm working with XCode Version 16.2) Best!
Replies
4
Boosts
0
Views
451
Activity
Mar ’25