Repository navigation
Conversation
- 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
stepankuzmin
reviewed
Aug 5, 2026
stepankuzmin
reviewed
Aug 5, 2026
- remove a `parseExtendedSpatialFormats` contractor parameter in favor of using a `localGeocoder` https://mapbox.atlassian.net/browse/RTFDB-4842
| 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) ) { |
Contributor
There was a problem hiding this comment.
Doesn't that break the externalGeocoder?
Author
There was a problem hiding this comment.
No - that branch was already dead code for externalGeocoder before the removal. At that point externalGeocoderRes:
- holds an empty array (initial value) if the geocoding request failed the very first time
- holds a Promise (from
this.options.externalGeocoder(...) || Promise.resolve([])), not a resolved array, soexternalGeocoderRes.lengthwas always undefined/falsy.
The condition could never be satisfied through the externalGeocoder side. So removing it doesn't change behavior for externalGeocoder at all.
|
|
||
| - Fix reverse geocoding errors caused by leading/trailing whitespace in coordinate input (e.g. `"48.774989, 9.155557 "`) | ||
| - Fix an error message not being shown when pasting an invalid value directly (e.g. via keyboard shortcut), instead of typing it character by character | ||
| - Fix the suggestion list not updating after cutting (Cmd/Ctrl+X) or undoing (Cmd/Ctrl+Z) a change to the search input |
Comment on lines
+80
to
+85
| var spatialFeatures = [ | ||
| spatialFormats.parseSlashSeparatedZoomLatLng(query), | ||
| spatialFormats.parseCommaSeparatedLngLatZoom(query), | ||
| spatialFormats.parseTile(query), | ||
| spatialFormats.parseQuadkey(query) | ||
| ].filter(Boolean); |
Contributor
There was a problem hiding this comment.
If we want to have built-in local geocoders, we need to expose them so they are available on the imported object, e.g. something like:
const {slashSeparatedZoomLatLng, commaSeparatedLngLatZoom, tile, quadkey} = MapboxGeocoder.localGeocoders;…and then we can use them like:
Suggested change
| var spatialFeatures = [ | |
| spatialFormats.parseSlashSeparatedZoomLatLng(query), | |
| spatialFormats.parseCommaSeparatedLngLatZoom(query), | |
| spatialFormats.parseTile(query), | |
| spatialFormats.parseQuadkey(query) | |
| ].filter(Boolean); | |
| return [ | |
| slashSeparatedZoomLatLng(query), | |
| commaSeparatedLngLatZoom(query), | |
| tile(query), | |
| quadkey(query), | |
| coordinatesGeocoder(query) | |
| ].filter(Boolean); |
| ); | ||
|
|
||
| var MapboxGeocoder = require('../'); | ||
| var spatialFormats = require('../lib/spatial-formats'); |
Contributor
There was a problem hiding this comment.
Suggested change
| var spatialFormats = require('../lib/spatial-formats'); | |
| const {slashSeparatedZoomLatLng, commaSeparatedLngLatZoom, tile, quadkey} = MapboxGeocoder.localGeocoders; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
localGeocoderfunctionisValidTile,isValidQuadkey,tileToLngLatandquadkeyToTilehelpers tolib/utils.jsbboxhttps://mapbox.atlassian.net/browse/RTFDB-4842
npm run docsand commit changes to API.mdmainheading before mergingParsing extended spatial formats when enabled:
parseExtendedSpatialFormats.mp4
Previous vs current behavior when user cut or undo search input value
cut_undo.mp4