latlon_to_xy

1.0.3 • Public • Published

latlon_to_xy

Converts Web Mercator coordinates to screen pixels and back

Installation

Using npm:

$ npm install latlon_to_xy

Usage

//Load module
let conversions = require('latlon_to_xy');
 
//set values
conversions.setupConversor(
  tile_height,
  zoom,
  center_longitude,
  center_latitude
);
 
//once the values are set, only one value is required for all calculations, and an alternative center value is optional
let x = conversions.lonToX(lon, altC); //converts longitude to x, an alternative center can be provided in lon units
let y = conversions.latToY(lat, altC); //converts latitude to y, an alternative center can be provided in lat units
let lon = conversions.xToLon(x, altC); //converts x to longitude, an alternative center can be provided in lon units
let lat = conversions.yToLat(y, altC); //converts y to latitude, an alternative center can be provided in lat units

TODO

  • Provide method for calculating necessary zoom for a location to be inside the screen

Package Sidebar

Install

npm i latlon_to_xy

Weekly Downloads

51

Version

1.0.3

License

ISC

Unpacked Size

5.2 kB

Total Files

4

Last publish

Collaborators

  • juanirache