---
title: "mapView(_:viewFor:)"
framework: mapkit
role: symbol
role_heading: Instance Method
path: "mapkit/mkmapviewdelegate/mapview(_:viewfor:)-6j267"
---

# mapView(_:viewFor:)

Asks the delegate for the overlay view to use when displaying the specified overlay object.

## Declaration

```swift
optional func mapView(_ mapView: MKMapView, viewFor overlay: any MKOverlay) -> MKOverlayView
```

## Parameters

- `mapView`: The map view that requests the overlay view.
- `overlay`: The object representing the overlay that the map view is about to display.

## Return Value

Return Value The view to use when presenting the specified overlay on the map. If you return nil, no view  displays for the specified overlay object.

## See Also

### Methods

- [view(for:)](mapkit/mkmapview/view(for:)-38z60.md)
- [mapView(_:didAddOverlayViews:)](mapkit/mkmapviewdelegate/mapview(_:didaddoverlayviews:).md)
