我使用MKMapView来显示我当前的位置,我发现当我什么都不做的时候,我需要大约15秒才能看到蓝色圆圈并指向地图视图,但是如果我移动地图后地图视图开始定位,蓝色圆圈和点将立即显示(现在不需要5秒),它们之间的差异是什么?我可以缩短编码时显示蓝圈的时间吗?非常感谢
我创建了地图
self.runMapView = [[[MKMapView alloc] initWithFrame:self.bounds] autorelease];
self.runMapView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
self.runMapView.showsUserLocation = YES;
runMapView.delegate = self;
然后:
- (void)mapView:(MKMapView *)mapView_ didUpdateUserLocation:(MKUserLocation *)userLocation
{
if (loc2 == nil)//loc 2 is the ivar i used to track my first location
{
if (CLLocationCoordinate2DIsValid(userLocation.location.coordinate))
{
self.loc2 = userLocation.location;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 2000, 2000);
[runMapView setRegion:region];
}
}
}
我向地图添加了一些polylineview,当我在开始时将mapview添加到视图ctrl的视图时,mapview的alpha设置为0(因为我有一个按钮来决定显示或隐藏mapview) ,我不知道后面的地图更新位置是否会导致此问题?
答案 0 :(得分:0)
为位置管理器创建一个变量, 您需要更新mapview下方的位置,如下所示:
self.runMapView = [[[MKMapView alloc] initWithFrame:self.bounds] autorelease];
self.runMapView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
self.runMapView.showsUserLocation = YES;
self.runMapView.delegate = self;
[self.locationManager startUpdatingLocation];