3

I have a flutter map screen with dynamic polylines that are set using the GetBuilder. They are rendering but I want to fit them to the screen using cameraTargetBounds but this doesn't work.

See my code below:

    GetBuilder<SelectedTripController>(
        init: SelectedTripController(),
        builder: (_) {
          return GoogleMap(
            cameraTargetBounds: CameraTargetBounds(_.bounds),
            polylines: _.polyLines,
            initialCameraPosition: CameraPosition(
                target: _.center == null ? _center : _.center,
                zoom: 15.4746),
            onMapCreated: (GoogleMapController controller) {
              _controller.complete(controller);
              mapController = controller;
            },
          );
        });

I have checked and can confirm _.bounds has LatLngBounds.

Also, the _.center from GetXController doesn't update the camera position when it is changed.

How can I improve the code to achieve centering and fitting the polylines?

Tim Kariuki
  • 633
  • 8
  • 17

0 Answers0