mapbox / mapbox/mapbox-gl-geocoder

Add a mapboxgl.EventData option, pass to 'map.fitBounds' and 'map.flyTo'

Open
#478 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.