CQGoogleDirections 0.1.8

CQGoogleDirections 0.1.8

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released上次发布Nov 2015
SPM支持 SPM

Lukasz Solniczek 维护。



  • Lukasz Solniczek

CQGoogleDirections

CQGoogleDirections 是一组用于简化使用 Google Directions API 的类。它将响应 JSON 转换为可供在您的应用程序中使用的一系列方便的对象。

使用方法

开始使用 CQGoogleDirections 只需两行代码。

创建 CQGoogleDirections 对象
let directionAPI = CQGoogleDirections(from: CLLocationCoordinate2D(latitude: 52.237800, longitude: 21.049662), to: CLLocationCoordinate2D(latitude: 52.226974, longitude: 21.056588), wayPoints: nil)
运行 API 请求并处理返回
directionAPI.calculateDirections { response in
    switch response.result {
    case .Success:
        print(response.routes)
    case .Failure(_):
        print("Error")
    }
}
访问 CQRoute 对象

CQRoute 是主要对象,用于封装关于 overviewPolylinesboundslegs 的信息。要访问 CQRoute,您需要

case .Success:
    if let routes = response.routes as CQRoutes? {
        //use routes object
    }

需求

  • 至少在 iOS 8 及更高版本上运行。
  • 与 Swift 2.0 / Xcode 7 及更高版本兼容。

安装

然后在终端中运行以下命令:

pod install

现在,您应该可以从代码中简单地导入模块,例如

import CQGoogleDirections

待办事项

  1. 为所有 Google Directions API 参数添加服务
  2. 处理 Google Directions API 错误
  3. 编写测试
  4. 创建更好的库示例

作者

Lukasz Solniczek, l(dot)solniczek(at)gmail(dot)com

许可证

CQGoogleDirections 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。