<!--
{
  "availability" : [
    "iOS: 27.2.0 -",
    "iPadOS: 27.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/locationHeadingAnchor(manager:isEnabled:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP014_CoreLocation_aB0E21locationHeadingAnchor7manager9isEnabledQrSo17CLLocationManagerC_SbtF"
  },
  "title" : "locationHeadingAnchor(manager:isEnabled:)"
}
-->

# locationHeadingAnchor(manager:isEnabled:)

Specifies this view as the reference body for the location manager’s
heading calculations.

```
nonisolated func locationHeadingAnchor(manager: CLLocationManager, isEnabled: Bool = true) -> some View
```

## Parameters

`manager`

The location manager to specify this view as the body of.

`isEnabled`

Whether this view should be the manager’s body.

## Discussion

```
@State private var locationManager = CLLocationManager()

var body: some View {
    MyView()
        .locationHeadingAnchor(manager: locationManager)
}
```

If more than one view specifies itself as the body of the same manager,
the most recent one to do so becomes the body. Once a view stops being
the body, whether because it disappeared or because `isEnabled` became
`false`, the manager has no body until some view specifies one again.

Use `isEnabled` to pick between views which are all on screen. For
example, a map might anchor headings to a puck, except while navigating,
when it anchors them to a vehicle icon instead:

```
ZStack {
    Puck()
        .locationHeadingAnchor(manager: locationManager,
                               isEnabled: !isNavigating)
    VehicleIcon()
        .locationHeadingAnchor(manager: locationManager,
                               isEnabled: isNavigating)
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)