MapboxSearchController
public class MapboxSearchController : UIViewController
extension MapboxSearchController: SearchEngineDelegate
Provides built-in location search functionality powered by Mapbox
-
Custom search bar placeholder
Declaration
Swift
public var searchBarPlaceholder: String? { get set }
-
Provider of customer’s favorite records
Declaration
Swift
public var favoritesProvider: FavoritesProvider
-
Provider of recent searches
Declaration
Swift
public var historyProvider: HistoryProvider
-
Actual
CategorySearchEngine
used for category search requestsDeclaration
Swift
public var categorySearchEngine: CategorySearchEngine
-
Actual
SearchEngine
used for query-based searchesDeclaration
Swift
public var searchEngine: SearchEngine { get set }
-
Options used to customize search, nil by default.
Declaration
Swift
public var searchOptions: SearchOptions?
-
Options used to customize category search, nil by default.
Declaration
Swift
public var categorySearchOptions: SearchOptions?
-
Structure to configure MapboxSearchController UI and logic
Declaration
Swift
public var configuration: Configuration { get set }
-
The object that the search controller calls with the result of user actions
Declaration
Swift
public weak var delegate: SearchControllerDelegate?
-
Instantiate MapboxSearchController with explicit accessToken and custom location provider
Declaration
Swift
public required init(accessToken: String, configuration: Configuration = Configuration())
Parameters
accessToken
Mapbox public access token. Checkout
init(locationProvider:)
toconfiguration
configuration for search and categorySearch engines.
-
MapboxSearchController initializer with accessToken taken from application Info.plist
Access token is expected to be at
MGLMapboxAccessToken
key in application Info.plist. Missing accessToken will trigger fatalErrorDeclaration
Swift
public required init(configuration: Configuration = Configuration())
Parameters
configuration
configuration for search and categorySearch engines.
-
Make initial UI
Declaration
Swift
override public func viewDidLoad()
-
Restart listening services on screen appearance
Declaration
Swift
override public func viewWillAppear(_ animated: Bool)
-
Pause listening services on screen disappearance
Declaration
Swift
override public func viewDidDisappear(_ animated: Bool)
-
Presentation styles for MapboxSearchController. Non-animated
See moreDeclaration
Swift
public enum PresentationStyle
-
Get access to the
MapboxPanelController
for.panel
presentation styleDeclaration
Swift
public var panelController: MapboxPanelController? { get }
-
Show Mapbox Search Controller inside of target view controller
Declaration
Swift
public func present(in rootVC: UIViewController, presentationStyle: PresentationStyle = .panel)
Parameters
rootVC
ViewController to be root of Search Controller
presentationStyle
Choose one of the presentation styles. Default is
.panel
-
Reset MapboxSearchController state recursively
Declaration
Swift
public func resetSearchUI(animated: Bool, collapse: MapboxPanelController.State? = .collapsed)
Parameters
animated
Should changes be animated
collapse
Change the collapsing status. Pass
nil
to not apply status changes. Default:.collapsed
-
Update suggestion table or show empty suggestions view.
Declaration
Swift
public func suggestionsUpdated(suggestions: [SearchSuggestion], searchEngine: SearchEngine)
-
Declaration
Swift
public func offlineResultsUpdated( _ results: [SearchResult], suggestions: [SearchSuggestion], searchEngine: SearchEngine )
-
Preserve result in the
historyProvider
and pass object to thedelegate
.Declaration
Swift
public func resultResolved(result: SearchResult, searchEngine: SearchEngine)
-
Display search error on results table view.
Declaration
Swift
public func searchErrorHappened(searchError: SearchError, searchEngine: SearchEngine)