How do you disable the rotation of the map in flutter_map?
Asked
Active
Viewed 5,268 times
17
-
4https://pub.dev/documentation/flutter_map/latest/flutter_map.plugin_api/InteractiveFlag-class.html – pskink Feb 01 '21 at 11:06
-
1This worked. If you wish to get a correct answer please post an Answer instead of a comment. Thank you :) Or I can answer it by myself and give you the credits. – João Martins Feb 01 '21 at 12:05
-
yes, write a self answer then – pskink Feb 01 '21 at 12:06
3 Answers
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

Safrankuchen
- 41
- 2
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:

Dan Gerchcovich
- 168
- 5
- 12
-
I've never used this package, so I'm taking this only from the author's api documentation. If this does not give you any compile time errors, then go ahead. Please try this, and let me know – Dan Gerchcovich Feb 01 '21 at 11:10
-
Nah it did not work. I added the `.pichZoom` option and it still rotates. – João Martins Feb 01 '21 at 11:14
-
then I would post an issue on the github repository. Contact the Author, and they can help – Dan Gerchcovich Feb 01 '21 at 11:15