Question

In my app i have n arrays of annotations in my app, foodannotations, gasannotations, and shoppingannotations. I want each array of annotations to show a different colored pin. I am currently using.

Was it helpful?

Solution

Already a discussion was been done regarding this. Please search question if it is already available before you ask. Thanks.

Pls refer the following links:

iPhone SDK: MapKit multiple custom annotations

Multiple Arrays of Annotations, Different Pin Color for Each Array?

Do this in viewForAnnotation:

int annType = ((YourAnnotationClass *)annotation).annotationType;
switch (annType)
{
    case 0 :   //Food
        pinview.pinColor = MKPinAnnotationColorRed;
    case 1 :   //Gas
        pinview.pinColor = MKPinAnnotationColorGreen;
    default :  //default or Shopping
        pinview.pinColor = MKPinAnnotationColorPurple;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top