Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Directions {
- routes = (
- {
- bounds = {
- northeast = {
- lat = "39.893397";
- lng = "42.2477961";
- };
- southwest = {
- lat = "21.4204199";
- lng = "39.2398944";
- };
- };
- copyrights = "Map data U00a92014 Google, Mapa GISrael, ORION-ME";
- legs = (
- {
- distance = {
- text = "2,940 km";
- value = 2940341;
- };
- duration = {
- text = "1 day 15 hours";
- value = 138793;
- };
- "end_address" = "Unnamed Road, Erzincan Province, Turkey";
- "end_location" = {
- lat = "39.893397";
- lng = "39.906191";
- };
- "start_address" = "4289, Al Hajlah, Mecca 24231U00a06970, Saudi Arabia";
- "start_location" = {
- lat = "21.4204199";
- lng = "39.8258119";
- };
- steps = (
- {
- distance = {
- text = "0.6 km";
- value = 630;
- };
- duration = {
- text = "1 min";
- value = 55;
- };
- "end_location" = {
- lat = "21.4235672";
- lng = "39.8211613";
- };
- "html_instructions" = "Head <b>west</b> on <b>Alsouq Alsagheer Tunnel</b>";
- polyline = {
- points = "stvaCinarFEh@?h@?f@Cd@If@Gb@Yx@Yx@e@bAWb@Y`@CD[b@c@l@ILADIRIVGPKRGJKPILKPWRi@X_Ad@MFSJ]N[N_@P]ROJ";
- };
- "start_location" = {
- lat = "21.4204199";
- lng = "39.8258119";
- };
- "travel_mode" = DRIVING;
- -(void)retrieveDirectionsFromOrigin:(CLLocationCoordinate2D)origin toDestination:(CLLocationCoordinate2D)destination
- {
- 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];
- _directionsURL=[NSURL URLWithString:directionsURL];
- [self retrieveDirections:nil withDelegate:self];
- }
- -(void)retrieveDirections:(SEL)selector withDelegate:(id)delegate{
- dispatch_async(dispatch_get_main_queue(), ^{
- NSData *data = [NSData dataWithContentsOfURL:_directionsURL];
- [self fetchedData:data withDelegate:delegate];
- });
- }
- -(void)fetchedData:(NSData *)data withDelegate:(id)delegate{
- NSError* error;
- NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
- NSLog(@"Directions %@",json);
- if(!error){
- self.steps = json[@"routes"][0][@"legs"][0][@"steps"];
- }
- marker.position = CLLocationCoordinate2DMake(21.422492, 39.826169);
- marker2.position = CLLocationCoordinate2DMake(21.413333, 39.893333);
- marker.title = @"Kaaba";
- marker2.title= @"Minna";
- marker.snippet = @"Saudia Arab";
- marker2.snippet = @"Saudia Arab";
- marker.map = mapView;
- marker2.map = mapView;
- directions=[[Directions alloc]init];
- [directions retrieveDirectionsFromOrigin:marker.position toDestination:marker2.position];
- [mapViewView setNeedsDisplay];
- [mapView setNeedsDisplay];
- [self.view bringSubviewToFront:backButton];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement