Open captainbarbosa opened 6 years ago
+1 this would be very helpful.
I'm not an experienced iOS developer and want to use Mapbox for a new Swift project. The lack of documentation around this specific interaction is making me fallback to MapKit rather than Mapbox, which has a fair amount of documentation (both official and unofficial) around this.
Putting this example in mapbox/ios-sdk-examples#17 would give it more visibility (i.e., on this examples site).
Please wherever do it because there is no clear way to do that. For example I have a search for addresses, I already have the country selected but I need to search streets by name and autocomplete.
Is this feature still not implemented? I already created an app on the Android side and currently converting it to iOS only to find out a key feature such as this isn't really documented and seems to be pushed aside constantly.
This library already provides much of the functionality needed to implement an autocompleting search UI; this ticket only tracks adding an example of doing so. Compared to Android, it’s more straightforward on iOS to set up a standard search UI, and you’d benefit from all the UI customization hooks that would be available as a result. The steps look something like this:
Geocoder.geocode(_:completionHandler:)
in response to UISearchResultsUpdating.updateSearchResults(for:)
. Here’s an example set of options to use:
let options = ForwardGeocodeOptions(query: text)
options.locale = .autoupdatingCurrent
options.allowedScopes = [.address, .pointOfInterest]
options.maximumResultCount = 10
options.focalLocation = location
tableView(_:cellForRowAt:)
, configure a UITableViewCell (or a custom subclass) to display details about the placemark.This Apple example shows how to do it using MapKit, but the types and principles are similar when using MapboxGeocoder.swift. Hope this gives you a decent starting point!
An example of how to use MapboxGeocoder.swift's autocomplete functionality with a
UISearchController
would be particularly useful.