---
title: "exchangeOverlay(_:with:)"
framework: mapkit
role: symbol
role_heading: Instance Method
path: "mapkit/mkmapview/exchangeoverlay(_:with:)"
---

# exchangeOverlay(_:with:)

Exchanges the positions of two overlay objects.

## Declaration

```swift
func exchangeOverlay(_ overlay1: any MKOverlay, with overlay2: any MKOverlay)
```

## Parameters

- `overlay1`: The first overlay object.
- `overlay2`: The second overlay object.

## Discussion

Discussion If the overlays are in the same map level, they exchange positions within that level’s array of overlay objects. If they’re in different map levels, the two objects also swap levels. Swapping the position of the overlays affects their visibility in the map view.

## See Also

### Adding and inserting overlays

- [addOverlay(_:level:)](mapkit/mkmapview/addoverlay(_:level:).md)
- [addOverlays(_:level:)](mapkit/mkmapview/addoverlays(_:level:).md)
- [addOverlay(_:)](mapkit/mkmapview/addoverlay(_:).md)
- [addOverlays(_:)](mapkit/mkmapview/addoverlays(_:).md)
- [insertOverlay(_:at:level:)](mapkit/mkmapview/insertoverlay(_:at:level:).md)
- [insertOverlay(_:at:)](mapkit/mkmapview/insertoverlay(_:at:).md)
- [insertOverlay(_:above:)](mapkit/mkmapview/insertoverlay(_:above:).md)
- [insertOverlay(_:below:)](mapkit/mkmapview/insertoverlay(_:below:).md)
- [exchangeOverlay(at:withOverlayAt:)](mapkit/mkmapview/exchangeoverlay(at:withoverlayat:).md)
