У меня есть набор данных аннотаций, которые могут обновляться очень быстро. На данный момент я удаляю все аннотации перед тем, как перенести их обратно на карту.
NSArray *existingpoints = [mapView.annotations filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"!(self isKindOfClass: %@)", [MKUserLocation class]]];
[mapView removeAnnotations:existingpoints];
Я вычисляю, где они в любом случае находятся внутри настраиваемого объекта, поэтому хотел бы иметь возможность вызывать это и «перемещать» аннотацию без удаления и повторного добавления вернуться к карте. Пример вызова, который я делаю, который работает, и я хотел бы почти "опросить", приведен ниже.
- (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;
}
Как я просил, файл .h объекта, у меня нет метода SetCoordinate ..
#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