Skip to content

Commit

Permalink
limit bbox values by edge lat/lon values
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenykatyshev committed Dec 3, 2020
1 parent f344a0c commit a586fe2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/getBbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default function ({ latitude, longitude, zoom, width, height }) {

const shiftDegreesEW = shiftMetersEW * degreesPerMeter;
const shiftDegreesNS = shiftMetersNS * degreesPerMeter;

const west = longitude-shiftDegreesEW < -180 ? -180 : longitude-shiftDegreesEW;
const south = latitude-shiftDegreesNS < -90 ? -90 : latitude-shiftDegreesNS;
const east = longitude+shiftDegreesEW > 180 ? 180 : longitude+shiftDegreesEW;
const north = latitude+shiftDegreesNS > 90 ? 90 : latitude+shiftDegreesNS;

// [south, west, north, east]
return [longitude-shiftDegreesEW, latitude-shiftDegreesNS, longitude+shiftDegreesEW, latitude+shiftDegreesNS];
return [west, south, east, north];
}

0 comments on commit a586fe2

Please sign in to comment.