UNPKG
slippy-bbox
Version:
latest (1.0.0)
1.0.0
calculate a bounding box for a slippy map (x,y,zoom) coordinate
slippy-bbox
/
index.js
11 lines
(10 loc)
•
307 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
var
PI
=
Math
.
PI
module
.
exports
=
function
(
x, y, z
) {
var
p2z =
Math
.
pow
(
2.0
,z)
return
[ x / p2z *
360.0
-
180
,
// west
Math
.
atan
(
Math
.
sinh
(
PI
-(
2.0
*
PI
*(y+
1
))/p2z))/
PI
*
180.0
,
// south
(x+
1
) / p2z *
360.0
-
180
,
// east
Math
.
atan
(
Math
.
sinh
(
PI
-(
2.0
*
PI
*y)/p2z))/
PI
*
180.0
// north
] }