ForEachStore with MapKit's MapView Annotation. #1805
Unanswered
ratnesh-jain
asked this question in
Q&A
Replies: 1 comment
-
Here is the single scope solution I considered for this. Map(coordinateRegion: viewStore.binding(\.$coordinateRegion).convertToMapKit(), annotationItems: viewStore.locations) { location in
MapAnnotation(coordinate: .init(latitude: location.latitude, longitude: location.longitude)) {
NavigationLink {
let detailStore = store.scope { state in
return state.locationDetails[id: location.id]!
} action: { detailAction in
return .locationDetailAction(location.id, detailAction)
}
LocationDetailsView(store: detailStore)
} label: {
PinAnnoationView()
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Thanks for this architecture. I really like the way library encourages the feature development with isolation and composing together to develop the as whole.
I am opening this discussion to discuss the approach working with MapKit's MapView with the MKAnnotations with ForEachStore reducer for navigating to particular annotation details.
Here is the code snippet that I have implemented.
Now when I try to implement the SwiftUI View as below.
Problem:
In the above implementation, this code will compile but will create multiple instances ofLocationDetailsView
due to multiple items in locationDetails array.If I move theForEachStore
at the level aboveNavigationLink
link, this will cause thePinAnnotationView
to render duplicates.If I move theForEachStore
at the level aboveMapAnnotation
, this will refuse to compile since the MapAnnotation does not conforms toSwiftUI.View
protocol.I am not sure what should be the workaround for this or I am missing something or any other techniques I can implement.
EDIT:
Thanks.
Ratnesh.
Beta Was this translation helpful? Give feedback.
All reactions