I have a mapview where the annotation\'s coordinates are constantly being updated but when I use setCoordinate, the annotation does not move. How do I refresh the annotation
Try using [self.mapView removeAnnotations:self.mapView.annotations]
:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.mapView removeAnnotations:self.mapView.annotations];
PFQuery *query = [PFQuery queryWithClassName:@"caches"];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error)
{
for (PFObject *comment in comments)
{
NSString *tit = comment[@"titulo"];
NSString *lat = comment[@"latitud"];
NSString *lon = comment[@"longitud"];
float latFloat = [lat floatValue];
float lonFloat = [lon floatValue];
CLLocationCoordinate2D Pin;
Pin.latitude = latFloat;
Pin.longitude = lonFloat;
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc]init];
annotationPoint.coordinate = Pin;
annotationPoint.title = tit;
[self.mapView addAnnotation:annotationPoint];
}
}];
}