mapbox / mapbox/mapbox-maps-swiftui-demo
@EnvironmentObject instead of @State not working
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 29
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
I tried to use an @EnvironmentObject as Binding. It inits the map with given annotation but when the @EnvironmentObject is updated MapBox will not update the annotations.
`struct ContentView: View {
@EnvironmentObject var annotationVM: AnnotationsVM
var body: some View {
MapView(annotationsX: $annotationVM.allAnnotations).centerCoordinate(.init(latitude: 37.791293, longitude: -122.396324)).zoomLevel(16)
}
}`
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 at the ContentView example, tracing the MapView call and the AnnotationsVM.allAnnotations binding to determine why later environment-object updates do not reach the annotations. Done means MapView reflects changes to the environment object's annotations after initialization; no test file is identified in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100