Get info on a mapview selected annotation

青春壹個敷衍的年華 提交于 2019-12-20 03:22:17

问题


I have annotations on a mapview and a callout with a button on each. What I need to do is grab properties from this callout, ie. the title, but logging this line:

NSLog(@"%@", mapView.selectedAnnotations);

returns <AddressAnnotation: 0x1bdc60> which obviously gives me no useful info...

My question is, how can I access the properties of a selected annotation callout?


回答1:


This is how

 for (id annotation in mapView.annotations) {NSLog([annotation title]);}



回答2:


Here is what I did in the annotationviewClick function:

Hope this helps

-(IBAction) annotationViewClick:(id) sender{

    [self.view addSubview:LoadingView];
    Annotation *ann = [myMap.selectedAnnotations objectAtIndex:([myMap.selectedAnnotations count]-1)];


    NSLog(@"Selected:%@", [ann tag]);

}



回答3:


mapView.selectedAnnotations returns an array of anotations. You should access its items to get info.



来源:https://stackoverflow.com/questions/1722820/get-info-on-a-mapview-selected-annotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!