Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

erf/tile-to-geo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tile-to-geo

Transform lat,zoom and lng,zoom to tile coordinates and back for spherical mercator projection.

Install

npm install tile-to-geo

Usage

assert(tu.lng_x(45, 1), 1);
assert(tu.lat_y(-45, 1), 1);

assert(tu.lng_x(160, 2), 3);
assert(tu.lat_y(-80, 2), 3);

assert(tu.x_lng(0, 2), -180);
assert(tu.y_lat(0, 2), 90);

assert(tu.x_lng(4, 2), 180);
assert(tu.y_lat(4, 2), -90);

Tests

npm test