MKMapRect zooms too much

后端 未结 5 1827
悲哀的现实
悲哀的现实 2021-01-14 11:32

I use this code to show all my annotations on my map:

 MKMapRect zoomRect = MKMapRectNull;
        for (id  annotation in mapView.annotat         


        
5条回答
  •  天命终不由人
    2021-01-14 11:49

    For those of us who like one liners:

    let minRectSize: Double = 5000
    zoomRect = MKMapRect(
        x: zoomRect.minX - max(0, minRectSize - zoomRect.width) / 2,
        y: zoomRect.minY - max(0, minRectSize - zoomRect.height) / 2,
        width: max(zoomRect.width, minRectSize),
        height: max(zoomRect.height, minRectSize))
    

提交回复
热议问题