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

Center Map on Vertex Addition When Position Locked & Off-Screen #6008

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

mohsenD98
Copy link
Collaborator

@mohsenD98 mohsenD98 commented Feb 16, 2025

Description:

This PR addresses a usability issue related to adding vertices when the coordinate cursor is locked and is off-screen. (#5883 ).

Problem:

When the coordinate cursor is locked, new vertices should be added at the current location point. However, if the user moves the map canvas so the current location (and thus the crosshair) is no longer visible, the user receives no visual confirmation of vertex addition. This creates uncertainty as to whether the vertex has been added or not.

Solution:

This PR implements a solution that automatically recenters the map when a vertex is added under the described condition. Specifically:

When the positionLocked setting is enabled and a vertex is being added.

The code checks if the crosshair circle (representing the current location) is off-screen. This is determined by the following logic:

const outOfScreen = crosshairCircle.x + crosshairCircle.width <= 0 ||
                    crosshairCircle.x - crosshairCircle.width >= mainWindow.width ||
                    crosshairCircle.y + crosshairCircle.height <= 0 ||
                    crosshairCircle.y - crosshairCircle.height >= mainWindow.height;

If outOfScreen is true , the map is automatically recentered to the current location using mapCanvas.mapSettings.setCenter(positionSource.projectedPosition, true);.

Screen cast:

Screencast.From.2025-02-16.23-49-34.webm

@mohsenD98 mohsenD98 self-assigned this Feb 16, 2025
@qfield-fairy
Copy link
Collaborator

qfield-fairy commented Feb 16, 2025

@mohsenD98 mohsenD98 changed the title WIP: Recenter if out of screen and locked. Center Map on Vertex Addition When Position Locked & Off-Screen Feb 18, 2025
@mohsenD98 mohsenD98 marked this pull request as ready for review February 18, 2025 17:13
@nirvn nirvn merged commit c11405d into master Feb 19, 2025
27 checks passed
@nirvn nirvn deleted the recenter-out-of-screen-and-locked branch February 19, 2025 02:24
nirvn pushed a commit that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants