rson
rson

Reputation: 1465

Get info on a mapview selected annotation

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?

Upvotes: 2

Views: 6326

Answers (3)

Barrett
Barrett

Reputation: 1050

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]);

}

Upvotes: 2

cal
cal

Reputation: 470

This is how

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

Upvotes: 2

Vladimir
Vladimir

Reputation: 170849

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

Upvotes: 1

Related Questions