1

嗨,伙计们。如果你可以的话,我需要一些帮助。当我按下地图按钮时,我通过 CLLocation 属性加载了一个具有经度和纬度的对象。问题是,我不希望地图将区域/中心坐标设置为用户位置,我希望它在地图加载后进入注释区域,所以我这样做:

- (void)loadActiveEstateAnnotation
{
    RE_Annotation *re_annotation = [[RE_Annotation alloc] init];

     if(self.mapView.showsUserLocation == YES)
         NSLog(@"Santa Clause is comming to town");

    re_annotation.longitude = viewingEstate.estateLocation.coordinate.longitude;
    re_annotation.latitude = viewingEstate.estateLocation.coordinate.latitude;
    re_annotation.poiID = [[RE_Shared sharedInstance] selectedEstate];
    re_annotation.title = [NSString stringWithFormat:@"Estate %d",re_annotation.poiID];

    [self.mapView addAnnotation:re_annotation];

    CLLocationCoordinate2D activeAnnotationCoordonate;

    activeAnnotationCoordonate.longitude = re_annotation.longitude;
    activeAnnotationCoordonate.latitude = re_annotation.latitude;

    MKCoordinateSpan activeEstateSpan;

    activeEstateSpan.longitudeDelta = 0.05;
    activeEstateSpan.latitudeDelta = 0.05;


    MKCoordinateRegion activeEstateRegion;

    activeEstateRegion.center = activeAnnotationCoordonate;
    activeEstateRegion.span = activeEstateSpan;

    NSLog(@"----These are the coordinates%f,%f", activeAnnotationCoordonate.longitude, activeAnnotationCoordonate.latitude);   // coordinates are good and valid ive checked them

    [self.mapView setRegion:activeEstateRegion];
    [self.mapView regionThatFits:activeEstateRegion];
    [re_annotation autorelease];

}

所以底线地图视图出口不是设置区域,即使坐标也很好。但是,它确实接受了我给它的不同跨度,但它仍然始终锁定在用户区域;问题是……为什么?

4

1 回答 1

1

发生这种情况是因为您的CLLocationManager班级每次都更新位置,MKMapView所以在这里您更新的当前位置被设置为 MapView 的区域

为了停止这个,只需调用这个方法..

[yourLocationManager stopUpdatingLocation];

在你的loadActiveEstateAnnotation方法开始。

于 2012-12-05T08:57:15.917 回答