我有一组可以很快更新的注释数据。目前,我删除了所有注释,然后将它们重新绘制回地图上。
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