Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling flutter_map package rotation in Flutter

How do you disable the rotation of the map in flutter_map?

like image 924
João Martins Avatar asked Feb 01 '21 10:02

João Martins


2 Answers

As written by @pskink the answer is to use the InteractiveFlag provided by flutter_map in such a way

MapOptions(
    minZoom: 11.0,
    maxZoom: 17.0,
    center: LatLng(lat, lng),
    interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
    zoom: 13.0,
  ),

By doing this, you can ensure that only pinchZoom and drag actions are allowed in your map.

like image 199
João Martins Avatar answered Oct 08 '22 14:10

João Martins


Looking at the API Documentation, there is a class MultiFingerGesture. This looks like it controls the gestures on the Widget, and there is an option to only allow PinchMove, or PinchZoom. The default looks like it's the all option. If you change the Map's property that equates to this class, and change to either PinchMove, or PinchZoom then it should work. Please review the class here:

https://pub.dev/documentation/flutter_map/latest/flutter_map.plugin_api/MultiFingerGesture-class.html

like image 25
Dan Gerchcovich Avatar answered Oct 08 '22 12:10

Dan Gerchcovich