Explain Map() position

Hi,

Can someone explain how the Map() position should work?

struct ContentView: View {

@State private var position: MapCameraPosition = .userLocation(followsHeading: true, fallback: .automatic)

    var body: some View {
        Map(position: $position) {
            UserAnnotation()
        }
    }
}

I was expecting the map to zoom in to users location but it shows the map zoomed out to the max instead. Location is authorized. I've also added the location button.

.mapControls {
    MapUserLocationButton()
}

Pressing it zooms in to the user's location without issues.

Thanks!

Post not yet marked as solved Up vote post of macmac72 Down vote post of macmac72
1.1k views

Replies

It seems the behavior of fallback automatic.

After initial display, setting position programmatically has no effect -- I wrote a feedback on this bug.

In my app, tapping the user location button has no effect either, but I couldn't create a simple app to reproduce it.

  • Did you ever receive feedback on this bug submission. I ran into the same issue where map position cannot be updated programatically.

  • My app shows it's fixed in Xcode 15 beta 6.

Add a Comment