如何以编程方式选择地图引脚 [英] How to select a map pin programmatically

查看:150
本文介绍了如何以编程方式选择地图引脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很喜欢Maps Concept。



请查看附件一次。





当我点击pin我收到消息说欣赏你的笑容或任何文本.....现在我想要...当我们选择表视图时,我需要提出该引脚的消息(与该引脚的用户交互)...



我正在使用这个地图和引脚的代码。

   - (void)viewWillAppear:(BOOL )动画
{
[super viewWillAppear:YES];
customLocation.latitude = [casesobjc.latitude_string doubleValue];
customLocation.longitude = [casesobjc.longitude_string doubleValue];
MapViewAnnotation * newAnnotation = [[MapViewAnnotation alloc] initWithTitle:casesobjc.locationForMap_string andCoordinate:customLocation];
[mapView addAnnotation:newAnnotation];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation :( id< MKAnnotation>)注释{
MKPinAnnotationView * pin =(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@annotation_ID ];
if(pin == nil){
pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@annotation_ID];
} else {
pin.annotation = annotation;
}
pin.pinColor = MKPinAnnotationColorPurple;
pin.animatesDrop = YES;
pin.canShowCallout = YES;
返回针;
}

现在我将显示所有的针脚,如下所示。





如何做当我们点击表格视图时,我需要显示该引脚的标题,就像我们选择一个引脚时的显示方式一样?



感谢

解决方案

您要查找的方法是 selectAnnotation:



在您的 didSelectRowAtIndexPath 中,您必须找到与表格行相关联的注释。



pre $ [mapView selectAnnotation:foundAnnotation animated:

是]; 


I am new to Maps Concept.

Please find the attached image once.

when i click the "pin" i am getting message says "Admire your smile" or any text..... Now i want like... when we select the table view, i need to raise that message for that pin(with out user interaction for that pin)...

I am using below code for This maps and pins.

    -(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
customLocation.latitude=[casesobjc.latitude_string doubleValue];
        customLocation.longitude=[casesobjc.longitude_string doubleValue];
 MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:casesobjc.locationForMap_string andCoordinate:customLocation];
[mapView addAnnotation:newAnnotation];
}
- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id<MKAnnotation>) annotation {
 MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"annotation_ID"];
if (pin == nil) {
        pin = [[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"annotation_ID"];
    } else {
        pin.annotation = annotation;
    }
    pin.pinColor = MKPinAnnotationColorPurple;
    pin.animatesDrop = YES;
    pin.canShowCallout=YES;
return pin;
}

Now i will show all the pins once like below.

How to do When we click on table view i need to show the title for that pin like how we show when we select a pin?

Thanks in Advance

解决方案

The method that you are looking for is selectAnnotation:.

In your didSelectRowAtIndexPath, you have to find the annotation associated with the table row.

Once you find it, you can tell it, to select it by using:

[mapView selectAnnotation:foundAnnotation animated:YES];

这篇关于如何以编程方式选择地图引脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆