Global Mercator
A set of tools geospatial tools to help with TMS, Google (XYZ) Tiles.
This library is insipered by GDAL2Tiles, Google Summer of Code 2007 & 2008
Installation
Using npm:
$ npm install --save global-mercator
In Node.js:
import * as mercator from 'global-mercator'
import { latLngToMeters } from 'global-mercator'
latLngToMeters
Converts LatLng coordinates to Meters coordinates.
Parameters
Examples
latLngToMeters({lat: 37, lng: 126})
Returns Object Meters coordinates
metersToLatLng
Converts Meters coordinates to LatLng coordinates.
Parameters
Examples
metersToLatLng({ mx: 14026255, my: 4439106 })
Returns Object LatLng coordinates
metersToPixels
Converts Meters coordinates to Pixels coordinates.
Parameters
Examples
metersToPixels({ mx: 14026255, my: 4439106, zoom: 13 })
Returns Object Pixels coordinates
latLngToTile
Converts LatLng coordinates to TMS Tile.
Parameters
Examples
latLngToTile({lat: 37, lng: 126, zoom: 13 })
Returns Object TMS Tile
latLngToGoogle
Converts LatLng coordinates to Google (XYZ) Tile.
Parameters
Examples
latLngToGoogle({lat: 37, lng: 126, zoom: 13 })
Returns Object Google (XYZ) Tile
metersToTile
Converts Meters coordinates to TMS Tile.
Parameters
Examples
metersToTile({ mx: 14026255, my: 4439106, zoom: 13 })
Returns Object TMS Tile
pixelsToMeters
Converts Pixels coordinates to Meters coordinates.
Parameters
Examples
pixelsToMeters({ px: 1782579, py: 1280877, zoom: 13 })
Returns Object Meters coordinates
pixelsToTile
Converts Pixels coordinates to TMS Tile.
Parameters
Examples
pixelsToTile({ px: 1782579, py: 1280877, zoom: 13 })
Returns Object TMS Tile
tileBbox
Converts TMS Tile to bbox in Meters coordinates.
Parameters
Examples
tileBbox({ tx: 6963, ty: 5003, zoom: 13 })
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
tileLatLngBbox
Converts TMS Tile to bbox in LatLng coordinates.
Parameters
Examples
tileLatLngBbox({ tx: 6963, ty: 5003, zoom: 13 })
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
googleBbox
Converts Google (XYZ) Tile to bbox in Meters coordinates.
Parameters
Examples
googleBbox({ x: 6963, y: 3188, zoom: 13 })
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
googleLatLngBbox
Converts Google (XYZ) Tile to bbox in LatLng coordinates.
Parameters
Examples
googleLatLngBbox({ x: 6963, y: 3188, zoom: 13 })
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
tileGoogle
Converts TMS Tile to Google (XYZ) Tile.
Parameters
Examples
tileGoogle({ tx: 6963, ty: 5003, zoom: 13 })
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
googleTile
Converts Google (XYZ) Tile to TMS Tile.
Parameters
Examples
googleTile({ x: 6963, y: 3188, zoom: 13 })
Returns Object TMS Tile
googleQuadkey
Converts Google (XYZ) Tile to Quadkey.
Parameters
Examples
googleQuadkey({ x: 6963, y: 3188, zoom: 13 })
Returns string Quadkey
tileQuadkey
Converts TMS Tile to QuadKey.
Parameters
Examples
tileQuadkey({ tx: 6963, ty: 5003, zoom: 13 })
Returns string Quadkey
quadkeyTile
Converts Quadkey to TMS Tile.
Parameters
Examples
quadkeyTile('1321102330211')
Returns Object TMS Tile
quadkeyGoogle
Converts Quadkey to Google (XYZ) Tile.
Parameters
Examples
quadkeyGoogle('1321102330211')
Returns Object Google (XYZ) Tile
bboxLatLngToMeters
Converts bbox from LatLng coordinates to Meters coordinates
Parameters
bbox
Array<number> extent in [minX, minY, maxX, maxY] order
Examples
bboxLatLngToMeters([ 125, 35, 127, 37 ])
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
validateTile
Validates TMS Tile.
Parameters
Examples
validateTile({tx: 60, ty: 80, zoom: 5})
validateTile({tx: 60, ty: -43, zoom: 5})
Returns Object TMS Tile
validateZoom
Validates Zoom level.
Parameters
Examples
validateZoom(12)
validateZoom(-4)
validateZoom(30)
Returns number Zoom level
validatePixels
Validates Pixels coordinates.
Parameters
Examples
validatePixels([-115, 44])
Returns Array<number> Pixels coordinates
validateMeters
Validates Meters coordinates.
Parameters
Examples
validateMeters([-115, 44])
Returns Array<number> Meters coordinates
validateLatLng
Validates LatLng coordinates.
Parameters
Examples
validateLatLng([-115, 44])
Returns Array<number> LatLng coordinates
validateLngLat
Validates LngLat coordinates.
Parameters
Examples
validateLngLat([-115, 44])
Returns Array<number> LngLat coordinates
validateBbox
Validates bbox.
Parameters
bbox
Array<number> extent in [minX, minY, maxX, maxY] order
Examples
validateBbox([ -75, 44, -74, 45 ])
validateBbox([ -75, 44, -74 ])
assertUndefined
Assert undefined items within object.
Parameters
Examples
assertUndefined({foo: 'bar'})
assertUndefined({foo: undefined})
Returns Object items