0
您好我已经设置我的MapKit向上显示用户的位置,但它加载的视图太过于缩小,所以我试图放大它,例如, 20英里的面积。 我试图用其他一些问题的代码来做到这一点,但他们都没有对视图做出任何改变。 顺便说一句我也试图能够看到当前用户:纬度和经度,但只看到0在我的浮动变量,也许这些链接?ios放大用户位置
下面是代码:
- (void)viewDidLoad
{
#ifdef __IPHONE_8_0
if(IS_OS_8_OR_LATER)
{
[self.locationManager requestWhenInUseAuthorization];
}
#endif
MKCoordinateSpan span = MKCoordinateSpanMake(20.5982f,0.0001f);
CLLocationCoordinate2D coordinate = {30, 75};
MKCoordinateRegion region = {coordinate, span};
MKCoordinateRegion regionThatFits = [self.mapView regionThatFits:region];
[self.mapView setRegion:regionThatFits animated:YES];
self.locationManager.delegate=self;
[self.locationManager startUpdatingLocation];
float latitude = self.locationManager.location.coordinate.latitude;
float longitude = self.locationManager.location.coordinate.longitude;
[self.mapView.userLocation addObserver:self
forKeyPath:@"location"
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
context:NULL];
self.mapView.showsUserLocation = YES;
非常感谢您的帮助,您可以用这个给。我是MapKit的新手。的
可能重复的[变焦的MKMapView上viewDidLoad中的用户的位置?(http://stackoverflow.com/questions/6063970/mkmapview-zoom-to-users-location-on-viewdidload) –
@Anbu。 Karthik谢谢你的指针,但是这并没有解决问题 – Kitcc
然后wat发生了,你还需要什么 –