Iphone 将已添加的批注移动到新位置
我想将添加的注释移动到newlocation,下面是代码,在其他部分我想这样做: 在以前的代码中,添加了新注释,删除了以前的注释,但其方向会受到影响。因此,我想在不添加新注释的情况下移动注释Iphone 将已添加的批注移动到新位置,iphone,ios,mkmapview,mapkit,core-location,Iphone,Ios,Mkmapview,Mapkit,Core Location,我想将添加的注释移动到newlocation,下面是代码,在其他部分我想这样做: 在以前的代码中,添加了新注释,删除了以前的注释,但其方向会受到影响。因此,我想在不添加新注释的情况下移动注释 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if (newLoc
- (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
}
}
}
-(void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
{
if(newLocation.HorizontalAccurance<0)
返回;
如果(!newLocation)
返回;
静态布尔注释添加=否;
self.currentLocation=新位置;
self.previousLocation=旧位置;
if(self.currentLocation!=nil)
{
CLLocationCoordinate2D位置=CLLocationCoordinate2D标记(self.currentLocation.coordinate.latitude,self.currentLocation.coordinate.经度);
myAnnotation=[[myAnnotation alloc]initWithCoordinates:位置标题:@“当前位置”副标题:nil];
如果(!annotationAdded)
{
annotationAdded=是;
[self.myMapView addAnnotation:myAnnotation];
}
其他的
{
//在这里,我想将添加的注释移动到新位置坐标
}
}
}
它的工作方式是,向地图提供注释,然后它启动在屏幕上绘制注释的函数。一旦它出现在屏幕上,这基本上不是移动注释的方法,而是删除它并添加一个具有新坐标的新注释