Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable map rotation #811

Closed
joao10martins opened this issue Feb 1, 2021 · 8 comments
Closed

Disable map rotation #811

joao10martins opened this issue Feb 1, 2021 · 8 comments

Comments

@joao10martins
Copy link

joao10martins commented Feb 1, 2021

Is it possible to disable rotation of the map? I do not want the map to rotate.

@ibrierley
Copy link
Contributor

Not tried it, but I note the latest version of FlutterMap has both "layers" and "nonRotatedLayers"...have you tried using that instead of layers in your FlutterMap creation (and nonRotatedChildren rather than children) ?

@joao10martins
Copy link
Author

joao10martins commented Feb 1, 2021

I tried using the "nonRotatedLayers" and indeed, the rotation was disabled. But that introduced wrong behavior of pinch actions and even dragging. To give you an example: when I tried to drag the screen down in order to scroll upwards on the map, I instead went downwards.

@merxim
Copy link

merxim commented Feb 1, 2021

Hey, I noticed the map was rotating for the first time today (which i didnt have on another device last week) and I came to ask the EXACT same question. I don't know if you 've solved it in the meantime, but in case you haven't:

Digging through the code led me to the interactive_flag class which you can use in your MapOptions . The following code works for me to disable rotation:

MapOptions options = MapOptions(interactiveFlags: InteractiveFlag.all & ~InteractiveFlag.rotate,
  );
return FlutterMap(
  mapController: _mapController,
  options: options,
  layers: [.... etc
  ]
  );

@joao10martins
Copy link
Author

joao10martins commented Feb 1, 2021

Yeah I fixed that later. By doing the same thing.

@kengu kengu closed this as completed Mar 19, 2021
@Apollo108
Copy link

Apollo108 commented Sep 7, 2021

Jesus Christ, even deliberately I couldn't have come up with more harder way to toggle map rotation than that...

@kengu
Copy link
Contributor

kengu commented Sep 7, 2021

@Apollo108 This is a community driven spare-time effort. Feel free to contribute to make it better. I agree that things can be better, it always can, but please keep the comments constructive.

@Tarek-higazi
Copy link

Old thread but i noticed that its impossible to block map-rotation on Web. Using the latest Fluttermaps version & disabling rotation in MapOptions, i can still rotate using by pressing the Ctrl button, clicking the mouse & moving it.
(on mobile works as expected)

@josxha
Copy link
Contributor

josxha commented May 6, 2024

@Tarek-higazi the rotate flag is implemented as a two finger rotate gesture only, the Ctrl+drag gesture can be disabled like described here: https://docs.fleaflet.dev/usage/options/interaction-options#cursor-keyboard-rotation
I agree that splitting this appart is not the right approach and confusing. #1809 tries to solve that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants