Be sure to sign up for an API key as described here. After you have a key configured in your app, use the main entry point, MapzenSearch
, for executing search-related queries.
Find a place by searching for an address or name.
private func search() {
let config = SearchConfig.init(searchText: "pizza") { (response) in
// display result
}
_ = MapzenSearch.sharedInstance.search(config)
}
Get real-time result suggestions with autocomplete.
private func autocomplete() {
let point = GeoPoint.init(latitude: 40.74433, longitude: -73.9903)
let config = AutocompleteConfig.init(searchText: "pizza", focusPoint: point) { (response) in
// display result
}
_ = MapzenSearch.sharedInstance.autocompleteQuery(config)
}
Find what is located at a certain coordinate location.
private func reverseGeo() {
let point = GeoPoint.init(latitude: 40.74433, longitude: -73.9903)
let config = ReverseConfig.init(point: point) { (response) in
// display result
}
_ = MapzenSearch.sharedInstance.reverseGeocode(config)
}
Get rich details about a place.
private func places() {
let config = PlaceConfig.init(gids: ["gid", "anotherGid"]) { (response) in
// display result
}
_ = MapzenSearch.sharedInstance.placeQuery(config)
}