I have a data set of annotations that can update very quickly. At the moment I remove all annotations before replotting them back onto the map.
NSArray *existingpoints = [mapView.annotations filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"!(self isKindOfClass: %@)", [MKUserLocation class]]];
[mapView removeAnnotations:existingpoints];
I calculate where they are anyway within the custom object so would like to be able to call this and "move" the annotation without removing and re-adding it back to the map. The example call I make which works and I would like to almost "poll" is below.
- (CLLocationCoordinate2D) coordinate
{
CLLocationCoordinate2D coord;
coord.latitude = [lat doubleValue];
coord.longitude = [lon doubleValue];
double differencetime = exampleTime;
double speedmoving;
double distanceTravelled = speedmoving * differencetime;
CLLocationDistance movedDistance = distanceTravelled;
double radiansHeaded = DEG2RAD([self.heading doubleValue]);
CLLocation *newLocation = [passedLocation newLoc:movedDistance along:radiansHeaded];
coord = newLocation.coordinate;
return coord;
}
As requested, the .h file of the Object, I do not have a SetCoordinate method..
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface TestObject : NSObject <MKAnnotation>{
NSString *adshex;
NSString *lat;
NSString *lon;
NSString *title;
NSString *subtitle;
CLLocationCoordinate2D coordinate;
}
@property(nonatomic,retain)NSString *adshex;
@property(nonatomic,retain)NSString *lat;
@property(nonatomic,retain)NSString *lon;
@property(nonatomic,retain)NSString *title;
@property(nonatomic,retain)NSString *subtitle;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (CLLocationCoordinate2D) coordinate;
@end