---
title: "mapRectThatFits(_:edgePadding:)"
framework: mapkit
role: symbol
role_heading: Instance Method
path: "mapkit/mkmapview/maprectthatfits(_:edgepadding:)"
---

# mapRectThatFits(_:edgePadding:)

Returns a centered, inset map rectangle with the same aspect ratio as the map view’s frame.

## Declaration

```swift
func mapRectThatFits(_ mapRect: MKMapRect, edgePadding insets: UIEdgeInsets) -> MKMapRect
```

```swift
func mapRectThatFits(_ mapRect: MKMapRect, edgePadding insets: NSEdgeInsets) -> MKMapRect
```

## Parameters

- `mapRect`: The initial map rectangle with the width and height you want to adjust.
- `insets`: The distance (in screen points) by which to inset the returned rectangle from the actual boundaries of the map view’s frame.

## Return Value

Return Value MapKit centers the map rectangle on the same point of the map, and adjusts the width and height to fit in the map view’s frame, minus its inset values.

## See Also

### Adjusting map regions and rectangles

- [regionThatFits(_:)](mapkit/mkmapview/regionthatfits(_:).md)
- [mapRectThatFits(_:)](mapkit/mkmapview/maprectthatfits(_:).md)
