Calculate map bounds that exclude surrounding UI panels

Display the visible map center and bounds excluding surrounding UI panels, so they don't overlap

View on GitHub
SDK 1.0.0-rc.7

The shaded rectangle is the slice of map no panel covers, with an X at its centre, recomputed as the map moves or the window resizes. The toolbar stops short of the map’s edges, and it still cuts the slice from the top, the side that leaves the most map visible.

  • calculatePaddedBBox takes the panel elements themselves and returns geographic bounds, so the overlay’s pixel geometry is never yours to measure.
  • calculatePaddedCenter gives the point to centre on when panels make the container’s middle the wrong target.
  • polygonFromBBox turns either result into drawable GeoJSON.

Related examples