Tôi có một tập hợp các chú thích dữ liệu có thể cập nhật rất nhanh. Hiện tại, tôi xóa tất cả các chú thích trước khi thêm lại chúng vào bản đồ.MKMapView di chuyển chú thích Tự động - animate chúng?
NSArray *existingpoints = [mapView.annotations filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"!(self isKindOfClass: %@)", [MKUserLocation class]]];
[mapView removeAnnotations:existingpoints];
Tôi tính chúng ở đâu trong đối tượng tùy chỉnh để có thể gọi điều này và "di chuyển" chú thích mà không xóa và thêm lại nó vào bản đồ. Cuộc gọi ví dụ mà tôi thực hiện có tác dụng và tôi muốn gần như "cuộc thăm dò ý kiến" ở bên dưới.
- (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;
}
Theo yêu cầu, các tập tin .h của Object, tôi không có một phương pháp 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
Bạn có phương thức setCoordinate trong đối tượng chú thích của mình hay chỉ là phương thức phối hợp? Hiển thị tệp .h cho đối tượng chú thích của bạn. – Anna
Không, tôi không thêm, .h vào bản chỉnh sửa –