[BUG] Different values of bearing causes zoom to reset the bearing
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: `"mapbox-gl": "^3.6.0"`
**browser**: `chrome 128.0.6613.138`
### Steps to Trigger Behavior
1. take the example https://docs.mapbox.com/mapbox-gl-js/example/georeference-imagery/
2. add a bearing of 6
3. zoom on the map
4. the bearing is reset
Whereas you set the bearing to 7, you zoom, bearing doesn't change
### Link to Demonstration
```ts
import { useEffect, useRef } from "react";
import mapboxgl from "mapbox-gl";
import "mapbox-gl/dist/mapbox-gl.css";
export const MapboxExample = () => {
const mapContainerRef = useRef();
const mapRef = useRef();
useEffect(() => {
mapboxgl.accessToken = "ACCESS_TOKEN";
mapRef.current = new mapboxgl.Map({
container: mapContainerRef.current,
style: "mapbox://styles/mapbox/streets-v12",
center: [-122.619991, 45.536023],
zoom: 10.5,
bearing: 6,
});
mapRef.current.on("load", () => {
mapRef.current.addSource("portland", { type: "raster", url: "mapbox://examples.32xkp0wd", });
mapRef.current.addLayer({id: "portland", source: "portland", type: "raster", });
});
return () => mapRef.current.remove();
}, []);
return
;};
```
### Expected Behavior
You zoom in/out or drag the map and the bearing doesn't change
### Actual Behavior
When you zoom in/out or drag the map, with some bearing value (I saw it with bearing less then 6), then the bearing is reset and you see the map rotate as like there is no bearing setting set
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 georeference imagery example linked in the issue and reproduce the behavior with bearing 6, then compare it with bearing 7 while zooming or dragging. Trace the map camera handling involved in those interactions; done means zooming, zooming out, and dragging preserve the configured bearing for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100