Add API to convert standard position (center/pitch/zoom/bearing) to FreeCameraOptions
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Currently there's no way to get a `FreeCameraOptions` object corresponding to a hypothetical map position defined in traditional terms (`center`, `zoom`, `pitch` and `bearing`), only for the current position.
I needed this to do a free-form interpolation between two cameras defined this way, and was able to achieve this through the hack of cloning the map transform, but there should be an easier API built-in:
```js
const fakeTransform = map.transform.clone();
fakeTransform.center = targetLngLat;
fakeTransform.zoom = targetZoom;
fakeTransform.bearing = targetBearing;
fakeTransform.pitch = targetPitch;
const targetCamera = fakeTransform.getFreeCameraOptions();
```
E.g. accepting options in `getFreeCameraOptions`:
```js
const camera = map.getFreeCameraOptions({bearing: 30, pitch: 10});
```
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 map.getFreeCameraOptions API and the map transform behavior shown in the issue, then trace how FreeCameraOptions is produced for the current position. Define the accepted standard position options and verify that the API returns the corresponding camera for center, zoom, pitch, and bearing, including the interpolation use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100