Contents

MapUserLocationButton

A button that sets the framing of the associated map to the user location.

Declaration

@MainActor @preconcurrency struct MapUserLocationButton

Overview

Use MapUserLocationButton in conjunction with Map as a stand alone view, as shown in this example:

    struct LocationButtonTestView: View {
        @Namespace var mapScope
        var body: some View {
            VStack {
                Map(scope: mapScope)
                MapUserLocationButton(scope: mapScope)
            }
            .mapScope(mapScope)
        }
    }

You can also use MapUserLocationButton in conjunction with the Map/mapControls(_:) modifier as shown in this example:

    Map()
        .mapControls {
            MapUserLocationButton()
        }

Topics

Creating a map user location button

See Also

Map controls