Skip to content

Map.flyTo padding not being cleared -> fitBounds is summing it up with it's own padding argument. #6744

@kamil-sienkiewicz-asi

Description

@kamil-sienkiewicz-asi

maplibre-gl-js version: 5.13.0

browser: chrome 141.0.7390.77

I think there were few issues about this already, but I don't see any open one, yet still this bug exists so creating new one.

Related issues:
mapbox/mapbox-gl-js#11831
#4095 - this was closed, but not resolved
#2984 -> there is no solution to my knowledge, mapbox says that they fixed it somehow

Steps to Trigger Behavior

Steps to Trigger Behavior

  1. Call function map.FlyTo with padding ->
 map.flyTo({
   center: coordinates[0],
   padding: {
      top: 50,
      bottom: 0,
      left: 100,
      right: 0
   }
})
  1. Call function map.fitBounds ->
map.fitBounds(bounds, {
 padding: 200
});
  1. Call to fitBounds uses sum of padding from fitBounds and previous flyTo ->
padding = {
   top: 50 + 200,
   bottom: 200,
   left: 100 + 200,
   right 0 + 200,
}

Link to Demonstration

https://jsbin.com/xeseliyufe/edit?html,output

Screen.Recording.2025-11-20.at.13.19.55.webm

Expected Behavior

Padding is not summed up

Actual Behavior

Padding is summed up which breaks UI of the app

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions