Closed TreTuna closed 2 years ago
Thanks for sharing this new feature. Is there an easy way to test this locally?
Thanks for sharing this new feature. Is there an easy way to test this locally?
Sure! If you have a sample app using the geocoder, you just need to add a fake getSuggestions
API function into your geocodeApi
object that's passed in. It doesn't need to call an API, just needs to return an array of strings that would be added to the results box.
You can see an example of how we're integrating it with our Amplify plugin here: https://github.com/aws-amplify/maplibre-gl-js-amplify/blob/main/src/AmplifyMapLibreGeocoder.ts
Adds This PR brings functionality for a suggestions API.
getSuggestions
API function togeocoderApi
objectgetSuggestions
api is available,showResultsWhileTyping
will default totrue
and show bothgeocode
andsuggestion
resultsgeocode
results while typing.results
, we looked at this, but since it would have been a breaking change to rename that, we did not proceed there.suggestionsOnlyWhileTyping
flag - Combined with the previous, this allows the state where a developer only wants to see suggestionsprocessResutls
function to theoptions
object that is used to filter, sort, combine, and limit results offorwardGeocode/reverseGeocode
andgetSuggestions
processResults
function:suggestions
strings that are duplicated ingeocode
results, compared with geocodefeature.label
filteredSuggestions
first, followed by search resultsoptions.limit
evenly between the twooptions.limit
is an odd number, show 1 moregeocode
result than suggestionsuggestions
orgeocode
results to fill to limit, then add more of the other until limit is reachedAutoSuggest with Geocode on typing:
AutoSuggest only on typing:
npm run docs
and commit changes to API.mdmaster
heading before merging