Skip to content

Commit

Permalink
fix: add condition to check if zoom level has been updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mulengawilfred committed Dec 4, 2024
1 parent 7823bc3 commit 75c97b8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/engines/Cesium/core/Imagery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export function useImageryProviders({
const tileKeys = tiles.map(t => t.id).join(",");
const prevTileKeys = useRef(tileKeys);
const prevProviders = useRef<Providers>({});

const zoomLevels = tiles.map(t => {
if(t.id && t.zoomLevel) return {[t.id]: t.zoomLevel}
return
})
const prevZoomLevels = useRef(zoomLevels)

// Manage TileProviders so that TileProvider does not need to be recreated each time tiles are updated.
const { providers, updated } = useMemo(() => {
Expand Down Expand Up @@ -174,9 +180,11 @@ export function useImageryProviders({
!!added.length ||
!!isCesiumAccessTokenUpdated ||
!isEqual(prevTileKeys.current, tileKeys) ||
!isEqual(prevZoomLevels.current, zoomLevels) ||
rawProviders.some(p => p.tile && (p.prevType !== p.tile.type || p.prevUrl !== p.tile.url));

prevTileKeys.current = tileKeys;
prevZoomLevels.current = zoomLevels;
prevCesiumIonAccessToken.current = cesiumIonAccessToken;

return { providers, updated };
Expand Down

0 comments on commit 75c97b8

Please sign in to comment.