feat: update route center calculating

This commit is contained in:
2025-11-26 04:29:19 +03:00
parent 04a9ac452e
commit 95fe297aae
7 changed files with 67 additions and 39 deletions

View File

@@ -12,6 +12,7 @@ export function RightSidebar() {
saveChanges,
originalRouteData,
setMapRotation,
setMapCenter,
setIconSize: updateIconSize,
setFontSize: updateFontSize,
} = useMapData();
@@ -386,7 +387,11 @@ export function RightSidebar() {
value={Math.round(localCenter.x * 1000) / 1000}
onChange={(e) => {
setIsUserEditing(true);
setLocalCenter((prev) => ({ ...prev, x: Number(e.target.value) }));
const newValue = Number(e.target.value);
setLocalCenter((prev) => ({ ...prev, x: newValue }));
if (!isNaN(newValue) && localCenter.y !== undefined) {
setMapCenter(newValue, localCenter.y);
}
}}
onBlur={() => {
setIsUserEditing(false);
@@ -406,12 +411,16 @@ export function RightSidebar() {
/>
<TextField
type="number"
label="Центр карты, высота"
label="Центр карты, долгота"
variant="filled"
value={Math.round(localCenter.y * 1000) / 1000}
onChange={(e) => {
setIsUserEditing(true);
setLocalCenter((prev) => ({ ...prev, y: Number(e.target.value) }));
const newValue = Number(e.target.value);
setLocalCenter((prev) => ({ ...prev, y: newValue }));
if (!isNaN(newValue) && localCenter.x !== undefined) {
setMapCenter(localCenter.x, newValue);
}
}}
onBlur={() => {
setIsUserEditing(false);