相关疑难解决方法(0)

定位MKMapView以一次显示多个注释

我有几个注释想要添加到我的MKMapView(它可以是0-n项,其中n通常是5左右).我可以添加注释,但我想调整地图大小以适应屏幕上的所有注释,我不知道如何做到这一点.

我一直在看,-regionThatFits:但我不太清楚如何处理它.我会发布一些代码来展示我到目前为止所拥有的内容.我认为这应该是一个通常很简单的任务,但到目前为止我对MapKit感到有些不知所措.

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{

location = newLocation.coordinate;
//One location is obtained.. just zoom to that location

MKCoordinateRegion region;
region.center = location;

//Set Zoom level using Span
MKCoordinateSpan span;
span.latitudeDelta = 0.015;
span.longitudeDelta = 0.015;
region.span = span;
// Set the region here... but I want this to be a dynamic size
// Obviously this should be set after I've added my annotations
[mapView setRegion:region animated:YES];

// Test data, using these as annotations for …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c mapkit ios

91
推荐指数
11
解决办法
8万
查看次数

标签 统计

cocoa-touch ×1

ios ×1

iphone ×1

mapkit ×1

objective-c ×1