mapbox-gl-geocoder icon indicating copy to clipboard operation
mapbox-gl-geocoder copied to clipboard

API.md parameters options.type misleading and incorrect.

Open CodeZeno opened this issue 5 years ago • 3 comments

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.

CodeZeno avatar Nov 28 '19 00:11 CodeZeno

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)

andrewharvey avatar Nov 28 '19 00:11 andrewharvey

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.

CodeZeno avatar Nov 28 '19 00:11 CodeZeno

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.

andrewharvey avatar Nov 28 '19 03:11 andrewharvey