ios - Plot two different color of mapview pin -


i'm trying display mapview array of coordinates. so, load latitudes , longitudes array contains. showing perfectly. now, want display 1 paritcular latitude & longitude different color pin. i've referred this answer no such different can't see.

viewcontroller.m


-(void)showmap: { ... ... dataprovider *d = [dataprovider getinstance]; nsinteger numb = sender.view.tag; d.colorlatitude = [[arraxy objectatindex:numb] objectforkey:@"lat"]; d.colorlongitude = [[arraxy objectatindex:numb] objectforkey:@"lng"]; [d._address removeallobjects]; [arraxy removeobjectatindex:sender.view.tag]; d._address = arraxy;  mapviewcontroller *map = [[mapviewcontroller alloc]initwithnibname:@"mapviewcontroller" bundle:nil]; [self.navigationcontroller pushviewcontroller:map animated:yes];  } 

mapviewcontroller.m


-(void)viewwillappear:(bool)animated { dataprovider *d = [dataprovider getinstance]; [_mapview removeannotations:_mapview.annotations];  registerviewcontroller *appdelegate = [[registerviewcontroller alloc]init];  [_mapview setshowsuserlocation:yes]; [_mapview setregion:mkcoordinateregionmakewithdistance([appdelegate.locationmanager location].coordinate, 1000, 1000)]; [_mapview setusertrackingmode:mkusertrackingmodenone];  mkcoordinateregion rregion = {{0.0,0.0},{0.0,0.0}}; rregion.center.latitude = [d.colorlatitude floatvalue]; rregion.center.longitude = [d.colorlongitude floatvalue]; rregion.span.latitudedelta=0.001f; rregion.span.longitudedelta=0.001f; [_mapview setregion:rregion];  mapviewannotations *add = [[mapviewannotations alloc]init]; add.coordinate = rregion.center; [_mapview addannotation:add];   if (d._address) {     (int i=0; i<[d._address count]; i++)     {         nsdictionary *dic=[d._address objectatindex:i];         mkcoordinateregion region={{0.0,0.0},{0.0,0.0}};         region.center.latitude=[[dic objectforkey:@"lat"]floatvalue];         region.center.longitude=[[dic objectforkey:@"lng"]floatvalue];         region.span.latitudedelta=0.001f;         region.span.longitudedelta=0.001f;         [_mapview setregion:region];          mapviewannotations *ann=[[mapviewannotations alloc]init];         ann.coordinate=region.center;         [_mapview addannotation:ann];     } } [super viewwillappear:yes]; } 

and mkmapview's delegate method is

- (mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id  <mkannotation>)annotation { if (![annotation iskindofclass:[mapviewannotations class]]) {     return nil; }  static nsstring *reuseid = @"currentloc";  mkpinannotationview *annview = (mkpinannotationview *)[mapview dequeuereusableannotationviewwithidentifier:reuseid]; if (annview == nil) {     annview = [[mkpinannotationview alloc] initwithannotation:annotation reuseidentifier:reuseid];     annview.animatesdrop = no;     annview.canshowcallout = yes;     annview.calloutoffset = cgpointmake(-5, 5); } else {     annview.annotation = annotation; }  dataprovider *mvann = [dataprovider getinstance]; if (mvann.colorlatitude) // here i'm checking condition. {     annview.pincolor = mkpinannotationcolorgreen; } else {     annview.pincolor = mkpinannotationcolorred; }  return annview; } 

i'm writting condition if co-ordinate there i've plot green color pin particular coordinate only. how achieve this?

the difference between code , 1 hinata has referred if statement in other code uses value (yesno) on annotation drawing decide colour use. getting value dataprovider not telling annotation drawing, instance gives ever instance method feels returning @ time map asking pin. need tell you're drawing decide put colorlatitude


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -