【问题标题】:iOS google maps directions API used in code代码中使用的 iOS 谷歌地图方向 API
【发布时间】:2011-12-24 16:40:47
【问题描述】:

我正在尝试从这样的示例查询中获取 XML 结果: http://maps.googleapis.com/maps/api/directions/xml?origin=Toronto,ON&destination=Manhattan,NY&dirflg=r&sensor=false

在我的程序中。有没有办法在 Objective-C 代码中获取 XML 结果?我不希望我的应用程序打开地图应用程序。我希望能够接收 XML。我的应用程序中确实有一个 MapKit。

【问题讨论】:

    标签: iphone objective-c ios google-maps directions


    【解决方案1】:

    当然。只需执行以下操作:

    NSXMLParser * xmlParser = 
        [[NSXMLParser alloc] initWithContentsOfURL: [NSURL URLWithString: @"http://maps.googleapis.com/maps/api/directions/xml?origin=Toronto,ON&destination=Manhattan,NY&dirflg=r&sensor=false"];
    

    Apple documentation for NSXMLParser is here

    对于您的目的而言,这可能有点过于繁重,因此您也可以执行answers provided for in this duplicate question 之类的操作。

    【讨论】:

    • 啊,太好了。你知道为什么 'dirflg=r' 参数(切换到公共交通)不起作用吗?
    • 不是我的头脑,而是发布一个不同的问题,我或其他人可以为你想出一个快速的答案。
    猜你喜欢
    • 2015-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 2013-03-26
    • 1970-01-01
    相关资源
    最近更新 更多