mapbox / mapbox/mapbox-maps-flutter

Update CameraOptions has no effect?

Open
#351 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

Hello,

I using mapbox with a draggable bottom sheet on top of it. I have a "follow mode" on this map to keep current position at the center. So in order to have the correct center depending of the position of the bottom sheet I'm doing something like this:

cameraOptions: CameraOptions(
                        center: Point(
                          coordinates: context.read<AppCubit>().state.initialMapViewport.center,
                        ).toJson(),
                        bearing: context.read<AppCubit>().state.initialMapViewport.bearing,
                        pitch: context.read<AppCubit>().state.initialMapViewport.pitch,
                        zoom: context.read<AppCubit>().state.initialMapViewport.zoomLevel,
                        padding: MbxEdgeInsets(
                          top: 0,
                          left: 0,
                          bottom: (MediaQuery.of(context).size.height - kBottomNavigationBarHeight - kToolbarHeight) * snapPosition,
                          right: 0,
                        ),
                      ),

The snapPosition is updated each time the sheet is moved. But when moving the coordinates it doesn't center correctly, it take the first value entered when creating the widget.

I also tried using:

mapboxMap.setCamera(
      CameraOptions(
        padding: MbxEdgeInsets(
          top: 0,
          left: 0,
          bottom: bottomExtent, // mapCenterOffset,
          right: 0,
        ),
      ),
    );

Calling this each time the sheet is moved, but nothing happen.

Any idea how can I achieve that?

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 with the widget's cameraOptions initialization and the mapboxMap.setCamera call shown in the issue, then trace how the draggable bottom sheet updates snapPosition and bottomExtent. Reproduce the behavior while moving the sheet and verify that updated center and padding values affect the map camera; the issue provides no named files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.