Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>- (void)getCordinate :(NSString *)strOrigin : (NSString*)strDestination { NSMutableString *tempStrOrigin = [NSMutableString stringWithString:strOrigin]; NSMutableString *tempStrDestination = [NSMutableString stringWithString:strDestination]; //[tempStrOrigin replaceOccurrencesOfString:@" " withString:@"+" options:NULL range:[NSMakeRange(0, [tempStrOrigin length])]]; tempStrOrigin = [[tempStrOrigin stringByReplacingOccurrencesOfString:@" " withString:@"+"] mutableCopy]; tempStrDestination = [[tempStrDestination stringByReplacingOccurrencesOfString:@" " withString:@"+"] mutableCopy]; NSString *url = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=%@&amp;destination=%@&amp;sensor=false&amp;mode=walking",tempStrOrigin,tempStrDestination]; NSLog(@"URL:%@",url); NSURLConnection *urlConnection = [NSURLConnection connectionWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]] delegate:self]; if (urlConnection == nil) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Pradeep Chakoriya" message:@"Connection Failed !" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; [alert release]; } } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"Connection finish!!!"); NSError *error = nil; NSMutableString *str = [[NSMutableString alloc]initWithData:responeData encoding:NSUTF8StringEncoding]; NSLog(@"Response in String:%@",str); SBJsonParser *parser=[[SBJsonParser alloc] init]; NSDictionary *jsonObject = [parser objectWithString:str]; NSLog(@"Error:%@",error); NSLog(@"Response Object:%@",jsonObject); NSLog(@"End location:%@",[jsonObject valueForKeyPath:@"routes.legs.end_location"]); NSLog(@"Start location:%@",[jsonObject valueForKeyPath:@"routes.legs.start_location.lat"]); NSLog(@"Overview_polyline:%d",[[jsonObject valueForKeyPath:@"routes.overview_polyline.points"] count]); NSString *strTemp = [NSString stringWithFormat:@"%@",[[jsonObject valueForKeyPath:@"routes.overview_polyline.points"] objectAtIndex:0]]; NSLog(@"String Temp:%@",strTemp); NSLog(@"Decode points:%@",[[[self decodePolyLine:strTemp] objectAtIndex:0] class]); } -(NSMutableArray *)decodePolyLine:(NSString *)encodedStr { NSMutableString *encoded = [[NSMutableString alloc] initWithCapacity:[encodedStr length]]; NSLog(@"encoded:%@",encoded); [encoded appendString:encodedStr]; NSLog(@"encoded:%@",encoded); /*[encoded replaceOccurrencesOfString:@"\\\\" withString:@"\\" options:NSLiteralSearch range:NSMakeRange(0, [encoded length])];*/ NSInteger len = [encoded length]; NSInteger index = 0; NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease]; NSInteger lat=0; NSInteger lng=0; while (index &lt; len) { NSInteger b; NSInteger shift = 0; NSInteger result = 0; do { b = [encoded characterAtIndex:index++] - 63; result |= (b &amp; 0x1f) &lt;&lt; shift; shift += 5; } while (b &gt;= 0x20); NSInteger dlat = ((result &amp; 1) ? ~(result &gt;&gt; 1) : (result &gt;&gt; 1)); lat += dlat; shift = 0; result = 0; do { b = [encoded characterAtIndex:index++] - 63; result |= (b &amp; 0x1f) &lt;&lt; shift; shift += 5; } while (b &gt;= 0x20); NSInteger dlng = ((result &amp; 1) ? ~(result &gt;&gt; 1) : (result &gt;&gt; 1)); lng += dlng; NSNumber *latitude = [[[NSNumber alloc] initWithFloat:lat * 1e-5] autorelease]; NSNumber *longitude = [[[NSNumber alloc] initWithFloat:lng * 1e-5] autorelease]; // printf("[%f,", [latitude doubleValue]); // printf("%f]", [longitude doubleValue]); CLLocation *loc = [[[CLLocation alloc] initWithLatitude:[latitude floatValue] longitude:[longitude floatValue]] autorelease]; [array addObject:loc]; } [encoded release]; return array; } Use this code to get all latitute and longitute of origin to destination </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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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