Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. Directions {
  2. routes = (
  3. {
  4. bounds = {
  5. northeast = {
  6. lat = "39.893397";
  7. lng = "42.2477961";
  8. };
  9. southwest = {
  10. lat = "21.4204199";
  11. lng = "39.2398944";
  12. };
  13. };
  14. copyrights = "Map data U00a92014 Google, Mapa GISrael, ORION-ME";
  15. legs = (
  16. {
  17. distance = {
  18. text = "2,940 km";
  19. value = 2940341;
  20. };
  21. duration = {
  22. text = "1 day 15 hours";
  23. value = 138793;
  24. };
  25. "end_address" = "Unnamed Road, Erzincan Province, Turkey";
  26. "end_location" = {
  27. lat = "39.893397";
  28. lng = "39.906191";
  29. };
  30. "start_address" = "4289, Al Hajlah, Mecca 24231U00a06970, Saudi Arabia";
  31. "start_location" = {
  32. lat = "21.4204199";
  33. lng = "39.8258119";
  34. };
  35. steps = (
  36. {
  37. distance = {
  38. text = "0.6 km";
  39. value = 630;
  40. };
  41. duration = {
  42. text = "1 min";
  43. value = 55;
  44. };
  45. "end_location" = {
  46. lat = "21.4235672";
  47. lng = "39.8211613";
  48. };
  49. "html_instructions" = "Head <b>west</b> on <b>Alsouq Alsagheer Tunnel</b>";
  50. polyline = {
  51. points = "stvaCinarFEh@?h@?f@Cd@If@Gb@Yx@Yx@e@bAWb@Y`@CD[b@c@l@ILADIRIVGPKRGJKPILKPWRi@X_Ad@MFSJ]N[N_@P]ROJ";
  52. };
  53. "start_location" = {
  54. lat = "21.4204199";
  55. lng = "39.8258119";
  56. };
  57. "travel_mode" = DRIVING;
  58.  
  59. -(void)retrieveDirectionsFromOrigin:(CLLocationCoordinate2D)origin toDestination:(CLLocationCoordinate2D)destination
  60. {
  61. NSString *directionsURL=[NSString stringWithFormat:@"http://maps.google.com/maps/api/directions/json?origin=%f,%f&destination=%f,%f&sensor=false",origin.latitude,origin.longitude,destination.longitude,destination.longitude];
  62. _directionsURL=[NSURL URLWithString:directionsURL];
  63. [self retrieveDirections:nil withDelegate:self];
  64. }
  65. -(void)retrieveDirections:(SEL)selector withDelegate:(id)delegate{
  66. dispatch_async(dispatch_get_main_queue(), ^{
  67. NSData *data = [NSData dataWithContentsOfURL:_directionsURL];
  68. [self fetchedData:data withDelegate:delegate];
  69. });
  70. }
  71.  
  72. -(void)fetchedData:(NSData *)data withDelegate:(id)delegate{
  73. NSError* error;
  74. NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
  75. NSLog(@"Directions %@",json);
  76. if(!error){
  77. self.steps = json[@"routes"][0][@"legs"][0][@"steps"];
  78. }
  79.  
  80. marker.position = CLLocationCoordinate2DMake(21.422492, 39.826169);
  81. marker2.position = CLLocationCoordinate2DMake(21.413333, 39.893333);
  82. marker.title = @"Kaaba";
  83. marker2.title= @"Minna";
  84. marker.snippet = @"Saudia Arab";
  85. marker2.snippet = @"Saudia Arab";
  86. marker.map = mapView;
  87. marker2.map = mapView;
  88.  
  89. directions=[[Directions alloc]init];
  90. [directions retrieveDirectionsFromOrigin:marker.position toDestination:marker2.position];
  91. [mapViewView setNeedsDisplay];
  92. [mapView setNeedsDisplay];
  93. [self.view bringSubviewToFront:backButton];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement