Move Already Added Annotation To NewLocation
I want to move added annotation to newlocation, below is the code and in
else part i want to do that :
In previous code, new annotation is added and previous annotation is
removed, but its get affected in degree of direction. So, i want to move
annotation with out adding new annotation.
- (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
}
}
}
No comments:
Post a Comment