Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *thePath = [[NSBundle mainBundle] pathForResource:@"ROUTE_TRIP_1" ofType:@"plist"];
- NSArray *pointsArray = [NSArray arrayWithContentsOfFile:thePath];
- NSInteger pointsCount = pointsArray.count;
- CLLocationCoordinate2D pointsToUse;
- for(int i = 0; i < pointsCount; i++) {
- CGPoint p = CGPointFromString(pointsArray[i]);
- pointsToUse = CLLocationCoordinate2DMake(p.x,p.y);
- // NSLog (@"total11 %.1f",_currentRoute.distance/1000);
- NSLog (@"total %.1f",_currentRoute.distance/1000);}
- //*********************************************************
- // CLLocationCoordinate2D destinationCoords = CLLocationCoordinate2DMake(13.702668,100.488366);
- MKPlacemark *destinationPlacemark = [[MKPlacemark alloc] initWithCoordinate:pointsToUse addressDictionary:nil];
- // MKPlacemark *destinationPlacemark = [[MKPlacemark alloc] initWithCoordinate:destinationCoords addressDictionary:nil];
- MKMapItem *destination = [[MKMapItem alloc] initWithPlacemark:destinationPlacemark];
- [directionsRequest setDestination:destination];
- MKDirections *directions = [[MKDirections alloc] initWithRequest:directionsRequest];
- [directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
- // We're done
- self.activityIndicator.hidden = YES;
- [self.activityIndicator stopAnimating];
- self.routeButton.enabled = YES;
- // Now handle the result
- if (error) {
- NSLog(@"There was an error getting your directions");
- //return;
- }
- // So there wasn't an error - let's plot those routes
- self.routeDetailsButton.enabled = YES;
- self.routeDetailsButton.hidden = NO;
- _currentRoute = [response.routes firstObject];
- [self plotRouteOnMap:_currentRoute];
- }
- }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement