mapbox / mapbox/mapbox-gl-js

Ability to set padding in options object on Map.setMaxBounds() method

Open
#11,630 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I have no idea what this looks like under the hood, so I don't know if this would be a quick change or more complicated, but it would be great to be able to pass an options object with padding to the setMaxBounds method, like I'm able to do with fitBounds.

Motivation

I've had a few times where I want to restrict panning on a map to a particular region, but want to be able to set some padding around the edges. Workarounds that I've tinkered with, but aren't ideal are:

  1. Manually finding the bounding coordinates for the larger "padded" area, which works, but is a little clunky/inexact and time-consuming.
  2. Running fitBounds with padding set, grabbing the new bounds with getBounds, feeding this into maxBounds and then restoring the original map position without transition.

It would be great if there was a way to set this easily, if that's easy to do.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the setMaxBounds method and compare its current behavior with fitBounds, especially the existing padding option. Trace how max bounds and map padding are represented, then check the relevant tests if they can be located from those entry points. Done means callers can provide padding through setMaxBounds while existing calls continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.