让注释适合我的MKMapView?

时间:2013-09-11 03:30:39

标签: iphone

首先,谢谢你,接下来,这是我的问题,核心代码:

for(int idx = 0; idx < route0.polyLine.count; idx++)
{
    CLLocationCoordinate2D coordinate = [[route0.polyLine objectAtIndex:idx] coordinate];
    minLat = MIN(minLat, coordinate.latitude);
    minLon = MIN(minLon, coordinate.longitude);
    maxLat = MAX(maxLat, coordinate.latitude);
    maxLon = MAX(maxLon, coordinate.longitude);
}

MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 1.06f*(maxLat - minLat);
span.longitudeDelta = 1.06f*(maxLon - minLon);
CLLocationCoordinate2D location;
location.latitude = (minLat + maxLat)/2;
location.longitude = (minLon + maxLon)/2;
region.span=span;
region.center=location;
[_mapView regionThatFits:region];  
[_mapView setRegion:region animated:false];

我的注意力是让mapview上的注释适合屏幕,但如果注释太近,则会出现:  enter image description here

0 个答案:

没有答案