Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For drawing multiple points you can use it as </p> <p>need to declare mutable array in header file </p> <pre><code>NSMutableArray *polyLineArray; </code></pre> <p>Implementation file need minor changes as ===</p> <pre><code>-(void) showRouteFrom: (id&lt;MKAnnotation&gt;)source to:(id&lt;MKAnnotation&gt;)destination; { NSLog(@"source title is %@",source.title); NSLog(@"destination title is %@",destination.title); routes = [self calculateRoutesFrom:source.coordinate to:destination.coordinate]; NSLog(@"routes are %@",routes); NSInteger numberOfSteps = routes.count; CLLocationCoordinate2D coordinates[numberOfSteps]; for (NSInteger index = 0; index &lt; numberOfSteps; index++) { CLLocation *location = [routes objectAtIndex:index]; CLLocationCoordinate2D coordinate = location.coordinate; coordinates[index] = coordinate; } polyLine = [MKPolyline polylineWithCoordinates:coordinates count:numberOfSteps]; [polyLineArray addObject:polyLine]; // NSLog(@"poly line to be added as ovelay is %@",polyLine); } - (IBAction)drawMultiple:(id)sender { polyLineArray=[[NSMutableArray alloc] init]; NSDictionary *kolkata,*delhi,*chennai,*mumbai,*pune; kolkata=[NSDictionary dictionaryWithObjectsAndKeys:@"location1",@"comments",@"1",@"id",@"23.0083321",@"latitude",@"88.54276659999",@"longitude",nil]; delhi=[NSDictionary dictionaryWithObjectsAndKeys:@"location2",@"comments",@"2",@"id",@"28.889816",@"latitude",@"77.3418147",@"longitude",nil]; chennai=[NSDictionary dictionaryWithObjectsAndKeys:@"location3",@"comments",@"3",@"id",@"13.23339843",@"latitude",@"80.3322912",@"longitude",nil]; mumbai=[NSDictionary dictionaryWithObjectsAndKeys:@"location4",@"comments",@"4",@"id",@"19.2716339",@"latitude",@"72.9864994",@"longitude",nil]; pune=[NSDictionary dictionaryWithObjectsAndKeys:@"location5",@"comments",@"5",@"id",@"18.6346965",@"latitude",@"73.9894867",@"longitude",nil]; NSArray *arrayOfLocations=[[NSArray alloc] initWithObjects:kolkata,delhi,chennai,mumbai,pune,nil]; MKPointAnnotation *start=[[MKPointAnnotation alloc] init]; MKPointAnnotation *end=[[MKPointAnnotation alloc] init]; dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ //Background Thread for (int i=0;i&lt;arrayOfLocations.count-1;i++) { NSDictionary *dic=[arrayOfLocations objectAtIndex:i]; [start setCoordinate:CLLocationCoordinate2DMake([[dic valueForKey:@"latitude"] floatValue], [[dic valueForKey:@"longitude"] floatValue])]; dic=[arrayOfLocations objectAtIndex:i+1]; [end setCoordinate:CLLocationCoordinate2DMake([[dic valueForKey:@"latitude"] floatValue], [[dic valueForKey:@"longitude"] floatValue])]; [self showRouteFrom:start to:end]; } dispatch_async(dispatch_get_main_queue(), ^(void){ //Run UI Updates NSDictionary *tempDic=[[NSDictionary alloc] initWithDictionary:[arrayOfLocations objectAtIndex:0]]; [start setCoordinate:CLLocationCoordinate2DMake([[tempDic valueForKey:@"latitude"] floatValue], [[tempDic valueForKey:@"longitude"] floatValue])]; [__mapView addAnnotation:start]; [__mapView addAnnotation:end]; if (polyLine) { [__mapView setVisibleMapRect:[polyLine boundingMapRect]]; for (MKPolyline *pLine in polyLineArray) { [__mapView addOverlay:pLine]; } } NSLog(@"drawing path completed"); }); }); } </code></pre> <p><a href="http://ge.tt/5uV1g0m/v/0" rel="nofollow noreferrer">If u need sample code here it is</a> </p> <p>Output is --------</p> <p><img src="https://i.stack.imgur.com/eXWDE.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload