<!--
{
  "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/MapContent/tag(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit",
      "SwiftUI",
      "_MapKit_SwiftUI"
    ],
    "preciseIdentifier" : "s:15_MapKit_SwiftUI0A7ContentPAAE3tagyQrqd__SHRd__lF"
  },
  "title" : "tag(_:)"
}
-->

# tag(_:)

Sets the unique tag value of this piece of map content.

```
@MainActor @preconcurrency func tag<V>(_ tag: V) -> some MapContent where V : Hashable
```

## Parameters

`tag`

A <doc://com.apple.documentation/documentation/Swift/Hashable>
value to use as the map content’s tag.

## Return Value

Map content with the specified tag set.

## Discussion

Use this modifier to differentiate between selectable content in the map. When the map’s
selection binding has the same value as the tag applied to a piece of map content, that content is
considered selected.

A `ForEach` automatically applies a default tag to each enumerated
view using the `id` parameter of the corresponding element. If
the element’s `id` parameter and the the map’s selection input have the same type, you can omit
the explicit tag modifier.

---

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)