Instance Method

mapRectThatFits(_:)

Adjusts the aspect ratio of the specified map rectangle to ensure that it fits in the map view’s frame.

Declaration

func mapRectThatFits(_ mapRect: MKMapRect) -> MKMapRect

Parameters

mapRect

The initial map rectangle whose width and height you want to adjust.

Return Value

A map rectangle that is still centered on the same point of the map but whose width and height are adjusted to fit in the map view’s frame.

Discussion

You can use this method to normalize map rectangle values before displaying the corresponding area. This method returns a new map rectangle that both contains the specified rectangle and fits neatly inside the map view’s frame.

See Also

Adjusting Map Regions and Rectangles

func regionThatFits(MKCoordinateRegion)

Adjusts the aspect ratio of the specified region to ensure that it fits in the map view’s frame.

func mapRectThatFits(MKMapRect, edgePadding: UIEdgeInsets)

Adjusts the aspect ratio of the specified map rectangle, incorporating the specified inset values.