Coordinates2pixels
Coordinates2pixels is a utility module which helps to convert from geographic coordinates (EPSG:4326) to pixel coordinates and the other way round.
Installation
npm install --save coordinates2pixels
API
function | description |
---|---|
lng2pixel(lng, zoom) |
converts longitude to pixels coordinates (return a float). |
lat2pixel(lat, zoom) |
converts latitude to pixels coordinates (return a float). |
pixel2lng(x, zoom) |
converts x to geographic coordinates. |
pixel2lat(y, zoom) |
converts y to geographic coordinates. |
Usage
see example/square.js
var coords = ; // create a square around the coordinates { var px = coords py = coords; var box = coords coords coords coords return box;} // create a square of 100x100 pixels around coordinates (-70,-33)var bbox = ;// [ -33.00022494868904, -70.00026822090148, -32.99977505073747, -69.9997317790985 ]
License
License: http://jfgodoy.mit-license.org