From 03fd183c95686a6ebc83fbbe39bf4b4d5e9c845e Mon Sep 17 00:00:00 2001 From: Donovan Date: Fri, 10 Jan 2025 16:29:45 -0500 Subject: [PATCH] removed logs and added StyleData error handling --- src/components/PropertyMap.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/PropertyMap.tsx b/src/components/PropertyMap.tsx index b0c13531..7749d0c9 100644 --- a/src/components/PropertyMap.tsx +++ b/src/components/PropertyMap.tsx @@ -418,8 +418,6 @@ const PropertyMap: FC = ({ }; map?.on('load', () => { - console.log('Map loaded, checking layers...'); - if (!map.getLayer('vacant_properties_tiles_points')) { map.addLayer(layerStylePoints); } @@ -455,8 +453,6 @@ const PropertyMap: FC = ({ map.setFilter('vacant_properties_tiles_points', ['all', ...mapFilter]); map.setFilter('vacant_properties_tiles_polygons', ['all', ...mapFilter]); - } else { - console.warn('Layers not found, skipping filter application.'); } }); // map load @@ -473,12 +469,7 @@ const PropertyMap: FC = ({ maxZoom={MAX_MAP_ZOOM} interactiveLayerIds={layers} onError={(e) => { - console.log(e); - if ( - e.error.cause === - "The layer 'vacant_properties_tiles_polygons' does not exist in the map's style and cannot be queried for features." - ) - setHasLoadingError(true); + setHasLoadingError(true); }} onLoad={(e) => { setMap(e.target); @@ -486,6 +477,18 @@ const PropertyMap: FC = ({ onSourceData={(e) => { handleSetFeatures(e); }} + onStyleData={(e) => { + const layerIds = e.target + .getStyle() + .layers.map((layer: any) => layer.id); + const layersApplied = layers.every((layer) => + layerIds.includes(layer) + ); + if (layersApplied) { + setHasLoadingError(false); // Reset loading error after style change + console.log('Layers successfully applied after style change.'); + } + }} onMoveEnd={handleSetFeatures} >