Interprating API response from Google server

169 views Asked by At

I am developing a Location based application. application will show route between to locations with turn by turn directions(as in native "Maps" application with all the nodes). I am requesting to google maps for directions in following way.(as example directions between cupertino and stanford)

NSString* apiUrlStr = [NSString stringWithFormat:@"http://maps.google.com/maps?dirflg=d&output=dragdir&saddr=Stanford&daddr=cupertino"];
    NSURL* apiUrl = [NSURL URLWithString:apiUrlStr];

    NSError* error = nil;
    NSString* apiResponse = [NSString stringWithContentsOfURL:apiUrl encoding:NSASCIIStringEncoding error:&error];
    NSLog(@"apiResponse=%@", apiResponse);

At the console I got response

{tooltipHtml:" (12.9\x26#160;mi / 19 mins)",polylines:[{id:"route0",points:"kklcFzishVdBb@??@s@rB{PHi@Xk@??bEmDrDgF~DeHVcAhCgG??rFfEv@RbFHnEa@vBGnEd@\\P~EjGtMxK??zNwTxB_ChCqD??bAt@bDdBvDt@~BXrC@xBS|NiClA@fAPvBdA~@dAlIQAxAr@n@|@d@rFxA|AlAAnAz@t@l@@nAd@zQnC??bA\\^XVr@Az@KVa@\\m@B[UWq@?i@zBaI@oBd@mDt@kS~@kGAoDrA_DhAqB~AkBlCuBlDiB~Cw@lU}CbBa@~B{@jE_CvAgAjDyDhQ{SvFuFpUgSzD{EdAcBBiDlA_DfAaEbIk@r@mERyBZkMXkHX{DjA{GtBaG|CcFxC{CfAy@vUaMjDmEvA}BxCkGAwCfAyEtCiRv@{ClB_F|B_EpDkEvAoAdGcE|FwEbBmBvBmDhAiCtMma@dAcCrBmDLiNlB{CfAcCtEaMtKsUCmEdP{WbB_EbAoDr@}Dd@aFLkCC_FK_C{C}YMqGPsGRyC\eCdAeFpCaLdBiJXcENgHa@qIcIwo@[DWeFKk[Dyc@??\gHbAgI?@??|bAG???s@_@?",levels:"BBB???BB????BB?@???@??BB??BB???@????@????@??????@BB?????@???@????@???@??????@??????@???@????@?@?????@?????@??????@??@??@?????A???@????@??????@???@?BB??BBBB?B",numLevel`s:4,zoomFactor:16}]}

I am not able understand above response. Does this response contains turn by turn directions? If not how can get these directions?

1

There are 1 answers

0
Artur Ozierański On BEST ANSWER

According to Google Directions API documentation:

overview_polyline contains an object holding an array of encoded points

That means you cannot directly read real points value.

Also:

Note: the Directions API may only be used in conjunction with displaying results on a Google map; using Directions data without displaying a map for which directions data was requested is prohibited.