Zoom MKMapView to fit polyline points

后端 未结 8 1238
小蘑菇
小蘑菇 2020-12-05 04:39

I have an array, allCollections, that holds programmatically-created arrays of CLLocations the user has recorded through my iOS app. Each sub-array in allCollections holds a

8条回答
  •  长情又很酷
    2020-12-05 05:07

    You could loop through all CLLocations recording the max/min coordinates and use that to set a view rect like they do on this question iOS MKMapView zoom to show all markers .

    Or you could go through each of your overlays and get their boundingMapRect then use MKMapRectUnion (http://developer.apple.com/library/ios/documentation/MapKit/Reference/MapKitFunctionsReference/Reference/reference.html#//apple_ref/c/func/MKMapRectUnion) to combine them all until you have one MKMapRect that covers them all and use that to set the view.

    [mapView setVisibleMapRect:zoomRect animated:YES]
    

    This question shows a simple loop combining the maprects in unions as I suggested: MKMapRect zooms too much

提交回复
热议问题