Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. NSString *thePath = [[NSBundle mainBundle] pathForResource:@"ROUTE_TRIP_1" ofType:@"plist"];
  2. NSArray *pointsArray = [NSArray arrayWithContentsOfFile:thePath];
  3.  
  4. NSInteger pointsCount = pointsArray.count;
  5.  
  6. CLLocationCoordinate2D pointsToUse;
  7.  
  8. for(int i = 0; i < pointsCount; i++) {
  9. CGPoint p = CGPointFromString(pointsArray[i]);
  10. pointsToUse = CLLocationCoordinate2DMake(p.x,p.y);
  11. // NSLog (@"total11 %.1f",_currentRoute.distance/1000);
  12. NSLog (@"total %.1f",_currentRoute.distance/1000);}
  13. //*********************************************************
  14. // CLLocationCoordinate2D destinationCoords = CLLocationCoordinate2DMake(13.702668,100.488366);
  15. MKPlacemark *destinationPlacemark = [[MKPlacemark alloc] initWithCoordinate:pointsToUse addressDictionary:nil];
  16. // MKPlacemark *destinationPlacemark = [[MKPlacemark alloc] initWithCoordinate:destinationCoords addressDictionary:nil];
  17. MKMapItem *destination = [[MKMapItem alloc] initWithPlacemark:destinationPlacemark];
  18. [directionsRequest setDestination:destination];
  19.  
  20. MKDirections *directions = [[MKDirections alloc] initWithRequest:directionsRequest];
  21. [directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
  22. // We're done
  23. self.activityIndicator.hidden = YES;
  24. [self.activityIndicator stopAnimating];
  25. self.routeButton.enabled = YES;
  26.  
  27. // Now handle the result
  28. if (error) {
  29. NSLog(@"There was an error getting your directions");
  30. //return;
  31. }
  32.  
  33.  
  34. // So there wasn't an error - let's plot those routes
  35. self.routeDetailsButton.enabled = YES;
  36. self.routeDetailsButton.hidden = NO;
  37. _currentRoute = [response.routes firstObject];
  38. [self plotRouteOnMap:_currentRoute];
  39.  
  40. }
  41. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement