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

Zoom gesture works only on half screen on orientation change #195

Open
SergioOrellanaR opened this issue Jan 23, 2020 · 19 comments
Open

Zoom gesture works only on half screen on orientation change #195

SergioOrellanaR opened this issue Jan 23, 2020 · 19 comments
Labels
android bug Something isn't working pinned

Comments

@SergioOrellanaR
Copy link

SergioOrellanaR commented Jan 23, 2020

When phone orientation changes (From portrait to landscape and vice versa) zoom gestures work only on half screen (where the original orientation pixels are equals to new orientation).

This was tested into a mapBoxMap builded with a lot of widgets and on a page with only a Scaffold and a instance of mapboxmap (Android).

@m0nac0 m0nac0 added android bug Something isn't working labels Jan 23, 2020
@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 23, 2020

I was able to reproduce this. If I tilt my phone from vertical to horizontal (counter-clockwise), for example, about the right half of the screen doesn't react to drag or zoom gestures. Double tapping works and drag gestures started in the "unresponsive area" that continue to the "responsive area" work for the part in the "reponsive area".

@SebastianSmolorz
Copy link
Contributor

I'm also experiencing this. Originally noticed the same issue in portrait mode so I started to cut away parent comonents to isolate the issue but I was not able to reproduce it reliably. It makes me think that it's something to do with redrawing the map rather than tilting itself.

@tobrun
Copy link
Collaborator

tobrun commented Jan 25, 2020

Thank you all for chiming in, I'm having trouble reproducing this. Could someone 👀 #201 and check how that setup differs from yours? Do you have a specific setup for handling orientation changes? Atm I'm guessing that the resize isn't correctly handled, having a minimal reproducible test case would be great!

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 25, 2020

@tobrun I just checked out #201 and I can still reproduce this bug on my physical Android 8.0 device with that new example.

@mindthefish
Copy link

Still having this issue with the latest version. My map is on fullscreen within a Stack. Tapping works fine, pinching only in the "old" area before the orientation change. I will check the example project to find an easy to reproduce setup.

@mindthefish
Copy link

mindthefish commented Dec 16, 2020

The issue is actually pretty easy to reproduce. Simply run the "Full screen map" example and change the orientation. When changed from landscape to portrait, the pinch or drag gesture in the lower area does not work. When changing from initially portrait mode to landscape, the pinch or drag gesture in the right area does not work. Wrapping the MapboxMap into an OrientationBuilder does not fix it either. Although the build function is called, the map is not getting reinitialised (the onMapCreated function is not called).

@mindthefish
Copy link

As a dirty workaround it is possible to rebuild the widget tree two times. First time returning an empty Container and add a post frame callback, second time the entire tree including map. This reinitializes the map and updates the gesture active area. This adds a lot of lag and 0,5 seconds empty screen so definitely not recommended. This should be fixed within Mapbox.

@mindthefish
Copy link

Is there any update on this issue? The problem still persists. Reinitialising the map causes other issues, because Flutter Mapbox seems to loose track of some channel methods after the rebuild, so after orientation change I get "MissingPluginException". I really appreciate a clean solution for this issue.

@raphaelvigee
Copy link

This is also happening when opening/closing the keyboard...

@teddichiiwa
Copy link

Same here...

@teddichiiwa
Copy link

Found a hacky way to fix this issue after 1 month struggling with it:

  1. Wrap FlutterMapWidget inside SizedBox:
  2. Use the code below to set width & height of the SizedBox, flag flutterMapInitialized to false
width: flutterMapInitialized
         ? MediaQuery.of(context).size.width
         : max(MediaQuery.of(context).size.width, MediaQuery.of(context).size.height),
height: flutterMapInitialized
          ? MediaQuery.of(context).size.height
          : max(MediaQuery.of(context).size.width, MediaQuery.of(context).size.height)
  1. Then listen when camera move started call back, set flutterMapInitialized to true.

Sum up: Make a square SizedBox with side = max(screenWidth, screenHeight), then set the SizedBox's side back to equals the screen size after first camera move started callback called.

@stale
Copy link

stale bot commented Jan 14, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 14, 2022
@m0nac0 m0nac0 removed the stale label Jan 14, 2022
@maxammann
Copy link

@teddichiiwa Somehow I'm failing at applying your fix to flutter-maplibre-gl. Can you maybe elaborate what the idea behind the fix is and what "when camera move started call back" means? Which callback are you referring to?

@maxammann
Copy link

maxammann commented Jan 23, 2022

@felix-ht
Copy link
Collaborator

@maxammann would you mind creating a pr adding this to this package or creating a separate package with your helper?

@maxammann
Copy link

@felix-ht I just got response that it does not yet work in release mode :) I'll try to fix it again later this week. After that a PR would be possible.

@teddichiiwa
Copy link

@maxammann Sorry for late response, our team rewrite the PlatformView using Hybrid Composition and this bug will be gone (see: https://docs.flutter.dev/development/platform-integration/platform-views).

@maxammann
Copy link

Alright so this whacky and hacky workaround works now for us:
https://github.com/digitalfabrik/ehrenamtskarte/blob/7675f039be5b914ad9c1331cc39e615ff802b5f8/frontend/lib/map/map/screen_parent_resizer.dart

It required quite some fine-tuning to cover edge cases. Make sure that when the initial render of the map happens that it is already visible. This means it should not be covered by a route which hides the map.

@maxammann
Copy link

@maxammann would you mind creating a pr adding this to this package or creating a separate package with your helper?

I'm not sure whether this should be included in the respository. I think the root cause of this should be fixed.
For the time being we should maybe create a separate pub package which provides this helper. Or: Let's expect everyone to copy&paste this helper into their repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working pinned
Projects
None yet
Development

No branches or pull requests

9 participants