From 8dd751fb8dd134880c7fed7b1bbdd03dedcab885 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Thu, 13 Feb 2025 14:22:23 +0100 Subject: [PATCH] Feat: Add tolerance for lat/lon AND lan/lot inputs (Norway only) --- src/main/webapp/map_applications/phytophthora/index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/map_applications/phytophthora/index.html b/src/main/webapp/map_applications/phytophthora/index.html index 0005d51a..af52204e 100755 --- a/src/main/webapp/map_applications/phytophthora/index.html +++ b/src/main/webapp/map_applications/phytophthora/index.html @@ -305,7 +305,11 @@ { // Call map functionality to center on coordinate const lonLat = phrase.split(","); - navigateTo([parseFloat(lonLat[0]), parseFloat(lonLat[1])]); + // Check if it's a lat-lon or a lon-lat coordinate (Specific for Norway!) + // If the first coordinate is > 32, it must be the latitude, since max longitude for Norway is 31-something + let longitude = parseFloat(lonLat[0]) > 32 ? lonLat[1] : lonLat[0]; + let latitude = parseFloat(lonLat[0]) > 32 ? lonLat[0] : lonLat[1]; + navigateTo([parseFloat(longitude), parseFloat(latitude)]); return; } $.getJSON( "https://ws.geonorge.no/stedsnavn/v1/navn?sok=" + phrase + "*&utkoordsys=4326&treffPerSide=6&side=1&filtrer=navn.skrivem%C3%A5te%2Cnavn.navneobjekttype%2Cnavn.kommuner%2Cnavn.representasjonspunkt", renderResults); -- GitLab