feat(web): Add coordinate pair location searching. (#24799)

* feat(web): Add coordinate pair searching within the change location modal.

Adds simple logic to try and parse a coordinate pair in the format
`LATITUDE, LONGITUDE` as provided from Google Maps if a coordinate is
copied to update the coordinates automatically.

* Add checks for valid coordinate pairs

* Update formatting and fix linting issues
This commit is contained in:
GustavJones
2026-01-04 21:16:23 +02:00
committed by GitHub
parent abea5a53de
commit a1aa2b807b

View File

@@ -86,6 +86,27 @@
return;
}
// Try to parse coordinate pair from search input in the format `LATITUDE, LONGITUDE` as floats
const coordinateParts = searchWord.split(',').map((part) => part.trim());
if (coordinateParts.length === 2) {
const coordinateLat = Number.parseFloat(coordinateParts[0]);
const coordinateLng = Number.parseFloat(coordinateParts[1]);
if (
!Number.isNaN(coordinateLat) &&
!Number.isNaN(coordinateLng) &&
coordinateLat >= -90 &&
coordinateLat <= 90 &&
coordinateLng >= -180 &&
coordinateLng <= 180
) {
places = [];
showLoadingSpinner = false;
handleUseSuggested(coordinateLat, coordinateLng);
return;
}
}
searchPlaces({ name: searchWord })
.then((searchResult) => {
// skip result when a newer search is happening