0

在我的应用程序中,我使用了 MKmapview,我想隐藏用户当前位置注释点,这是我的代码

 - (void)viewDidLoad
 {
  [super viewDidLoad];
  appDel=(AppDelegate *)[UIApplication sharedApplication].delegate;
  DatabaseController *dbObj=[[DatabaseController alloc] init];
  NSString *query=[NSString stringWithFormat:@"select * from petBoundarySettings where petId=%@",self.petID];
  NSMutableArray *alertSettingArray=[dbObj getPetAlertSerrings:query :[appDel getDBPath]];
 if([alertSettingArray count]>0){
    distance=[[[alertSettingArray objectAtIndex:0] objectForKey:@"distance"] integerValue];
 address=[[alertSettingArray objectAtIndex:0] objectForKey:@"address"];
 lat2=[[alertSettingArray objectAtIndex:0] objectForKey:@"lat"] ;
 lon2=[[alertSettingArray objectAtIndex:0] objectForKey:@"lang"] ;
}
UIImageView *imageNav = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"sml-cat_03.png"]];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:imageNav];
[imageNav release];
[dbObj release];
MKCoordinateSpan span;
span.latitudeDelta=.01;
span.longitudeDelta=.01;
MKCoordinateRegion region;
//distance=appDel.alertDistance;
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = nil;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
currentAnnotation=[[MyAnnotations alloc]init];
NSLog(@"GL%f",appDel.getlat);
NSLog(@"GN%f",appDel.getlon);
regionCoordinate.latitude =[lat2 floatValue];
regionCoordinate.longitude = [lon2 floatValue];
currentAnnotation.coordinate=regionCoordinate;
currentAnnotation.title=@"Boundary Location";
currentAnnotation.subtitle=appDel.address;
     region.center=CLLocationCoordinate2DMake(regionCoordinate.latitude,regionCoordinate.longitude);

region.span=span;
[_myMapView setRegion:region animated:YES];
[_myMapView regionThatFits:region];

region1=region;
petAnnotation=[[MyAnnotations alloc]init];
petCoordinate.latitude = +11.028549739;
petCoordinate.longitude = +76.89644586;
petAnnotation.coordinate=petCoordinate;
petAnnotation.title=@"My Pet Location";
petAnnotation.subtitle=@"Vadavalli";
MKCircle *circle = [MKCircle circleWithCenterCoordinate:regionCoordinate radius:distance];
[_myMapView addOverlay:circle];
CLLocation *whereIAm = [locationManager location];
NSLog(@"MI%@",whereIAm);
[_myMapView addAnnotation:currentAnnotation];
MKMapPoint p1 = MKMapPointForCoordinate(regionCoordinate);
MKMapPoint p2 = MKMapPointForCoordinate(petCoordinate);
CLLocationDistance dist = MKMetersBetweenMapPoints(p1, p2);
i=0;
[self getPetData];
timer= [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(getPetData) userInfo:nil repeats:YES];
if(appDel.checkGPS==NO)
{
    [self getPetDataFromGPS];
}
}

如何从 mkmapview 隐藏当前位置,请帮我整理一下。

4

1 回答 1

2

MKMapView有一个名为的属性showsUserLocation,您可以设置它来确定是否可以显示用户的位置。但是,我看到您没有在代码中设置它,默认值为 NO。

如果您使用的是 Xib 或 Storyboard,请MKMapView在其中选中,因为属性检查器中有一个用于此行为的复选框。(显示用户位置)

于 2013-04-10T16:25:00.690 回答