Tôi đã tải hình ảnh chú thích tùy chỉnh cho vị trí hiện tại của người dùng. Tôi đang cập nhật vị trí người dùng hiện tại sau mỗi 1 giây ở chế độ nền.Chuyển động trơn tru của hình ảnh chú thích trên Mapview
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self performSelectorOnMainThread:@selector(tempupdate) withObject:nil waitUntilDone:NO];
[pool release];
-(void)tempupdate
{
NSLog(@"callToLocationManager");
mylocationManager = [[CLLocationManager alloc]init];
NSLog(@"locationManagerM = %@",mylocationManager);
mylocationManager.delegate = self;
mylocationManager.desiredAccuracy = kCLLocationAccuracyBest;
mylocationManager.distanceFilter = 500;
[mylocationManager startUpdatingLocation];
}
Sau khi cập nhật các latutude hiện tại và kinh độ tôi đang làm mới bản đồ sử dụng đoạn mã sau
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.002;
span.longitudeDelta=0.002;
CLLocationCoordinate2D location;
location.latitude=[lat doubleValue];
location.longitude=[longt doubleValue];
region.span=span;
region.center=location;
addAnnotation=[[AddressAnnotation alloc]initWithCoordinate:location];
[email protected]"You are here";
[self.mapView removeAnnotations:self.mapView.annotations];
[self.mapView addAnnotation:addAnnotation];
[self.mapView setRegion:region animated:TRUE];
[self.mapView regionThatFits:region];
Nhưng mỗi lần nhấp nháy hình ảnh tùy chỉnh chú thích trước khi thêm vào map.How để tránh hiệu ứng nhấp nháy này?
tôi biết vấn đề nằm trong việc loại bỏ và thêm chú thích trên bản đồ xem nhưng là có cách nào khác để làm điều này? Bạn có thể vui lòng cho tôi biết chi tiết những gì tôi nên làm gì? –
Đã chỉnh sửa câu trả lời của tôi với mã mẫu – MobileVet
Cảm ơn bạn đã trả lời. Nhưng nó không hoạt động. Vẫn cho tôi nhảy như hiệu ứng. –