The trail is line up but when i scroll i get a bad result.
In relation to the version of my app with MKAnnotatioView i can show you the code but i can't show you the log 'cause unfortunately i'm not with iphone now...
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
self.startingPoint = newLocation;
CLLocation *lastLocation;
if([pointArray count] >= 2)
{
lastLocation = [pointArray objectAtIndex:1];
[pointArray removeAllObjects];
}
mapView.showsUserLocation = NO;
double lat,lon;
lat = newLocation.coordinate.latitude;
lon = newLocation.coordinate.longitude;
if(distanceIndex == 0)
{
[pointArray insertObject:newLocation atIndex:0];
}
else
{
if(distanceIndex == 1)
{
[pointArray insertObject:newLocation atIndex:1];
}
else
{
[pointArray insertObject:lastLocation atIndex:0];
[pointArray insertObject:newLocation atIndex:1];
}
}
if(distanceIndex == 0)
{
MarkPlace *mark = nil;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateStr = [dateFormatter stringFromDate:[NSDate date]];
[dateFormatter release];
NSString *subtitle = [NSString stringWithFormat:@"Time Here: %@", dateStr];
mark = [[[MarkPlace alloc] initWithCoordinate:[[pointArray objectAtIndex:0] coordinate] currentTime:subtitle annotationType:MarkPlaceTypeEnd title:@"Pin Title"] autorelease];
[mapView addAnnotation:mark];
}
//create the route
MKCoordinateSpan span = mapView.region.span;
CLLocationCoordinate2D center = mapView.region.center;
IFRouteAnnotations *routeAnnotation = [[[IFRouteAnnotations alloc] initWithPoints:pointArray:0:span:center] autorelease];
[mapView addAnnotation:routeAnnotation];
[mapView setRegion:routeAnnotation.region animated:TRUE];
distanceIndex = distanceIndex + 1;
[routeAnnotation release];
}
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
//re-enable and re-position the route display
for (NSObject *key in [routeViews allKeys]) {
IFRouteView *routeView = [routeViews objectForKey:key];
[routeView regionChanged];
}
}
-(MKAnnotationView *)mapView:(MKMapView *)_mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotationView *annotationView = nil;
NSLog(@"viewForAnnotation");
if(distanceIndex == 0)
{
MKPinAnnotationView *pin=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"] autorelease];
pin.pinColor = MKPinAnnotationColorGreen;
pin.animatesDrop = TRUE;
pin.userInteractionEnabled = YES;
annotationView = pin;
[annotationView setEnabled:YES];
[annotationView setCanShowCallout:YES];
}
if([annotation isKindOfClass:[IFRouteAnnotations class]])
{
IFRouteAnnotations *routeAnnotation = (IFRouteAnnotations *)annotation;
annotationView = [routeViews objectForKey:routeAnnotation.routeID];
if(annotationView == nil)
{
IFRouteView *routeView = [[[IFRouteView alloc] initWithFrame:CGRectMake(0,0, mapView.frame.size.width, mapView.frame.size.height)]autorelease];
routeView.annotation = routeAnnotation;
routeView.mapView = mapView;
[routeViews setObject:routeView forKey:routeAnnotation.routeID];
annotationView = routeView;
}
}
return annotationView;
}
I don't know if you'll understand anything. My code is based on link text.
Thanks for your help!! :)