From c677913b906a37349cf53088cf1844a1a5a9114f Mon Sep 17 00:00:00 2001 From: csawatzky Date: Wed, 26 Mar 2025 15:47:08 -0600 Subject: [PATCH 1/2] fixed the geocoder result problems --- src/maps/mapControllers/Geocoder.tsx | 6 +++--- src/maps/mapObjectControllers/AgMapController.tsx | 11 ++--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/maps/mapControllers/Geocoder.tsx b/src/maps/mapControllers/Geocoder.tsx index ab0f640..162bc97 100644 --- a/src/maps/mapControllers/Geocoder.tsx +++ b/src/maps/mapControllers/Geocoder.tsx @@ -134,12 +134,12 @@ export default function Geocoder(props: Props) { geoCoder.on("error", () => {}); //event is fired when an option is selected from the results - geoCoder.on("result", (res: Result) => { + geoCoder.on("result", (res) => { if (resultFunction) { - resultFunction(res); + resultFunction(res.result); } if (customTransition) { - customTransition(res); + customTransition(res.result); } }); //once the map ref and access token are set up add the control to the map diff --git a/src/maps/mapObjectControllers/AgMapController.tsx b/src/maps/mapObjectControllers/AgMapController.tsx index 2153084..d2762f9 100644 --- a/src/maps/mapObjectControllers/AgMapController.tsx +++ b/src/maps/mapObjectControllers/AgMapController.tsx @@ -1351,13 +1351,6 @@ import { Result } from "@mapbox/mapbox-gl-geocoder"; }; const geocoderResult = (result: Result) => { - clickDelay() - console.log("result function") - console.log(result) - console.log("immediate id: " + result.id) - setTimeout(() => { - console.log("result.id after waiting 2 seconds: " + result.id) - }, 2000); if(result.id !== undefined){ setObjectKey(result.id.toString()); if (result.place_type.includes("bin")) { @@ -1375,8 +1368,8 @@ import { Result } from "@mapbox/mapbox-gl-geocoder"; }; const geocoderTransition = (result: Result) => { - let long = result.center ? result.center[0] : 0; - let lat = result.center ? result.center[1] : 0; + let long = result.center[0]; + let lat = result.center[1]; if (long && lat) { let centered = true; let zoom = zoomLevels.far; From 278dfa713d11abe234ad7c2e16948fe08cb0321e Mon Sep 17 00:00:00 2001 From: csawatzky Date: Wed, 26 Mar 2025 15:56:35 -0600 Subject: [PATCH 2/2] modified the bin page to use the bin key first if one was passed in then default to the params id --- src/pages/Bin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Bin.tsx b/src/pages/Bin.tsx index 5f5dbd5..e097e10 100644 --- a/src/pages/Bin.tsx +++ b/src/pages/Bin.tsx @@ -269,7 +269,7 @@ export default function Bin(props: Props) { loadRef.current = true; //add the presets to the bin page data load binAPI - .getBinPageData(binID, user.id(), showErrors) + .getBinPageData(binKey ?? binID, user.id(), showErrors) .then(resp => { if (resp.data.grainCompositionNames) { let tempMap: Map = new Map();