Skip to content

Commit

Permalink
Remove checkFitBoundsFromLayer function
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Sep 20, 2023
1 parent 81e2210 commit dc31237
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions app/scripts/components/common/mapbox/layers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,30 +372,6 @@ export function getMergedBBox(features: StacFeature[]) {

export const FIT_BOUNDS_PADDING = 32;

export function checkFitBoundsFromLayer(
layerBounds?: [number, number, number, number],
mapInstance?: MapboxMap
) {
if (!layerBounds || !mapInstance) return false;

const [minXLayer, minYLayer, maxXLayer, maxYLayer] = layerBounds;
const [[minXMap, minYMap], [maxXMap, maxYMap]] = mapInstance
.getBounds()
.toArray();
const isOutside =
maxXLayer < minXMap ||
minXLayer > maxXMap ||
maxYLayer < minYMap ||
minYLayer > maxYMap;
const layerExtentSmaller =
maxXLayer - minXLayer < maxXMap - minXMap &&
maxYLayer - minYLayer < maxYMap - minYMap;

// only fitBounds if layer extent is smaller than viewport extent (ie zoom to area of interest),
// or if layer extent does not overlap at all with viewport extent (ie pan to area of interest)
return layerExtentSmaller || isOutside;
}

interface LayerInteractionHookOptions {
layerId: string;
mapInstance: MapboxMap;
Expand Down

0 comments on commit dc31237

Please sign in to comment.