iphone - Rotate image as per the direction of user follows in Map -
i want rotate bike / car image in direction of user follows. right image follows direction looks non directive, can point not follows direction :
- (mkannotationview *)mapview:(mkmapview *)map viewforannotation:(id <mkannotation>)annotation { static nsstring *annotationviewid = @"annotationviewid"; mkannotationview *annotationview = (mkannotationview *)[map dequeuereusableannotationviewwithidentifier:annotationviewid]; if (annotationview == nil) { annotationview = [[[mkannotationview alloc] initwithannotation:annotation reuseidentifier:annotationviewid] autorelease]; } annotationview.image = [uiimage imagenamed:@"bike.png"]; annotationview.annotation = annotation; return annotationview; } - (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation { if (newlocation.horizontalaccuracy < 0) return; if (!newlocation) return; currentlocation = newlocation; if(currentlocation != nil) { if (myannotation) { [self.mymapview removeannotation:myannotation]; } cllocationcoordinate2d location = cllocationcoordinate2dmake(currentlocation.coordinate.latitude, currentlocation.coordinate.longitude); myannotation = [[myannotation alloc] initwithcoordinates:location title:@"current location" subtitle:nil]; [self.mymapview addannotation:myannotation]; } }
check out core location's -[cllocationmanagerdelegate locationmanager:didupdateheading:]
.
Comments
Post a Comment