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 annotations to reflect their coordinates?
- (void)updateUnits {
PFQuery *query = [PFQuery queryWithClassName:@"devices"];
[query whereKeyExists:@"location"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *row in objects) {
PFGeoPoint *geoPoint = [row objectForKey:@"location"];
CLLocationCoordinate2D coord = { geoPoint.latitude, geoPoint.longitude };
for (id<MKAnnotation> ann in mapView.annotations) {
if ([ann.title isEqualToString:[row objectForKey:@"deviceid"]]) {
[ann setCoordinate:coord];
NSLog(@"latitude is: %f" , coord.latitude);
NSLog(@"Is called");
break;
}
else {
//[self.mapView removeAnnotation:ann];
}
}
}
}
else {
}
}];
}