在我的应用程序中我使用了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隐藏当前位置,请帮我整理。
答案 0 :(得分:2)
MKMapView
有一个名为showsUserLocation
的属性,您可以设置该属性以确定是否可以显示用户的位置。但是,我发现您没有在代码中设置它,默认值为NO。
如果您使用的是Xib或Storyboard,请检查其中的MKMapView
,因为属性检查器中存在此行为的复选框。 (显示用户位置)