mapbox / mapbox/mapbox-gl-geocoder
Error thrown in onChange function in latest versions
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 388
- Forks
- 181
- PR merge metrics
- No merged PRs in 30d
Description
There is an error thrown in the onChange function of the geocoder. I discovered it when trying to add an `.on('result', (e) => {})` function to my `geocoder` instance. the `.on('result', (e) => {})` function does not get emitted because an error occurs in a block before it in the `onChange` function
```
_handleMarker: function(selected){
...
this.mapMarker = new this._mapboxgl.Marker(markerOptions);
...
}
```
called from
```
_onChange: function() {
...
if (this.options.marker && this._mapboxgl){
this._handleMarker(selected);
}
...
}
```
Heres the error:

Package Versions:
```json
"@mapbox/mapbox-gl-geocoder": "4.7.1",
"mapbox-gl": "2.2.0",
```
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the _onChange entry point and its _handleMarker call, then reproduce with @mapbox/mapbox-gl-geocoder 4.7.1 and mapbox-gl 2.2.0 while marker handling is enabled. Use the reported error to identify why the result event is not emitted; done means the onChange path completes and the .on('result', ...) handler fires without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100