search Places
Searches places matching the query text, optionally biased by a coordinate circle and a category, so a nomination can carry a canonical place id instead of a hand-typed name.
Use it behind the nomination form's search box. The server answers an empty list for queries under three characters - debounce the text field (for example 300 ms after the last keystroke) and hold back short queries client-side. Bias the search with the map center or the member's location, then record the place the member picks with rememberPlaceSearch.
Android (Kotlin)
// Called from a debounced text field.
fun onQueryChanged(query: String) {
if (query.length < 3) return
lifecycleScope.launch {
try {
val suggestions = AFCore.locations().searchPlaces(
query = query,
latitude = center.latitude,
longitude = center.longitude,
radiusMeters = 25_000.0
)
showSuggestions(suggestions)
} catch (t: Throwable) {
showError(t)
}
}
}iOS (Swift)
// Called from a debounced text field.
func onQueryChanged(_ query: String) {
guard query.count >= 3 else { return }
Task {
do {
let suggestions = try await AFCore.shared.locations().searchPlaces(
query: query,
latitude: KotlinDouble(value: center.latitude),
longitude: KotlinDouble(value: center.longitude),
radiusMeters: KotlinDouble(value: 25_000.0),
categoryCode: nil
)
showSuggestions(suggestions)
} catch {
showError(error)
}
}
}Return
The list of PlaceSuggestion.
Parameters
Search text, at least three characters.
Optional latitude to bias towards; pair with longitude.
Optional longitude to bias towards.
Optional radius of the bias circle in meters.
Optional category code to bias towards.
Throws
if the search request fails.