测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新版本 | 2017年11月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由Ryan Coyne维护。
要运行示例项目,请首先克隆仓库,并在 Example 目录下运行 pod install
。
从那里,你可以在 AppDelegate 中设置一个断点,我们调用 Nearby Places API 并给出响应,看看这个 Cocoapod 是否对你有用。
CCXGoogleNearbyPlaces 通过 CocoaPods 提供。要安装
它,只需将以下行添加到你的 Podfile 中
pod 'CCXGoogleNearbyPlaces'
一旦你下载并成功构建了该模块,请转到你的 AppDelegate 文件并导入 CCXGoogleNearlyPlaces 模块。
然后你需要确保你有一个 API 密钥来使用这个 Cocoapod。请参考以下内容以获得你的 API 密钥
一旦你从以上链接中获得有效的 API 密钥,你将设置你的 api 密钥如下
CCXGoogleSDK.places.apiKey = "Your API Key"
你可以用几种方式使用 CCXGoogleNearbyPlaces Pod 来获取结果。你可以使用带有距离、从位置传入的文本参数。API 返回 20 个结果。在响应对象中,我们将指出是否可以加载更多对象。你可以通过只传入下一个页面标记来加载下一页。
获取所有以半径和位置坐标为中心的附近地点,并带有文本参数
let coord = CLLocationCoordinate2D()
// Radius is in meters.
CCXGoogleSDK.places.get(withText: "restaurants", withRadius: 300.4, coordinate: coord) { response in
if response.status.isSuccess {
if response.places.isNotNil {
if response.canLoadMore {
// You should only use the pageToken in the get function on your next request.
self.queueForNextLoad = true
}
// Deal with the places:
print(response.places!)
}
} else if response.error.isNotNil {
//
print(response.error!)
}
}
获取所有以半径和位置坐标为中心的附近地点
let coord = CLLocationCoordinate2D()
// Radius is in meters.
CCXGoogleSDK.places.get(withRadius: 300.4, coordinate: coord) { response in
if response.status.isSuccess {
if response.places.isNotNil {
if response.canLoadMore {
// You should only use the pageToken in the get function on your next request.
self.queueForNextLoad = true
}
// Deal with the places:
print(response.places!)
}
} else if response.error.isNotNil {
//
print(response.error!)
}
}
获取带有下一个页面标记的附近地点
CCXGoogleSDK.places.get(pageToken: "nextPageToken") { (response) in
if response.status.isSuccess {
if response.places.isNotNil {
if response.canLoadMore {
// You should only use the pageToken in the get function on your next request.
self.queueForNextLoad = true
}
// Deal with the places:
print(response.places!)
}
} else if response.error.isNotNil {
//
print(response.error!)
}
}
获取你附近的特定类型或类别的地点
CCXGoogleSDK.places.get(withRadius: 200.4, coordinate: coord, category: .hairCare) { (response) in
if response.status.isSuccess {
if response.places.isNotNil {
if response.canLoadMore {
// You should only use the pageToken in the get function on your next request.
}
// Deal with the places:
print(response.places!)
}
} else if response.error.isNotNil {
//
print(response.error!)
}
}
Google 文档链接
ryancoyne, [email protected]
CCXGoogleNearbyPlaces采用MIT许可证。有关更多信息,请参阅LICENSE文件。