Contents

MapCompass

A view that reflects the current orientation of the associated map.

Declaration

@MainActor @preconcurrency struct MapCompass

Overview

You can use MapCompass with a Map as a stand alone view, as shown in the following example:

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

You can also use MapCompass with the Map/mapControls(_:), modifier, as shown below:

    Map()
        .mapControls {
            MapCompass()
        }

Tapping the compass reorients the map so that North is at the top of the Map view.

Topics

Creating a map compass

See Also

Map controls