mapbox / mapbox/mapbox-gl-geocoder
Add a mapboxgl.EventData option, pass to 'map.fitBounds' and 'map.flyTo'
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 388
- Forks
- 181
- PR merge metrics
- No merged PRs in 30d
Description
Camera move functions can have additional `eventData` passed to them, which is passed to event listeners of camera events ('move', 'zoom', etc)
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#flyto
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#fitbounds
This is useful for behaviour customization, but very useful for detecting whether a camera event was triggered by the user or programatically, as discussed here [mapbox-gl-js/issues/9700](https://github.com/mapbox/mapbox-gl-js/issues/9700)
This library already has a single function that initializes all camera moves, [_fly](https://github.com/mapbox/mapbox-gl-geocoder/blob/main/lib/index.js#L533), with two usages of `fitBounds` and one usage of `flyTo`.
Adding an `eventData` argument (which is just a user defined object) to these invocations (as the 2nd/3rd parameter respectively) works as expected. Passing `undefined` as `eventData` works as expected, too, there is no change compared to the current behaviour and events are not modified.
The `eventData` could be supplied by the user through the geocoder initialization options, as well as through a function that could update it after instance creation.
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 with the _fly function in lib/index.js and review its two fitBounds calls and one flyTo call, then compare their argument requirements with the linked Mapbox GL JS documentation. Done should mean eventData can be supplied through the geocoder API and is forwarded to camera-event listeners without changing behavior when omitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100