Convert MKCoordinateRegion to MKMapRect

前端 未结 10 692
南笙
南笙 2020-12-02 10:52

I have a square MKMapView in my app, and I wish to set a center point and the exact height/width of the view in meters.

Creating an MKCoordinateRegion and setting th

10条回答
  •  余生分开走
    2020-12-02 11:02

    you can use method to convert MKCoordinateRegion to CGRect

    - (CGRect)convertRegion:(MKCoordinateRegion)region toRectToView:(UIView *)view
    

    and use - (MKMapRect)mapRectForRect:(CGRect)rect

    or use MKMapPointForCoordinate method to first convert coordinates to MKPoint and use that to form MKMapRect to eventually use setVisibleMapRect:animated:

提交回复
热议问题