From ae985d487c57ade623df03fe46b3d141246c791b Mon Sep 17 00:00:00 2001 From: Bo Lu Date: Tue, 19 Nov 2024 13:19:57 -0500 Subject: [PATCH] Change to draw bbox if tiling fails --- src/components/search/geosearch.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/search/geosearch.tsx b/src/components/search/geosearch.tsx index 0951661..82599f9 100644 --- a/src/components/search/geosearch.tsx +++ b/src/components/search/geosearch.tsx @@ -197,7 +197,7 @@ const GeoSearch = ( if (result) { const coordinates=JSON.parse(result.coordinates); - const data = { + const geojson_data = { type: 'Feature', properties: { id: result.id, tag: 'geoViewGeoJSON' }, geometry: { @@ -267,7 +267,7 @@ const GeoSearch = ( // Draw the bounding box setTimeout(() => { - new L.geoJSON(data).addTo(map); + new L.geoJSON(geojson_data).addTo(map); }, 200); } else if ( imageUrls.length > 0 && @@ -312,29 +312,33 @@ const GeoSearch = ( { bounds: imageBounds, zIndex: 9999 } ); //Add tile to map - console.log("Adding tile to map"); + //console.log("Adding tile to map"); map.addLayer(layer); map.setView(new LatLng(tileCenter[1], tileCenter[0]), tileCenter[2]); setTimeout(() => { - new L.geoJSON(data).addTo(map); + new L.geoJSON(geojson_data).addTo(map); }, 200); }) .catch((err) => { + //Handle errors in getting the Tile console.error("TileJSON Error:", err); setMapView(center, bounds); + setTimeout(() => { + new L.geoJSON(geojson_data).addTo(map); + }, 200); }); } else { // Handle fallback GEO.ca record or default case setMapView(center, bounds); setTimeout(() => { - new L.geoJSON(data).addTo(map); + new L.geoJSON(geojson_data).addTo(map); }, 200); } } else { // Default handling when no options are provided setMapView(center, bounds); setTimeout(() => { - new L.geoJSON(data).addTo(map); + new L.geoJSON(geojson_data).addTo(map); }, 200); } }