mapbox / mapbox/mapbox-maps-flutter

CameraOptions padding does not work

Open
#816 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
380
Forks
204
PR merge metrics
No merged PRs in 30d

Description

The padding property of CameraBounds is ignored when calculating coordinate bounds.

This makes it impossible to detect which areas of the map are clear of obstructions like floating buttons and toolbars.

**To reproduce:**

```
CameraState c = await mapboxMap.getCameraState();

// get a bounds with padding
var borderPixels = 20.0;
final b1 = await mapboxMap.coordinateBoundsForCamera(CameraOptions(
padding: MbxEdgeInsets(
top: borderPixels,
left: borderPixels,
bottom: borderPixels,
right: borderPixels,
),
center: c.center,
zoom: c.zoom,
pitch: c.pitch,
));

// get a bounds without padding
final b2 = await mapboxMap.coordinateBoundsForCamera(CameraOptions(
center: c.center,
zoom: c.zoom,
pitch: c.pitch,
));

// the coordinates should be different but are the same
bool neSame = b1.northeast.coordinates == b2.northeast.coordinates;
bool swSame = b1.southwest.coordinates == b2.southwest.coordinates;

print('neSame: $neSame'); // prints true
print('swSame: $swSame'); // prints true

```

**Expected behaviour:**

The padding should be applied to the bounds returned.

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 coordinateBoundsForCamera entry point and trace how CameraOptions padding is handled. Reproduce the issue with the provided Flutter example, comparing bounds with and without padding; the fix is complete when the returned bounds reflect the specified padding.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
api, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.