mkmapview - ios: addAnnotations to mapView not working -


hi have nsmutablearray annotation objects follwoing code not add annotation:

in .h have

     @property (retain, nonatomic) marketsdatacontroller *marketlist; 

in .m have (adding annotations not work. nothing shows on map)

    _marketlist = [_marketservice.marketsdatacontroller retain];     nslog(@"%@!!!", [_marketlist objectinlistatindex:0].title);     [mapview addannotation:[_marketlist objectinlistatindex:0]];     [mapview addannotation:[_marketlist objectinlistatindex:1]];     [mapview addannotation:[_marketlist objectinlistatindex:2]]; 

marketslistdatacontroller looks this:

    #import "marketsdatacontroller.h"      //the following interface used private methods     @interface marketsdatacontroller ()     - (void)initializemarketslist;     @end      @implementation marketsdatacontroller      //set initial values instance variables     - (id)init {         nslog(@"init marketsdatacontroller");         if (self = [super init]) {             [self initializemarketslist];             return self;         }         return nil;     }      - (void)initializemarketslist{         nsmutablearray *marketslist = [[nsmutablearray alloc] init]; //initialize product list         _marketslist = marketslist;                      //set markets list markets list     }      //return number of products     - (nsuinteger)countoflist {         return [_marketslist count];     }      //return product within list     - (mapannotation *)objectinlistatindex:(nsuinteger)theindex {         return [_marketslist objectatindex:theindex];     }      - (void)addannotationtolist:(mapannotation *)mapannotation{         nslog(@"adding market");         [_marketslist addobject:mapannotation];     }      - (void)dealloc {         nslog(@"dealloc marketsdatacontroller");         [_marketslist release];         [super dealloc];      }      @end 

mapannotation .m looks like:

#import "mapannotation.h"  @implementation mapannotation  @synthesize coordinate, title, subtitle;  - (id)init{     cllocationcoordinate2d location;     location.latitude = 0;     location.longitude = 0;     return [self initwithcoordinate:coordinate title:nil subtitle:nil]; }  - (id)initwithcoordinate:(cllocationcoordinate2d) c title:(nsstring *)t subtitle:(nsstring *)st{     self = [super init];     coordinate = c;     title = [t retain];     subtitle = [st retain];     return self; }  - (void) dealloc{     [title release];     [subtitle release];     [super dealloc]; }  @end 

i create them , add them in class like:

if (![latitude isequal:[nsnull null]] && ![longitude isequal:[nsnull null]]) {                      nslog(@"%d", i);                     nslog(@"%@", title);                     cllocationcoordinate2d coordinate;                     coordinate.longitude = [latitude doublevalue];                     coordinate.longitude = [longitude doublevalue];                     [self buildmarketslist:coordinate title:title subtitle:@""]; //build browse list product                  } 

the method below:

- (void)buildmarketslist:(cllocationcoordinate2d)c title:(nsstring *)t subtitle:(nsstring *)st{     mapannotation *mapannotation = [[mapannotation alloc]initwithcoordinate:c title:t subtitle:st];     [_marketsdatacontroller addannotationtolist:mapannotation];     [mapannotation release]; }    

how can add array of annotation objects implement < mkannotation > ? no errors , no annotations show.

found problem:

change:

                coordinate.longitude = [latitude doublevalue];                 coordinate.longitude = [longitude doublevalue]; 

to:

                coordinate.latitude = [latitude doublevalue];                 coordinate.longitude = [longitude doublevalue]; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -