close
Skip to content

RTFDB-4842: Improve user input handling in "mapbox-gl-geocoder" - #559

Open
pahuta wants to merge 2 commits into
RTFDB-4842-improve-user-input-handling-3from
RTFDB-4842-improve-user-input-handling-4
Open

RTFDB-4842: Improve user input handling in "mapbox-gl-geocoder"#559
pahuta wants to merge 2 commits into
RTFDB-4842-improve-user-input-handling-3from
RTFDB-4842-improve-user-input-handling-4

Conversation

@pahuta

@pahuta pahuta commented Aug 5, 2026

Copy link
Copy Markdown
  • Add function to parse different spatial formats which can be used to configure localGeocoder function
  • Add isValidTile, isValidQuadkey, tileToLngLat and quadkeyToTile helpers to lib/utils.js
  • Use the parsed zoom when flying to a selected feature that has no bbox
  • Fix the suggestion list not updating after cutting (Cmd/Ctrl+X) or undoing (Cmd/Ctrl+Z) a change to the search input

https://mapbox.atlassian.net/browse/RTFDB-4842

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • run npm run docs and commit changes to API.md
  • update CHANGELOG.md with changes under main heading before merging

Parsing extended spatial formats when enabled:

parseExtendedSpatialFormats.mp4

Previous vs current behavior when user cut or undo search input value

cut_undo.mp4

- Add optional `parseExtendedSpatialFormats` option with four independently
  toggled formats, all disabled by default: `commaSeparatedLngLatZoom`
  (`lng,lat,zoom`), `slashSeparatedZoomLatLng` (`zoom/lat/lng`),
  `tile` (`z/x/y`) and `quadkey`
- Add `lib/spatial-formats.js`, which turns a matching search input into a
  synthetic GeoJSON feature and prepends it to the suggestion list on both
  the successful and the failed request path
- Add `isValidTile`, `isValidQuadkey`, `tileToLngLat` and `quadkeyToTile`
  helpers to `lib/utils.js`
- Use the parsed zoom when flying to a selected feature that has no `bbox`
- Fix `getSelectedIndex` in `lib/events.js` reporting index 0 for every
  result feature without an `id`

https://mapbox.atlassian.net/browse/RTFDB-4842
@pahuta
pahuta marked this pull request as ready for review August 5, 2026 09:42
@pahuta
pahuta requested a review from a team as a code owner August 5, 2026 09:42
@pahuta
pahuta requested review from underoot and removed request for a team August 5, 2026 09:42
Comment thread debug/index.js Outdated
Comment thread lib/spatial-formats.js Outdated
- remove a `parseExtendedSpatialFormats` contractor parameter in favor of using a `localGeocoder`

https://mapbox.atlassian.net/browse/RTFDB-4842
@pahuta
pahuta requested a review from stepankuzmin August 10, 2026 15:14
Comment thread lib/index.js
this._hideAttribution();

// in the event of an error in the Mapbox Geocoding API still display results from the localGeocoder
if ((localGeocoderRes.length && this.options.localGeocoder) || (externalGeocoderRes.length && this.options.externalGeocoder) ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't that break the externalGeocoder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants