ios - Displaying multiple annotations when location is updated using startUpdatingLocation -


my mapview showing number of userannotations when user location updating when user moving. want know how userannotaion displayed once when user location changed.

[self.mymapview removeannotation:userannotation]; not working

    -(void) viewdidload     {          [super viewdidload];      [locationmanager startupdatinglocation];      }          -(void) checklonglatitudeagain {         [locationmanager startupdatinglocation];     }         -(void)locationmanager:(cllocationmanager *)manager         didupdatetolocation:(cllocation *)newlocation                fromlocation:(cllocation *)oldlocation     {          userlat=self.lastlocation.coordinate.latitude;         userlong=self.lastlocation.coordinate.longitude;         cllocationcoordinate2d usercord =         {userlat, userlong};         pins *userannotation =         [[pins alloc] initwithcoordinate:usercord];         [userannotation settypeofannotation:cur_annotation];          if (newlocation.coordinate.latitude != self.lastlocation.coordinate.latitude &&             newlocation.coordinate.longitude != self.lastlocation.coordinate.longitude) {             [self.mymapview removeannotation:userannotation];             self.lastlocation = newlocation;              userlat=self.lastlocation.coordinate.latitude;             userlong=self.lastlocation.coordinate.longitude;             cllocationcoordinate2d usercord =             {userlat, userlong};             pins *userannotation =             [[pins alloc] initwithcoordinate:usercord];             [userannotation settypeofannotation:cur_annotation];              [self.mymapview addannotation:userannotation];      }      }         

make annotation global variable, , update coordinates in didupdatelocation:


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -