TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Ryan Coyne.
To run the example project, clone the repo, and run pod install
from the Example directory first.
From there, you may set a breakpoint in the AppDelegate where we call to the Nearby Places API and give a response & see if this is a cocoapod that could be of use for you.
CCXGoogleNearbyPlaces is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'CCXGoogleNearbyPlaces'
Once you have downloaded and successfully built the module, go to your AppDelegate file and import the CCXGoogleNearlyPlaces module.
You will then need to go and make sure you have an API key to use the cocoapod. Please reference the following to obtain your API key:
Once you have obtained a valid API key from the link above, you will set your api key as the following:
CCXGoogleSDK.places.apiKey = "Your API Key"
There are a few ways you can fetch results with the CCXGoogleNearbyPlaces pod. You may use a text parameter with a distance, from a location. The API returns 20 results. In the response object we will indicate whether or not you can load more objects. You may load the next page by only passing in the next page token on your next request.
Get all the nearby places with a radius & a location coordinate, and a text parameter:
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!)
}
}
Get all the nearby places with only a radius & a location coordinate:
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!)
}
}
Get all the nearby places with your next page token:
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!)
}
}
Get places around you with a specific type or category:
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 Documentation links:
ryancoyne, [email protected]
CCXGoogleNearbyPlaces is available under the MIT license. See the LICENSE file for more info.