Ensure a bounding box is visible between UI panels

Expand the map view to contain a specified bounding box while accounting for surrounding UI panels

View on GitHub
SDK 1.0.0-rc.7

The blue box always lands whole in the gap the panels leave, because the map is fitted to the larger red box drawn around it.

  • calculateFittingBBox returns that larger box from the one you want seen plus the panel elements, so fitBounds takes its result unchanged.
  • surroundingElements are the panels’ selectors, not pixel padding, so moving or resizing a panel needs no numbers updated.
  • polygonFromBBox draws both boxes, keeping the difference between what you asked for and what the map fits on screen.

Related examples