Center Map on Vertex Addition When Position Locked & Off-Screen #6008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
If
outOfScreen
istrue
, the map is automatically recentered to the current location usingmapCanvas.mapSettings.setCenter(positionSource.projectedPosition, true);
.Screen cast:
Screencast.From.2025-02-16.23-49-34.webm