如何处理多个引脚将下降在一个经度&;iphonesdk中的纬度?

如何处理多个引脚将下降在一个经度&;iphonesdk中的纬度?,iphone,mapkit,mkpinannotationview,Iphone,Mapkit,Mkpinannotationview,我有一项任务是使用map kit开发应用程序。 我从服务器获得多个pin,并且必须从用户当前位置删除一个pin。此用户当前位置pin应为绿色,来自服务器的其他pin应为其他颜色。我如何才能做到这一点 另一个问题是我得到了一些别针,因为纬度和经度有一些微小的差异。所以在一个特定的点上,在这个点上,引脚将被放置在另一个引脚上,我想给出一个按钮(在引脚弹出窗口上)哪个处理横向和纵向管脚的微小差异意味着按钮告诉下一个管脚&一旦按下按钮,弹出窗口应转到另一个尚未选择的管脚,并打开其弹出窗口,该窗口也告诉下

我有一项任务是使用map kit开发应用程序。
我从服务器获得多个pin,并且必须从用户当前位置删除一个pin。此用户当前位置pin应为绿色,来自服务器的其他pin应为其他颜色。我如何才能做到这一点

另一个问题是我得到了一些别针,因为纬度和经度有一些微小的差异。所以在一个特定的点上,在这个点上,引脚将被放置在另一个引脚上,我想给出一个按钮(在引脚弹出窗口上)哪个处理横向和纵向管脚的微小差异意味着按钮告诉下一个管脚&一旦按下按钮,弹出窗口应转到另一个尚未选择的管脚,并打开其弹出窗口,该窗口也告诉下一个管脚。我该怎么做

我使用这样的代码来创建pin

用于获取用户定位pin

        Place* current = [[[Place alloc] init] autorelease];
    current.name = @"You are here.";
    current.latitude = coordinate.latitude;
    current.longitude = coordinate.longitude;
    PlaceMark *from = [[[PlaceMark alloc] initWithPlace:current] autorelease];              
    [mapView addAnnotation:from];
用于获取服务器位置pin

    int s=1;
    for (j=0 ; j < i - 1   ; j++) 
    {
        //points = [[NSString alloc] initWithFormat:@"point%d",s];
        reports = [NSArray arrayWithArray:lat];
        NSString *titles = [[NSString alloc] initWithFormat:@"%@",[tit objectAtIndex:j]];
        NSString *description = [[NSString alloc] initWithFormat:@"%@",[des objectAtIndex:j]];
        float latitude=[[lat objectAtIndex:j] floatValue];
        float longitude=[[lon objectAtIndex:j] floatValue];
        Place* home = [[[Place alloc] init] autorelease];
        home.name = [NSString stringWithFormat:@"%@",titles];
        home.description = [NSString stringWithFormat:@"%@",description];
        home.latitude = latitude;
        home.longitude = longitude;
        PlaceMark *from = [[[PlaceMark alloc] initWithPlace:home] autorelease];             [mapView addAnnotation:from];
        s++;
        [self centerMap];
    }

我的所有代码都正常工作。我只想回答上述问题。请帮我回答您的第一个问题:

首先找到您的当前位置引用所有注释,但使用以下代码执行此操作

#pragma mark -
#pragma mark Location Manager functions

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{   NSLog(@"Inside Location Delegate"); 
/*NSString *val=[[NSString alloc] initWithFormat:@"Previous Location is:\n Lattitude : %f\n Longitude : %f \n\n Current location is :\n Lattitude : %f\n Longitude : %f",oldLocation.coordinate.latitude, oldLocation.coordinate.longitude,newLocation.coordinate.latitude, newLocation.coordinate.longitude];
NSLog(@"%@",val);*/
[self setMapCenter:newLocation.coordinate];

PlaceMark *addAnnotation = [[[PlaceMark alloc] initWithCoordinate:newLocation.coordinate] retain];
[addAnnotation setTitle:@"Your Location"];
[addAnnotation setSubTitle:@""];        
[self._mapView addAnnotation:addAnnotation];
userAnnoFlag = TRUE;

[self._mapView selectAnnotation:[[self._mapView annotations] lastObject] animated:YES];

[self.locationManager stopUpdatingLocation];
}
然后使用以下方法设置管脚:

#pragma mark -
#pragma mark Annotations Functions

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
@try {
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MyPin"];  
    annView.animatesDrop=FALSE;
    annView.canShowCallout = YES;
    [annView setSelected:YES];
    if (userAnnoFlag == TRUE){
        annView.pinColor = MKPinAnnotationColorRed;
        userAnnoFlag = FALSE;
    }
    if ([mapView userLocation]) {
        annView.pinColor = MKPinAnnotationColorRed;
    }
    else{
        annView.pinColor = MKPinAnnotationColorGreen;
    }   
    annView.calloutOffset = CGPointMake(-5, 5); 
    return annView;
}
@catch (NSException * e) {      
}
@finally {      
}
return 0;
}
#pragma标记-
#pragma标记注释函数
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
@试一试{
MKPinAnnotationView*annView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:@“MyPin”];
annView.animatesDrop=FALSE;
annView.canShowCallout=是;
[选择:是];
if(userAnnoFlag==TRUE){
annView.pinColor=MKPinAnnotationColorRed;
userAnnoFlag=FALSE;
}
如果([mapView用户位置]){
annView.pinColor=MKPinAnnotationColorRed;
}
否则{
annView.pinColor=MKPinAnnotationColorGreen;
}   
annView.calloutOffset=CGPointMake(-5,5);
返回视图;
}
@捕获(n例外*e){
}
@最后{
}
返回0;
}

对于第二个问题,您最好手动检查纬度和经度之间的差异,如果差异足够大(根据您的要求),则通过检查。

回答第一个问题:

首先找到您的当前位置引用所有注释,但使用以下代码执行此操作

#pragma mark -
#pragma mark Location Manager functions

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{   NSLog(@"Inside Location Delegate"); 
/*NSString *val=[[NSString alloc] initWithFormat:@"Previous Location is:\n Lattitude : %f\n Longitude : %f \n\n Current location is :\n Lattitude : %f\n Longitude : %f",oldLocation.coordinate.latitude, oldLocation.coordinate.longitude,newLocation.coordinate.latitude, newLocation.coordinate.longitude];
NSLog(@"%@",val);*/
[self setMapCenter:newLocation.coordinate];

PlaceMark *addAnnotation = [[[PlaceMark alloc] initWithCoordinate:newLocation.coordinate] retain];
[addAnnotation setTitle:@"Your Location"];
[addAnnotation setSubTitle:@""];        
[self._mapView addAnnotation:addAnnotation];
userAnnoFlag = TRUE;

[self._mapView selectAnnotation:[[self._mapView annotations] lastObject] animated:YES];

[self.locationManager stopUpdatingLocation];
}
然后使用以下方法设置管脚:

#pragma mark -
#pragma mark Annotations Functions

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
@try {
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MyPin"];  
    annView.animatesDrop=FALSE;
    annView.canShowCallout = YES;
    [annView setSelected:YES];
    if (userAnnoFlag == TRUE){
        annView.pinColor = MKPinAnnotationColorRed;
        userAnnoFlag = FALSE;
    }
    if ([mapView userLocation]) {
        annView.pinColor = MKPinAnnotationColorRed;
    }
    else{
        annView.pinColor = MKPinAnnotationColorGreen;
    }   
    annView.calloutOffset = CGPointMake(-5, 5); 
    return annView;
}
@catch (NSException * e) {      
}
@finally {      
}
return 0;
}
#pragma标记-
#pragma标记注释函数
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
@试一试{
MKPinAnnotationView*annView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:@“MyPin”];
annView.animatesDrop=FALSE;
annView.canShowCallout=是;
[选择:是];
if(userAnnoFlag==TRUE){
annView.pinColor=MKPinAnnotationColorRed;
userAnnoFlag=FALSE;
}
如果([mapView用户位置]){
annView.pinColor=MKPinAnnotationColorRed;
}
否则{
annView.pinColor=MKPinAnnotationColorGreen;
}   
annView.calloutOffset=CGPointMake(-5,5);
返回视图;
}
@捕获(n例外*e){
}
@最后{
}
返回0;
}

对于第二个问题,您最好手动检查纬度和经度之间的差异,如果差异足够大(根据您的要求),请将其传递。

我使用了userAnnoFlag(BOOL),但它不能正常工作,它只会更改从服务器端获取的pin颜色。我的意思是我不能正确理解你的代码。请指导我。我所做的是基本编程,因为我检索我的当前位置,并将标志设置为TRUE,然后从此方法调用add annotation methode。我使用了userAnnoFlag(BOOL),但它不能正常工作,它只会更改从服务器端获取的pin颜色。我的意思是我不能正确理解你的代码。请指导我。我所做的是基本的编程,因为我检索我的当前位置,并将标志设置为TRUE,然后从这个方法中调用addannotation methode。