views:

61

answers:

2

Hi there

Ok, so I've got some issues with my MapKit annotations.

First of all, I want a callout for each annotation. I can't find out how to do this at all! :( I have two NSStrings (name of the place and a short description). Then I need to be able to log the click on the callout - so I can launch a disclosure view.

Secondly I want to change the view for the user location annotation.

At the moment all annotations are set to the "default" pin annotation view by way of this code:

- (MKAnnotationView *) mapView:(MKMapView *)myMapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    annView.animatesDrop=TRUE;
    return annView;
}

I would prefer to have the user location annotation set to the default blue pulsing circle thing, but at least I want to be able to change the pinColor property to a different color, so the user can distinguish between their own location and the results of their search.

I hope somebody can help me.

Thank you.

+1  A: 

I think you should consider using showsUserLocation to depict your users location - it's the standard UI for the platform and helps people get a consistent experience across apps. Sure you can come up with some custom annotation for user location but why re-invent what people are used to seeing on the maps app and on many 3rd party apps?

You should take the time to review Apple's code samples for MapKit everything you need to do is there. This one in particular is a good starting point for you:

http://developer.apple.com/iphone/prerelease/library/samplecode/MapCallouts/Introduction/Intro.html

Nick
I *am* using showsUserLocation haha, but it changes the nice blue pulse to a pin... :/ I don't know why.
Thomas Clayson
You are using the reuse identifier for the currentlocation
Nick
right... how do I stop that? ie: how to I differentiate between the currentlocation annotation and the other annotations?
Thomas Clayson
reuseIdentifier:@"SomeOtherStringThatIsNotTheSameAsTheIdentifierBeingUsedByCurrentLocation"
Nick
hmm... the problem was i didn't know which annotation was the one being used by current location. Its ok - I've found it now. Something like `if(annotation == mapView.userlocation){ return nil; }` or similar. :) Thanks for your help though.
Thomas Clayson
A: 

hmm... the problem was i didn't know which annotation was the one being used by current location. Its ok - I've found it now. Something like if(annotation == mapView.userlocation){ return nil; } or similar. :) Thanks for your help though

Thomas Clayson