mapbox-gl-geocoder
mapbox-gl-geocoder copied to clipboard
API.md parameters options.type misleading and incorrect.
The API.md needs updating.
Under options.types
it states:
If reverseGeocode is enabled, you should specify one type. If you configure more than one type, the first type will be used.
This is misleading and incorrect. If you specify only one type and there are no results for that type you will get the message "No results found". You can and should specify multiple types in order of preference.
However "Consequently, setting limit to a higher-than-default value requires specifying exactly one types parameter." mapbox-gl-geocoder sets the limit by default to 5, hence requires exactly one types value. (from https://docs.mapbox.com/api/search/#reverse-geocoding)
Using latitude: 1.3, longitude: 103.8 with options.reverseGeocode
set to true, options.limit
set to 5 and option.types
set to "locality" I get "No results found".
If I change option.types
to "locality, neighborhood, district, country" I get Singapore.
Oh right, I see, it looks like mapbox-gl-geocoder is setting limit to 1, when reverse geocoding. You're correct that you can specify multiple types and it will fallback. Did you want to submit a PR? I'm happy to help review it.