<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKit",
  "identifier" : "/documentation/MapKit/MapUserLocationButton",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "MapKit",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:15_MapKit_SwiftUI0A18UserLocationButtonV"
  },
  "title" : "MapUserLocationButton"
}
-->

# MapUserLocationButton

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

```
@MainActor @preconcurrency struct MapUserLocationButton
```

## Overview

Use `MapUserLocationButton` in conjunction with [`Map`](/documentation/MapKit/Map) as a stand alone view, as shown in this example:

```swift
    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 <doc://com.apple.documentation/documentation/SwiftUI/View/mapControls(_:)> modifier as shown in this example:

```swift
    Map()
        .mapControls {
            MapUserLocationButton()
        }
```

## Topics

### Creating a map user location button

[`init(scope:)`](/documentation/MapKit/MapUserLocationButton/init(scope:))

Creates a new user location button with the scope you specify.

### Managing map control sizing and visibility

  <doc://com.apple.documentation/documentation/SwiftUI/View/mapControlVisibility(_:)>

  <doc://com.apple.documentation/documentation/SwiftUI/View/mapControls(_:)>

  <doc://com.apple.documentation/documentation/SwiftUI/View/controlSize(_:)>

### Setting the namespace Identifier

  <doc://com.apple.documentation/documentation/SwiftUI/View/mapScope(_:)>

### Setting the tint and border shape

  <doc://com.apple.documentation/documentation/SwiftUI/View/buttonBorderShape(_:)>

[`tint(_:)`](/documentation/MapKit/MapContent/tint(_:))

The tint shape style to apply to map content.



---

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)