缩放MKMapView以适合折线点 [英] Zoom MKMapView to fit polyline points

查看:133
本文介绍了缩放MKMapView以适合折线点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组allCollections,它包含用户通过我的iOS应用程序记录的以编程方式创建的CLLocations数组。 allCollections中的每个子数组都包含行程中的所有位置点。

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 all the location points in a trip taken.

我从allCollections中的数组中的CLLocations中绘制MKPolylines,以表示MKMapView上的这些行程。我的问题是:将折线添加到地图中,我将如何以编程方式缩放和居中地图以显示所有这些?

I draw MKPolylines off of the CLLocations in the arrays in allCollections to represent those trips on an MKMapView. My question is this: With the polylines added to the map, how would I go about programmatically zooming and centering the map to display all of them?

推荐答案

-(void)zoomToPolyLine: (MKMapView*)map polyline: (MKPolyline*)polyline animated: (BOOL)animated
{
    [map setVisibleMapRect:[polyline boundingMapRect] edgePadding:UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0) animated:animated];
}

这篇关于缩放MKMapView以适合折线点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆