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

[BUG] Polygon hitbox does not take into account map rotation #1934

Closed
papamedo opened this issue Jul 17, 2024 · 2 comments · Fixed by #1942
Closed

[BUG] Polygon hitbox does not take into account map rotation #1934

papamedo opened this issue Jul 17, 2024 · 2 comments · Fixed by #1942
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: core Scoped to the core flutter_map functionality

Comments

@papamedo
Copy link

What is the bug?

When the map is in the initial position, and when we are trying to select a polygon(shape made on the map) its working fine, but when we try to rotate it , the hit box or when i try to select anything, we are not able to select the polygon.
When camera rotation is 0, hit detection works as intended, if camera rotation is != 0 hit detection is not working as intended.
PolyLinelayer layer is working as intended, PolygonLayer is the issue.
I added a listener to _hitNotifier but is is detecting the same as the onTap function on GestureDetector.

[√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.19045.4529], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[X] Visual Studio - develop Windows apps
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.91.1)
[√] Connected device (3 available)
[√] Network resources

! Doctor found issues in 2 categories.

How can we reproduce it?

GestureDetector(
          onTap: () => _onTap(_hitNotifier.value!.hitValues.firstOrNull),
          child: PolygonLayer(
            hitNotifier: _hitNotifier,
            polygons: polygons,
          ),
        ),

Do you have a potential solution?

No

Platforms

Android 14

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console

@papamedo papamedo added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels Jul 17, 2024
@JaffaKetchup JaffaKetchup added P: 2 (soon™?) and removed needs triage This new bug report needs reproducing and prioritizing labels Jul 22, 2024
@JaffaKetchup
Copy link
Member

I think we need to rotate the points (not sure if it's before or after projection) before testing whether a point is within those points.

@JaffaKetchup JaffaKetchup changed the title [BUG] Hitbox not working when the map is rotated [BUG] Polygon hitbox does not take into account map rotation Jul 22, 2024
@monsieurtanuki
Copy link
Contributor

@JaffaKetchup Or rotate the touched pixel: the result (hit / no hit) would be the same and it's faster to rotate a pixel than to rotate a whole polygon.
Strange that the behavior differs between polylines and polygons.
I'll have a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: core Scoped to the core flutter_map functionality
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants