mapbox / mapbox/mapbox-maps-flutter

It is not possible to fit the map to a bounds using the cameraForCoordinates... methods on iOS

Open
#666 0 comments 2 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

On Android it is possible to move the camera to fit a bounds. On iOS the same code fails to work.

Swap the varialbe c[n] at the end of this code to test the different methods. All are fine on Android but fail on an iPhone:

var sw = Point(coordinates: Position(bounds.w, bounds.s));
var ne = Point(coordinates: Position(bounds.e, bounds.n));

CameraOptions c = await mapboxMap.cameraForCoordinateBounds(
  CoordinateBounds(southwest: sw, northeast: ne, infiniteBounds: false),
  MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight),
  0,
  MapConst.defaultFindZoomLevel,
  20,
  ScreenCoordinate(x: 0, y: 0),
);

CameraOptions c2 = await mapboxMap.cameraForCoordinatesPadding(
  [sw, ne],
  CameraOptions(pitch: 40),
  MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight),
  MapConst.defaultFindZoomLevel,
  ScreenCoordinate(x: 0, y: 0),
);

CameraOptions c3 = await mapboxMap.cameraForCoordinates([sw, ne], MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight), 0, 0);

CameraOptions c4 = await mapboxMap.cameraForCoordinatesCameraOptions([sw, ne], CameraOptions(), ScreenBox(min: ScreenCoordinate(x: 0, y: 0), max: ScreenCoordinate(x: 100, y: 100)));

var point = {
  "type": "Point",
  "coordinates": [1, 2]
};
CameraOptions c5 = await mapboxMap.cameraForGeometry(point, MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight), 0, 0);

mapboxMap.easeTo(c, MapAnimationOptions());

`

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 by reproducing the supplied cameraForCoordinateBounds, cameraForCoordinates, cameraForGeometry, and easeTo calls on an iPhone, then compare their behavior with Android. Done means the camera-for-coordinates methods fit the supplied bounds and the resulting CameraOptions can be applied on iOS as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Bug
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.