-
Notifications
You must be signed in to change notification settings - Fork 2
Search Module
Search module offers you full text searching for points of interests, cities, streets etc. You can specify location at where places want to be found or maximum limit of results.
Inputs and outputs of the module serve as quick look for possibilities you can do with the module. For more information look at code and its documentation.
searchLocation: SYGeoCoordinate?
- GPS location in what location is searching. If the location is set to nil, it will search around the user GPS position
maxResultsCount: UInt
- maximum limit of results search will return
searchController(_ searchController: SYMKSearchViewController, didSearched results: [SYSearchResult])
Array of results search returned based on given query
searchControllerDidCancel(_ searchController: SYMKSearchViewController)
Delegate receives information, that user did cancel action
searchController(_ searchController: SYMKSearchViewController, willShowMessageFor searchError: Error) -> String?
Define own error messages for specific errors
The most basic example. It shows the Search module with zero lines of configuration.
let search = SYMKSearchViewController()
In this sample, browse module has a custom action button with a search icon. The search module is presented after a tap on the search button.
let browseMap = SYMKBrowseMapViewController()
browseMap.setupActionButton(with: nil, icon: SYUIIcon.search) { [unowned self] in
let searchModule = SYMKSearchViewController()
presentModule(searchModule)
}
presentModule(browseMap)
This sample shows search results on the map as pins.
let browseMap = SYMKBrowseMapViewController()
browseMap.setupActionButton(with: nil, icon: SYUIIcon.search) { [unowned self] in
let searchModule = SYMKSearchViewController()
searchModule.delegate = self
presentModule(searchModule)
}
presentModule(browseMap)
SYMKSearchViewControllerDelegate
protocol implementation:
func searchController(_ searchController: SYMKSearchViewController, didSearched results: [SYSearchResult]) {
// handle search results
}
func searchController(_ searchController: SYMKSearchViewController, willShowMessageFor searchState: SYRequestResultState) -> String? {
// handle error search states
}
This sample shows all possible inputs for the search module. You can set search coordinates, a maximum number of results and you can prefill search with some text.
let searchModule = SYMKSearchViewController()
searchModule.searchCoordinates = SYGeoCoordinate(latitude: 48.147128, longitude: 17.103641)!
searchModule.maxResultsCount = 5
searchModule.prefillSearch(with: "Sygic")