Calculate map tiles for given map extent and zoom level. Considering map extent coordinates are in sperical (web) mercator projection.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
test
.gitignore
LICENSE.md
README.md
index.js
package.json

README.md

web-mercator-tiles

Calculate map tiles for given map extent and zoom level. Considering map extent coordinates are in sperical (web) mercator projection.

installation

npm install web-mercator-tiles

usage

var webMercatorTiles = require('web-mercator-tiles');
function: webMercatorTiles(extent,zoom)
parameters:
  extent: map extent of window or div in spherical mercator projeection (meters)
    {
      left: coordinate in meter,
      right: coordinate in meter,
      bottom: coordinate in meter,
      top: coordinate in meter
    }
  zoom: zoom level as integer
output: array of tiles object, where tile object is 
  {
    X: tile number in x direction
    Y: tile number in y direction 
    Z: tile number for zoom
    top: top of tile image position in window as pixel
    left: left of tile image position in window as pixel
  }

example

var webMercatorTiles = require('web-mercator-tiles'),
  mapExtent = {
    left:-7929831.7499857,
    bottom:5227055.1160079,
    right:-7910263.8707475,
    top:5236839.0556271
  },
  zoom = 12;
tiles = webMercatorTiles(mapExtent,zoom);
// tiles are
/*
[ { X: 1237, Y: 1512, Z: 12, top: -192, left: -129 },
  { X: 1237, Y: 1513, Z: 12, top: 64, left: -129 },
  { X: 1238, Y: 1512, Z: 12, top: -192, left: 127 },
  { X: 1238, Y: 1513, Z: 12, top: 64, left: 127 },
  { X: 1239, Y: 1512, Z: 12, top: -192, left: 383 },
  { X: 1239, Y: 1513, Z: 12, top: 64, left: 383 } ]
*/
```
## Similar
Check [map-the-tiles](https://www.npmjs.com/package/map-the-tiles) for projections other than spherical mercator, and having spherical mecator as default projection.
## developing
Once you run
 
```npm isntall```

then for running test 

```npm run test```

to create build

```npm run build```

## license
This project is licensed under the terms of the MIT license.