Pergunta

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.

Foi útil?

Solução

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;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top