Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No implementation found for method camera animate on channel map recenter button

The Flutter map recenter button not working

dependency version = google_maps_flutter: ^2.1.6

Implement code

Future<void> _goToTheLake() async {
LatLng lat = LatLng(ctrl.getLat().value, ctrl.getLang().value);
print(lat);
final GoogleMapController controller = await _controller.future;
controller.animateCamera(
    CameraUpdate.newCameraPosition(
    CameraPosition(target: lat, zoom: 15.0)));
setState(() {});

}

E/flutter (15144): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method camera#animate on channel plugins.flutter.io/google_maps_0)
E/flutter (15144): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (15144): <asynchronous suspension>

enter image description here

if anyone has a solution please drop a comment.

like image 988
Manoj Jaiswal Avatar asked Jan 28 '26 04:01

Manoj Jaiswal


2 Answers

  ///map controller
  Completer<GoogleMapController> mapController = Completer();

  ///create map controller
  void onMapCreated(GoogleMapController controller) {
    if(!mapController.isCompleted){
      mapController.complete(controller);
    }
  }

  @override
  void dispose() {
    mapController = Completer();
    super.dispose();
  }

here's works fine for me

like image 155
DHANESH P Avatar answered Jan 31 '26 06:01

DHANESH P


Hope this helps

  Completer<GoogleMapController> _controller = Completer();


    if(!freezeMap) {
      _controller.future.then((value) =>

          value.animateCamera(
              CameraUpdate.newLatLngZoom(
                  LatLng(loc.lat, loc.long), zoomLevel)));
    }
like image 28
Kobi Avatar answered Jan 31 '26 06:01

Kobi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!