Waes Antoine
Waes Antoine

Reputation: 33

Multiple pins with multiple colors MKMapView

How can I show multiple colors for my pins ?

I have one pin with this function :

c1.latitude = 48.7258729;
c1.longitude =  4.5781534;
HistoryMarker* ad15 = [[HistoryMarker alloc] initWithCoordinate:c1 Title:@"Title" SubTitle:@"SubTitle"];

[mapView addAnnotation:ad15];
[ad15 release];"

and another one with the user's research

Good night ! (For me, I'm french guy =))

Upvotes: 0

Views: 1361

Answers (2)

msgambel
msgambel

Reputation: 7340

The MKPinAnnotationView can only be 1 of 3 colours, each with their own guidelines of what they should represent. If you want more, you'll have to implement your own.

Edit: To set the pin colour, you need only set the pin colour property:

pin.pinColor = MKPinAnnotationColorRed;
pin.pinColor = MKPinAnnotationColorGreen;
pin.pinColor = MKPinAnnotationColorPurple;

Hope that helps!

Upvotes: 0

Gavin
Gavin

Reputation: 2834

To set the pin color, make use of MKPinAnnotationView pinColor property.

For custom annotation image, set the MKAnnotationView image property, as such.

UIImage *annImage = [UIImage imageNamed:@"AnnotationIcon.png"];
annView.image = annImage;

Do note that the MKPinAnnotationView animateDrop property will not work on custom images. There's a way to duplicate that animation though. See How do I animate MKAnnotationView drop?

Upvotes: 1

Related Questions