解释来自 Google 服务器的 API 响应
我正在开发一个基于位置的应用程序。应用程序将显示到位置之间的路线以及逐向方向(如在具有所有节点的本机“地图”应用程序中)。我请求谷歌地图以下列方式获取方向。(作为库比蒂诺和斯坦福之间的示例方向)
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);
在控制台我得到响应
{tooltipHtml:" (12.9\x26#160;mi / 19分钟)",折线:[{id:"route0",点:"kklcFzishVdBb@??@s@rB{PHi@Xk@??bEmDrDgF~DeHVcAhCgG??rFfEv@RbFHnEa@vBGnE d@\\P~EjGtMxK??zNwTxB_ChCqD??bAt@bDdBvDt@~BXrC@xBS|NiClA@fAPvBdA~@dAlI
QAxAr@n@|@d@rFxA|AlA
AnAz@t@l@@nAd@zQnC??bA\\^XVr@Az@KVa@\\m@B[UWq@?i@zBaI
@oBd@mDt@kS~@kG AoDrA_DhAqB~AkBlCuBlDiB ~Cw@lU}CbBa@~B{@jE_CvAgAjDyDhQ{SvFuFpUgSzD{EdAcB
BiDlA_DfAaEbIk@r@mERyBZkMXkHX{DjA{GtBaG|CcFxC{CfA y@vUaMjDmEva}BxCkG
AwCfAyEtCiRv@{ClB_F|B_EpDkEvAoAdGcE|FwEbBmBvBmDhAiCtMma@dAcCrBmDLiNlB{CfAcCtEaM tKsU
CmEdP{WbB_EbAoDr@}Dd@aFLkCC_FK_C{C}YMqGPsGRyC\eCdAeFpCaLdBiJXcENgHa@qIcIwo@[DWeFKk[Dyc@??\gHbAg我?@??|bAG???s@_@?",级别:"BBB???BB????BB?@???@??BB??BB???@ ??????@??????@??????@BB??????@???@??????@???@??????@? ?????@???@????@?@?????@?????@??????@??@??@?????一个?? ?@???@??????@???@?BB??BBBB?B",numLevel`s:4,zoomFactor:16}]}
我无法理解上面的回复。此响应是否包含逐段指示?如果没有,如何获得这些指示?
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~@dAlI
QAxAr@n@|@d@rFxA|AlA
AnAz@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{EdAcB
BiDlA_DfAaEbIk@r@mERyBZkMXkHX{DjA{GtBaG|CcFxC{CfAy@vUaMjDmEvA}BxCkG
AwCfAyEtCiRv@{ClB_F|B_EpDkEvAoAdGcE|FwEbBmBvBmDhAiCtMma@dAcCrBmDLiNlB{CfAcCtEaMtKsU
CmEdP{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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Google Directions API 文档:
这意味着您无法直接读取实际点数值。
还:
According to Google Directions API documentation:
That means you cannot directly read real points value.
Also: