我想将添加的注释移动到新位置,下面是代码,在其他部分我想这样做:
在以前的代码中,添加了新的注释并删除了以前的注释,但它在方向上受到了影响。所以,我想在不添加新注释的情况下移动注释。
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if (newLocation.horizontalAccuracy < 0)
return;
if (!newLocation)
return;
static BOOL annotationAdded = NO;
self.currentLocation = newLocation;
self.previousLocation = oldLocation;
if(self.currentLocation != nil)
{
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(self.currentLocation.coordinate.latitude, self.currentLocation.coordinate.longitude);
myAnnotation = [[MyAnnotation alloc] initWithCoordinates:location title:@"Current Location" subTitle:nil];
if (!annotationAdded)
{
annotationAdded = YES;
[self.myMapView addAnnotation:myAnnotation];
}
else
{
// Here i want to move added annotation to newlocation coordinates
}
}
}