17

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

João Martins
  • 706
  • 1
  • 8
  • 20

3 Answers3

38

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.

João Martins
  • 706
  • 1
  • 8
  • 20
4

This is better:

MapOptions (  
    interactiveFlags: InteractiveFlag.all & ~InteractiveFlag.rotate,
 )
pmatatias
  • 3,491
  • 3
  • 10
  • 30
1

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

Dan Gerchcovich
  • 168
  • 5
  • 12