Skip to content

Search Module

Jakub Kracina edited this page Sep 6, 2019 · 7 revisions

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.

Inputs

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

Outputs

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

Examples

Search - Default

The most basic example. It shows the Search module with zero lines of configuration.

Search - Default

Code

let search = SYMKSearchViewController()

Browse Map with Search

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.

Search - with Browse Map

Code

let browseMap = SYMKBrowseMapViewController()
browseMap.setupActionButton(with: nil, icon: SYUIIcon.search) { [unowned self] in
    let searchModule = SYMKSearchViewController()
    presentModule(searchModule)
}
presentModule(browseMap)

Sample

Search Results on Map

This sample shows search results on the map as pins.

Search - results on map

Code

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
}

Sample

Prefill Search

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.

Search - prefill

Code

let searchModule = SYMKSearchViewController()
searchModule.searchCoordinates = SYGeoCoordinate(latitude: 48.147128, longitude: 17.103641)!
searchModule.maxResultsCount = 5
searchModule.prefillSearch(with: "Sygic")