PlaceAutocomplete

public final class PlaceAutocomplete

Main entrypoint to the Mapbox Place Autocomplete SDK.

  • Basic internal initializer

    Declaration

    Swift

    public convenience init(
        accessToken: String? = nil,
        locationProvider: LocationProvider? = DefaultLocationProvider()
    )

    Parameters

    accessToken

    Mapbox Access Token to be used. Info.plist value for key MGLMapboxAccessToken will be used for nil argument

    locationProvider

    Provider configuration of LocationProvider that would grant location data by default

  • Undocumented

    See more

    Declaration

    Swift

    public struct Options
  • Values to filter Place Autocomplete results to include only a subset (one or more) of the available feature types.

    See more

    Declaration

    Swift

    public enum PlaceType : Equatable
  • Undocumented

    See more

    Declaration

    Swift

    public struct Result
  • Undocumented

    See more

    Declaration

    Swift

    public struct Suggestion
  • Start searching for query with provided options

    Declaration

    Swift

    public func suggestions(
        for query: String,
        region: BoundingBox? = nil,
        proximity: CLLocationCoordinate2D? = nil,
        filterBy options: Options = .init(),
        completion: @escaping (Swift.Result<[Suggestion], Error>) -> Void
    )

    Parameters

    query

    Text query for suggestions.

    region

    Limit results to only those contained within the supplied bounding box.

    proximity

    Optional geographic point that bias the response to favor results that are closer to this location.

    options

    Search options used for filtration.

    completion

    Result of the suggestion request, one of error or value.

  • Start searching for query with provided options

    Declaration

    Swift

    public func suggestions(
        for query: CLLocationCoordinate2D,
        filterBy options: Options = .init(),
        completion: @escaping (Swift.Result<[Suggestion], Error>) -> Void
    )

    Parameters

    query

    Coordinates query.

    options

    Search options used for filtration.

    completion

    Result of the suggestion request, one of error or value.

  • Retrieves detailed information about the PlaceAutocomplete.Suggestion. Use this function to end search session even if you don’t need detailed information.

    Subject to change: in future, you may be charged for a suggestion call in case your UX flow accepts one of suggestions as selected and uses the coordinates, but you don’t call select(suggestion:completion:) method to confirm this. Other than that suggestions calls are not billed.

    Declaration

    Swift

    public func select(
        suggestion: Suggestion,
        completion: @escaping (
            Swift.Result<PlaceAutocomplete.Result, Error>
        ) -> Void
    )

    Parameters

    suggestion

    Suggestion to select.

    completion

    Result of the suggestion selection, one of error or value.