解释来自 Google 服务器的 API 响应

发布于 2024-12-11 18:36:21 字数 1514 浏览 0 评论 0原文

我正在开发一个基于位置的应用程序。应用程序将显示到位置之间的路线以及逐向方向(如在具有所有节点的本机“地图”应用程序中)。我请求谷歌地图以下列方式获取方向。(作为库比蒂诺和斯坦福之间的示例方向)

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~@dAlIQAxAr@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{EdAcBBiDlA_DfAaEbIk@r@mERyBZkMXkHX{DjA{GtBaG|CcFxC{CfA y@vUaMjDmEva}BxCkGAwCfAyEtCiRv@{ClB_F|B_EpDkEvAoAdGcE|FwEbBmBvBmDhAiCtMma@dAcCrBmDLiNlB{CfAcCtEaM tKsUCmEdP{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~@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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光磨忆 2024-12-18 18:36:21

根据 Google Directions API 文档

overview_polyline 包含一个包含编码数组的对象

这意味着您无法直接读取实际点数值。

还:

注意:Directions API 只能与
在 Google 地图上显示结果;使用路线数据而不
显示请求方向数据的地图是
禁止。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文