title: Multiple MKPolyline on MKMapView iOS6
body: <p>I am working with <code>MKMapView</code> to draw route using <code>MKPolyline</code>, I am able to draw single route with an array of waypoints.Now I want to draw multiple <code>MKPolyline</code>s on the <code>MKMapView</code> for instance,  A blue <code>MKPolyline</code> from <code>28.102021, 77.10129</code> to <code>28.20320, 77.3021</code> and A red <code>MKPolyline</code> from <code>28.50930, 77.89192</code> to <code>28.60291, 77.87328</code>. How can I achieve this ?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>- (void)viewDidLoad
  {
  [super viewDidLoad];
  
  locationManager = [[CLLocationManager alloc] init];
  locationManager.desiredAccuracy = 6.0;
  locationManager.distanceFilter = 1.0;
  [locationManager startUpdatingLocation];
  locationManager.delegate = self;
  map.delegate = self;
  [map setShowsUserLocation:YES];
  [map setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
  wayPoints = [[NSMutableArray alloc] initWithCapacity:30];
  newWayPoints = [[NSMutableArray alloc]initWithCapacity:10];
  totalDistance = 0.0;
  
  stopTime = [NSDate dateWithTimeIntervalSinceNow:100];
  startTime = [NSDate date];
  
  SEL sel = @selector(timerTargetMethod);
  NSInvocation* inv = [NSInvocation invocationWithMethodSignature:
                       [self methodSignatureForSelector:sel]];
  [inv setTarget:self];
  [inv setSelector:sel];
  
  stopTimer = [NSTimer scheduledTimerWithTimeInterval:5 invocation:inv repeats:true];
  }
  
  - (void)viewDidUnload
  {
  [super viewDidUnload];
  // Release any retained subviews of the main view.
  // e.g. self.myOutlet = nil;
  }
  
  
  
  - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
  {
  if(newLocation != nil &amp;&amp; oldLocation != newLocation)
  {
      tempNewLocation = newLocation;
      tempOldLocation = oldLocation;
  
  }
  
  }
  
  
  - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
  {    
  MKAnnotationView *annotationView = [views objectAtIndex:0];
  id&lt;MKAnnotation&gt; mp = [annotationView annotation];
  MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate] ,4000,4000);
  
  [mv setRegion:region animated:YES];
  }
  
  // MKMapViewDelegate
  - (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id &lt;MKOverlay&gt;)overlay
  {
  MKOverlayView* overlayView = nil;
  MKPolylineView  * routeLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine];
  routeLineView.fillColor = [UIColor colorWithRed:0.0-1.0 green:0.0-1.0 blue:0.0-1.0 alpha:1.0f];
  routeLineView.strokeColor = [UIColor colorWithRed:0.0-1.0 green:0.0-1.0 blue:0.0-1.0 alpha:1.0f];
  
  routeLineView.lineWidth = 3;
  routeLineView.lineCap = kCGLineCapSquare;
  overlayView = routeLineView;
  return overlayView;
  
  }
  
  //define the targetmethod
  -(void) timerTargetMethod 
  {
  
  if([[NSDate date] timeIntervalSinceDate:startTime] &gt;= 100)
  {
      [stopTimer invalidate];
      [locationManager stopUpdatingLocation];
      NSLog(@"Time started at %@", startTime);
      NSLog(@"Time up at %@", stopTime);
  }
  else if (tempOldLocation.coordinate.latitude == tempNewLocation.coordinate.latitude   &amp;&amp; tempNewLocation.coordinate.longitude == tempOldLocation.coordinate.longitude) 
  {
      NSLog(@" Fix location found ");
  }
  else if( [[NSDate date] timeIntervalSinceDate:startTime] &gt;= 19 )
  {
      if(roundf([[NSDate date] timeIntervalSinceDate:startTime]) == 20)
      {
          NSLog(@"First Time Location Update");
          latitudeLongitude.text = [[ NSString alloc] initWithFormat:@"%g , %g", tempNewLocation.coordinate.latitude, tempNewLocation.coordinate.longitude];
  
          float interval = [[NSDate date] timeIntervalSinceDate:startTime];
          int okInterval = roundf(interval);
          NSLog(@"Interval 1 , %d", okInterval );
          time.text = [[ NSString alloc] initWithFormat:@"%d", okInterval  - 20];
          speed.text = @"0";
          totalDistance =  0;
          distance.text = @"0 meters";
      }
      else
      {
          latitudeLongitude.text = [[ NSString alloc] initWithFormat:@"%g , %g", tempNewLocation.coordinate.latitude, tempNewLocation.coordinate.longitude];
  
          float interval = [[NSDate date] timeIntervalSinceDate:startTime];
          int okInterval = roundf(interval);
          time.text = [[ NSString alloc] initWithFormat:@"%d", okInterval  - 20];
          NSLog(@"Interval 2 , %d , %f", okInterval , interval);
          if((tempNewLocation.coordinate.latitude == tempOldLocation.coordinate.latitude &amp;&amp; tempNewLocation.coordinate.longitude == tempOldLocation.coordinate.longitude) || tempNewLocation.speed &lt; 0)
              speed.text = @"0";
          else
              speed.text = [[ NSString alloc] initWithFormat:@"%g meters/sec", tempNewLocation.speed];
  
          if(tempNewLocation.coordinate.latitude == tempOldLocation.coordinate.latitude &amp;&amp; tempNewLocation.coordinate.longitude == tempOldLocation.coordinate.longitude)
          {
  
          }
          else if ([tempNewLocation distanceFromLocation:tempOldLocation] - tempNewLocation.horizontalAccuracy &gt;= 0) 
              totalDistance +=  [tempNewLocation distanceFromLocation:tempOldLocation] - (tempNewLocation.horizontalAccuracy / 2);
          else
              totalDistance +=  [tempNewLocation distanceFromLocation:tempOldLocation];
  
          if (totalDistance &lt; 0) 
              distance.text = @"0 meters";
          else
              distance.text = [[ NSString alloc] initWithFormat:@"%g meters", totalDistance];
      }
  
  
      [wayPoints addObject:tempNewLocation];
      MKMapPoint * pointsArray =
      malloc(sizeof(CLLocationCoordinate2D)*2);
  
      pointsArray[0]= MKMapPointForCoordinate(tempOldLocation.coordinate); 
      pointsArray[1]= MKMapPointForCoordinate(tempNewLocation.coordinate);
  
      routeLine = [MKPolyline polylineWithPoints:pointsArray count:2];
      free(pointsArray);
  
      if (tempNewLocation.coordinate.latitude - tempOldLocation.coordinate.latitude &lt; 1) {
          [map addOverlay:routeLine];
  
      }
  }
  }
  </code></pre>
  
  <p>Thanks </p>