Contents

mapRectThatFits(_:)

Returns a centered map rectangle with the same aspect ratio as 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 to the view frame.

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.

Discussion

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

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