I'm trying to build a autocomplete textfield which needs to display the city/town name only.
So what I want to do is that when someone enters
Am it will show
Amsterdam
Amstelveen
So it will only display the actual city names and nothing beyond that. It doesn't need to take places neighbourhoods etc into consideration.
I've applied a filter already but this doesn't fix it.
lazy var searchCompleter: MKLocalSearchCompleter = {
let sC = MKLocalSearchCompleter()
sC.delegate = self
sC.filterType = .locationsOnly
return sC
}()
func completerDidUpdateResults(_ completer: MKLocalSearchCompleter) {
self.searchSource = completer.results.map { $0.title }
DispatchQueue.main.async {
for result in self.searchSource! {
print(result)
}
}
}
func completer(_ completer: MKLocalSearchCompleter, didFailWithError error: Error) {
print(error.localizedDescription)
}
Does anyone know if it's possible to achieve what I want?
from Search for Place Names (City/Town) Using MKLocalSearchCompleter
No comments:
Post a Comment