0

我想将添加的注释移动到新位置,下面是代码,在其他部分我想这样做:

在以前的代码中,添加了新的注释并删除了以前的注释,但它在方向上受到了影响。所以,我想在不添加新注释的情况下移动注释。

- (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 

        }

    }
}
4

1 回答 1

0

它的工作方式是向地图提供注释,然后它会触发在屏幕上绘制注释的函数。一旦它出现在屏幕上,基本上没有办法移动注释,而是删除它并添加一个具有新坐标的新注释。

于 2013-09-20T03:34:06.053 回答