0

When I create the GoogleMap widget I can set:

initialCameraPosition: CameraPosition(
                    target: _initialCameraPosition,
                    zoom: 12.0,
                    bearing: 0.0
                  ),

but after the user changes the rotation, how can I set the bearing to 0.0 again?

Rony Tesler
  • 1,207
  • 15
  • 25

1 Answers1

1

Use the GoogleMap.onMapCreated callback to store a reference to the GoogleMapController parameter it has.

GoogleMap(
      onMapCreated: (controller) => /* store the controller in state */,
      ...
    );

Then, use it to set the camera position:

controller.animateCamera(
      CameraUpdate.newCameraPosition(
         CameraPosition(
          bearing: /* set your desired bearing */,
          ...
         ),
      ),
    );
offworldwelcome
  • 1,314
  • 5
  • 11