iphone - Get object properties from mapView.SelectedAnnotations -
i've got mapview , annotation view drops pins on region based on long/lat series of objects representing physical branches. i've got callout annotations prompting open shared application maps give them directions location.. but, can't figure out how address branch object/annotation , pass when calloutaccessorycontroltapped fires:
branch objects:
cllocationcoordinate2d newcord; newcord.latitude = 34.0038; newcord.longitude = -84.0965; corp = [[locationwithannotation alloc] initwithcoordinate:newcord]; corp.mtitle = @"corp office"; corp.msubtitle = @"123 main street, duluth ga"; [mapview addannotation:corp]; [corp release]; newcord.latitude = 33.0038; newcord.longitude = -84.3965; uga = [[locationwithannotation alloc] initwithcoordinate:newcord]; uga.mtitle = @"uga office"; uga.msubtitle = @"123 main street, atlanta ga"; [mapview addannotation:uga]; [corp release];
these annotations added map, when callout hit, want able tp push them maps app selected annotation's (corp, example) subtitle.
- (mkannotationview *) mapview:(mkmapview *)mapview viewforannotation:(id <mkannotation>) annotation{ mkpinannotationview *annview=[[mkpinannotationview alloc] initwithannotation:annotation reuseidentifier:@"currentloc"]; annview.pincolor = mkpinannotationcolorgreen; annview.animatesdrop=true; annview.canshowcallout = yes; annview.rightcalloutaccessoryview = [uibutton buttonwithtype:uibuttontypedetaildisclosure]; annview.calloutoffset = cgpointmake(-5, 5); return annview; } - (void)mapview:(mkmapview *)mapview annotationview:(mkannotationview *)view calloutaccessorycontroltapped:(uicontrol *)control { nslog(@"%@", mapview.selectedannotations); uialertview *alert = [[uialertview alloc] initwithtitle:@"directions" message:@"get directions branch?" delegate:self cancelbuttontitle:@"no" otherbuttontitles: @"yes, please", nil]; [alert show]; [alert release]; } - (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { if (buttonindex == 1) { mkuserlocation *loc = mapview.userlocation.location; double latitude = loc.location.coordinate.latitude; nsstring *lat = [nsstring stringwithformat:@"%f",latitude]; double longitude = loc.location.coordinate.longitude; nsstring *lon = [nsstring stringwithformat:@"%f",longitude]; nsstring *base = @"http://maps.google.com/maps?"; nsstring *dest = [@"daddr=" stringbyappendingstring: mapview.selectedannotations; // doesn't work.
the thing nslog dumping memory address selectedannotation.. how can grab object that?
for(yourmkannotationprotocolclass *object in _mapview.selectedannotation){ nslog("%@", object.title); // or can access other information you've defined }
Comments
Post a Comment