Skip to main content

Search by Coordinate

Search by Coordinate

The Search SDK simplifies the process of performing a coordinate search that will return addresses, places, or Points of Interest (POIs) around a specific geographical coordinate.

Installation guide

Before utilizing any of Mapbox's Search products, there are some common installation steps that you need to follow. Refer to this guide, and then go ahead with the steps outlined below.

  1. The PlaceAutocomplete class serves as the primary access point for implementing coordinate search functionality. To begin, you must first create an instance of this class. You can do this by using the following Swift code:
let placeAutocomplete = PlaceAutocomplete(accessToken: mapboxAccessToken)
  1. To retrieve autocomplete suggestions based on a specific geographical location, you should provide the geographic coordinates represented by the CLLocationCoordinate2D type. Here's how you can do it:
let searchCoordinates: CLLocationCoordinate2D = prepareSearchCoordinates()
placeAutocomplete.suggestions(for: searchCoordinates) { result in ... }
  1. After initiating a request for autocomplete suggestions, you'll need to handle the response from the suggestions() method. This function will either return an error or a list of suggestions. Here's how you can process the response:
placeAutocomplete.suggestions(for: query) { result in
switch result {
case .success(let suggestions):

case .failure(let error):
API Reference

For more information, see the full API reference for the iOS Search SDK.

Was this page helpful?