mapbox / mapbox/mapbox-gl-geocoder

Error thrown in onChange function in latest versions

Open
#420 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug
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:

![Screen Shot 2021-06-17 at 11 12 06 AM](https://user-images.githubusercontent.com/6536941/122424996-2aafbb00-cf5d-11eb-88dc-00caef455e4f.png)

Package Versions:
```json
"@mapbox/mapbox-gl-geocoder": "4.7.1",
"mapbox-gl": "2.2.0",
```

Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.