Note that there are some explanatory texts on larger screens.

plurals
  1. PODraw Map Path among multiple location
    primarykey
    data
    text
    <p>I am new in iphone development, i want to draw path between 5 location how i can draw path in google map. I want path from location1 to location2 , location2 to location3, location3 to location4 and location4 to location5. </p> <p>here is my code </p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSDictionary *d1,*d2,*d3,*d4,*d5; d1=[NSDictionary dictionaryWithObjectsAndKeys:@"location1",@"comments",@"1",@"id",@"23.02941395",@"latitude",@"72.54620655",@"longitude",nil]; d2=[NSDictionary dictionaryWithObjectsAndKeys:@"location2",@"comments",@"2",@"id",@"23.028359049999995",@"latitude",@"72.54537318333334",@"longitude",nil]; d3=[NSDictionary dictionaryWithObjectsAndKeys:@"location3",@"comments",@"3",@"id",@"23.029545",@"latitude",@"72.546036",@"longitude",nil]; d4=[NSDictionary dictionaryWithObjectsAndKeys:@"location4",@"comments",@"4",@"id",@"23.030050",@"latitude",@"72.546226",@"longitude",nil]; d5=[NSDictionary dictionaryWithObjectsAndKeys:@"location5",@"comments",@"5",@"id",@"23.030050",@"latitude",@"72.546022",@"longitude",nil]; self.reports=[NSArray arrayWithObjects:d1,d2,d3,d4,d5,nil]; for (NSDictionary *d in self.reports) { float latitude=[[d valueForKey:@"latitude"] floatValue]; float longitude=[[d valueForKey:@"longitude"] floatValue]; Place* home = [[[Place alloc] init] autorelease]; home.name = [d valueForKey:@"comments"]; home.latitude = latitude; home.longitude = longitude; PlaceMark *from = [[[PlaceMark alloc] initWithPlace:home] autorelease]; [mapView addAnnotation:from]; } [self centerMap]; } -(void) centerMap { MKCoordinateRegion region; CLLocationDegrees maxLat = -90; CLLocationDegrees maxLon = -180; CLLocationDegrees minLat = 120; CLLocationDegrees minLon = 150; NSMutableArray *temp=[NSArray arrayWithArray:self.reports]; NSLog(@"%@",temp); for (int i=0; i&lt;[temp count];i++) { Place* home = [[[Place alloc] init] autorelease]; home.latitude = [[[temp objectAtIndex:i] valueForKey:@"latitude"]floatValue]; home.longitude =[[[temp objectAtIndex:i] valueForKey:@"longitude"]floatValue]; PlaceMark* from = [[[PlaceMark alloc] initWithPlace:home] autorelease]; CLLocation* currentLocation = (CLLocation*)from ; if(currentLocation.coordinate.latitude &gt; maxLat) maxLat = currentLocation.coordinate.latitude; if(currentLocation.coordinate.latitude &lt; minLat) minLat = currentLocation.coordinate.latitude; if(currentLocation.coordinate.longitude &gt; maxLon) maxLon = currentLocation.coordinate.longitude; if(currentLocation.coordinate.longitude &lt; minLon) minLon = currentLocation.coordinate.longitude; region.center.latitude = (maxLat + minLat) / 2; region.center.longitude = (maxLon + minLon) / 2; region.span.latitudeDelta = maxLat - minLat; region.span.longitudeDelta = maxLon - minLon; } [mapView setRegion:region animated:YES]; } - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation { if (annotation == mapView.userLocation) return nil; MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"asdf"]; if (pin == nil) pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: @"asdf"] autorelease]; else pin.annotation = annotation; pin.userInteractionEnabled = YES; UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [disclosureButton setFrame:CGRectMake(0, 0, 30, 30)]; pin.rightCalloutAccessoryView = disclosureButton; pin.pinColor = MKPinAnnotationColorRed; //pin.animatesDrop = YES; [pin setEnabled:YES]; [pin setCanShowCallout:YES]; return pin; } - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { NSString *strTitle = [NSString stringWithFormat:@"%@",[view.annotation title]]; NSMutableDictionary *d; NSMutableArray *temp=[NSArray arrayWithArray:self.reports]; for (int i = 0; i&lt;[temp count]; i++) { d = (NSMutableDictionary*)[temp objectAtIndex:i]; NSString *strAddress = [NSString stringWithFormat:@"%@",[d valueForKey:@"comments"]]; if([strAddress isEqualToString:strTitle]) { [self presentModalViewController:self.nxtDetailsVCtr animated:YES]; [self.nxtDetailsVCtr.lblDetail setText:strAddress]; break; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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