Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different values of bearing causes zoom to reset the bearing #13284

Open
azro352 opened this issue Sep 19, 2024 · 0 comments
Open

Different values of bearing causes zoom to reset the bearing #13284

azro352 opened this issue Sep 19, 2024 · 0 comments

Comments

@azro352
Copy link

azro352 commented Sep 19, 2024

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

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 <div ref={mapContainerRef} id="map" style={{ height: "100%", minHeight: 700 }}></div>;
};

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant