Classes
The following classes are available globally.
-
Logger implementation for internal usage
See moreDeclaration
Swift
public class _Logger
-
Local data storage for Codable-complience records. The data will be preserved in “Application Support” folder in application container
See moreDeclaration
Swift
open class CodablePersistentService<Record> where Record : Decodable, Record : Encodable
-
Returns user location in energy efficient approach.
Would not trigger Location Permission dialogs but will retrieve permission changes notification. Suitable for
See moreSearchEngine
for providing user location by default without additional efforts.Declaration
-
Common root for
See moreSearchEngine
andCategorySearchEngine
. Should never be instantiated directlyDeclaration
Swift
public class AbstractSearchEngine : FeedbackManagerDelegate
-
Category Search Engine used specifically for category search Checkout
See moreSearchEngine
for more detailsDeclaration
Swift
public class CategorySearchEngine : AbstractSearchEngine
-
An entry object for online search with autocomplete suggestions powered by Mapbox Search services
SearchEngine requires Mapbox Access Token with any scope and visibility. We recommend to pass your token through
MBXAccessToken
key in application’sInfo.plist
to share the token with the Mapbox SDKs. You may choose to provide the accessToken as a parameter value instead.You must always assign
delegate
to receive search results provided by the engine. Update theSearchEngine.query
value to start or continue your search experience. It is possible to updatequery
value in real-time as the user types because the actual requests have a debounce logic.Listing 1 Create you first search request
let engine = SearchEngine() engine.delegate = self engine.query = "Mapbox"
Implement
SearchEngineDelegate
protocol to receive updates and search results with coordinates data. Pay attention that SearchEngine provides a list ofSearchSuggestion
which doesn’t include coordinates information.Listing 2 Implement
SearchEngineDelegate
protocolextension ViewController: SearchEngineDelegate { func resultsUpdated(searchEngine: SearchEngine) { displaySearchResults(searchEngine) } func resolvedResult(result: SearchResult) { presentSelectedResult(result) } func searchErrorHappened(searchError: SearchError) { presentSearchError(searchError) } }
Retrieve coordinates
Call
select(suggestion: SearchSuggestion)
when a customer makes a choice from the search results list to receive aSearchResult
with populated coordinates field. You can expect a resolved search result with populated coordinates to be returned inSearchEngineDelegate.resolvedResult(result: SearchResult)
delegate method.Listing 3 Select search result
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let suggestion = searchSuggestions[indexPath.row] dataSource.select(suggestion: suggestion) } … // SearchEngineDelegate implementation func resolvedResult(result: SearchResult) { presentAnnotationAt(coordinate: result.coordinate, title: result.name, subtitle: result.address?.formattedAddress(style: .medium)) }
Note
SearchEngine may respond with category suggestion. Selecting such suggestion would produce a new set of search results.Location bias
Location is strongly recommended for accurate search results. By default,
SearchEngine
would anticipateDefaultLocationProvider
to fulfill location data.DefaultLocationProvider
would receive location updates if application already have a location permission. The default implementation declare low accuracy for better battery efficiency. It’s possible to provide exact coordinate for search request withsearch(query:options:)
function. Engine will reuse these coordinates on each search request. To reset to default LocationProvider behavior, callsearch(query:options:)
with nil proximity inSearchRequest
.Listing 4 Provide search coordinate
See morelet engine = SearchEngine() engine.search(query: "mapbox", options: SearchOptions(proximity: CLLocationCoordinate2D(latitude: 38.8998315, longitude: -77.0346164)))
Declaration
Swift
public class SearchEngine : AbstractSearchEngine
extension SearchEngine: IndexableDataResolver
-
Search records data provider with local storage
See moreDeclaration
Swift
public class LocalDataProvider<Record> : IndexableDataProvider where Record : IndexableRecord, Record : SearchResult, Record : Decodable, Record : Encodable
-
Basic location provider which returns the same coordinate on each request
See moreDeclaration
Swift
open class PointLocationProvider : LocationProvider
-
OfflineManager handles
See moreTileStore
s and responsible for creating SearchTilsetDescriptor
sDeclaration
Swift
public class SearchOfflineManager
-
Simple wrapper for
MapboxCommon.TileStore
.This instance provides basic
TileStore` functionality for a rare case when someone using Offline search without other Mapbox frameworks.Use
See morecommonTileStore
property to access underlayingMapboxCommon.TileStore
Declaration
Swift
public class SearchTileStore
-
Represents navigation route that consist of the set of coordinates
See moreDeclaration
Swift
public class Route : Codable, Hashable
-
Search Response information. Contains search options. This response can be used for sending Missing Result feedback. One should build
See moreFeedbackEvent
usingSearchResponseInfo
SearchEngine.sendFeedback(event: FeedbackEvent, autoFlush: Bool = true) throws
Declaration
Swift
public class SearchResponseInfo
-
Services provider for SearchEngine
See moreDeclaration
Swift
public class ServiceProvider : ServiceProviderProtocol
-
Report search error or any other to the Mapbox telemetry.
That will help us to investigate issues related to search and search quality.
See moreDeclaration
Swift
public class EventsManager : NSObject
-
User Feedback event build based on SearchSuggestion or SearchResult. Does a result or suggestion have any problem with naming, location or something else? Please send feedback describing the issue! Can be sent by calling
See moresendFeedback(event:)
method of any SearchEngine instance.Declaration
Swift
public class FeedbackEvent
-
Profile feedback or build custom events for Mapbox Telemetry
See moreDeclaration
Swift
public class FeedbackManager
-
Undocumented
See moreDeclaration
Swift
public final class AddressAutofill
-
Undocumented
See moreDeclaration
Swift
public final class Discover
-
Main entrypoint to the Mapbox Place Autocomplete SDK.
See moreDeclaration
Swift
public final class PlaceAutocomplete