一个 Swift 库,用于在你的应用程序中快速集成位置搜索功能。
使用 Cocoapods 安装
pod 'AtlasKit'
快速开始
首先,使用数据源创建 AtlasKit
对象:Apple、Google 或 GetAddress.io。使用 Apple 数据源的 AtlasKit 实例将尝试使用 Apple 地图来获取位置,而使用 Google 或 GetAddress 数据源的实例在初始化时需要一个 API 密钥,并尝试使用相应的 API(Google Places 或 GetAddress)。
一旦你设置好你的实例,你就可以开始发出搜索请求,你可以选择带延迟或不带延迟的方式进行(适用于在你输入时进行搜索的文本框)。
atlasKit.performSearchWithDelay(term, delay: 0.5) { predictions, error in
...
}
atlasKit.performSearch(term) { { predictions, error in
...
}
你也可以取消所有待处理的搜索,通过以下方式:
atlasKit.cancelSearch()
搜索预测结果是 AtlasKitPlace
对象的实例,该对象包含:街道地址、城市、邮政编码、州、国家、位置(坐标)。请注意,这些值都是可选的,可能并非总是可用。
警告 - 此库仅用于英国地区,因此英国以外地区不支持邮政编码值。