Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CameraViewportState initial position is jumping #820

Open
vchrisb opened this issue Dec 19, 2024 · 0 comments
Open

CameraViewportState initial position is jumping #820

vchrisb opened this issue Dec 19, 2024 · 0 comments

Comments

@vchrisb
Copy link

vchrisb commented Dec 19, 2024

When initially loading a map that uses CameraViewportState, the map is briefly centering to a different center than configured.
This behavior is different to when using CameraOptions, where the onCameraChangeListener is also fired twice, but both with the same center.

MapWidget(
        key: ValueKey("mapWidget"),
        viewport: CameraViewportState(
            center: Point(coordinates: Position(-117.918976, 33.812092)),
            bearing: currentCity.bearing,
            pitch: 0,
            zoom: 18),
        onCameraChangeListener: (cameraChangedEventData) =>
            print(cameraChangedEventData.cameraState.center.toJson()),
      ),

Output for onCameraChangeListener:

{type: Point, bbox: null, coordinates: [-9.999999999999972, 29.999999999999964]}
{type: Point, bbox: null, coordinates: [-117.918976, 33.812092000000014]}

When configuring both, viewport and cameraOptions, it first centers to the position from cameraOptions and then to the position of cameraOptions. Maybe there is some unwanted default/calculation when using viewport alone?

MapWidget(
        key: ValueKey("mapWidget"),
        viewport: CameraViewportState(
            center: Point(coordinates: Point(coordinates: Position(-117.918976, 33.812092)),
            bearing: currentCity.bearing,
            pitch: 0,
            zoom: 18),
        cameraOptions: CameraOptions(
          center: Point(coordinates: Point(coordinates: Position(-100.918976, 33.812092))),
          zoom: 18,
        ),
        onCameraChangeListener: (cameraChangedEventData) =>
            print(cameraChangedEventData.cameraState.center.toJson()),
      ),

Output for onCameraChangeListener:

{type: Point, bbox: null, coordinates: [-100.918976, 33.812092000000035]}
{type: Point, bbox: null, coordinates: [-117.918976, 33.812092000000014]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant