Skip to content

Map isn't respecting passed in boundsΒ #13620

@robw-forensic-analytics

Description

mapbox-gl-js version

Latest

Expected behavior

We are building an application using mapbox where the map bounds can be shared across multiple users. We've found that when passing in a set of bounds to initalize a map, that there are differences across the shared bounding boxes, even though the map is being opened in the same browser, with the same size of map.

Steps to trigger the unexpected behavior

Using the below code take the console output and replace the bounds with that output, whilst maintaining the same size of map, at that point I'm expecting map.getBounds() to return the same as the passed in bounds -

const map = new mapboxgl.Map({
    container: 'map', 
    style: 'mapbox://styles/mapbox/standard',
    bounds: new mapboxgl.LngLatBounds(
        {lat: 51.982898278386415, lng: 0.5317321224441969},
        {lat: 51.90657505892173, lng: 0.21361845136780744}
    ),
    fitBoundsOptions: { padding: 0 },
    padding: 0
});

// This will be different from the passed in bounds...
console.log(map.getBounds());

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions