@@ -143,11 +143,16 @@ async function getAreaNameMatch(
143143 longitude : number ,
144144 latitude : number
145145) : Promise < AreaNameMatch | null > {
146- const coordinates = await geocoding . reverse ( [ longitude , latitude ] ) ;
146+ try {
147+ const coordinates = await geocoding . reverse ( [ longitude , latitude ] ) ;
147148
148- return getBestAreaNameMatchFromFeatures (
149- coordinates . features as AreaNameFeature [ ]
150- ) ;
149+ return getBestAreaNameMatchFromFeatures (
150+ coordinates . features as AreaNameFeature [ ]
151+ ) ;
152+ } catch ( error ) {
153+ console . warn ( "Could not reverse-geocode selected location:" , error ) ;
154+ return null ;
155+ }
151156}
152157
153158// TODO: use this to build a custom component around the core geocoding API, using my nice own components for input and dropdown
@@ -223,7 +228,6 @@ export default function LocationSelect({
223228 ( e : ChangeEvent < HTMLSelectElement > ) => {
224229 onLocationInteract ?.( ) ;
225230 setCountryCode ( e . target . value ) ;
226- console . log ( "Country changed, focusing input..." ) ;
227231 setMapShown ( false ) ;
228232 inputRef . current ?. focus ( ) ;
229233 } ,
@@ -232,12 +236,10 @@ export default function LocationSelect({
232236
233237 const handleDragStart = useCallback ( ( ) => {
234238 inputRef . current ?. blur ( ) ; // Close and blur the input if it's open
235- console . log ( "handling drag start" ) ;
236239 } , [ ] ) ;
237240
238241 const handleDragEnd = useCallback (
239242 async ( event : any ) => {
240- console . log ( "Drag end. Location:" , event . lngLat ) ;
241243 onLocationInteract ?.( ) ;
242244
243245 const nextCoordinates = {
@@ -264,8 +266,6 @@ export default function LocationSelect({
264266 async ( feature : GeocodingFeature ) => {
265267 if ( ! feature . center ) return ;
266268
267- // Otherwise continue as normal
268- console . log ( "Picked:" , feature , feature . center ) ;
269269 onLocationInteract ?.( ) ;
270270
271271 const nextCoordinates = {
@@ -288,16 +288,9 @@ export default function LocationSelect({
288288 inputRef . current ?. blur ( ) ;
289289
290290 if ( ! mapShown ) {
291- console . log ( "Map isnt shown yet, coming now..." ) ;
292291 setCoordinates ( nextCoordinates ) ;
293292 setMapShown ( true ) ;
294293 } else {
295- console . log (
296- "Map already shown, flying from" ,
297- coordinates ,
298- "to" ,
299- nextCoordinates
300- ) ;
301294 mapRef . current ?. flyTo ( {
302295 center : [ nextCoordinates . longitude , nextCoordinates . latitude ] ,
303296 duration : 2800 ,
0 commit comments