Installation
Using npm:
$ npm install --save global-mercator
In Node.js:
import * as mercator from 'global-mercator'
import { latLngToMeters } from 'global-mercator'
latLngToMeters
Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:900913
Parameters
Examples
latLngToMeters({lat: 45, lng: 90})
Returns Meters
metersToLatLng
Converts XY point from Spherical Mercator EPSG:900913 to lat/lng in WGS84 Datum
Parameters
Examples
metersToLatLng({mx: 10000000, my: 5500000})
Returns LatLng
metersToPixels
Converts EPSG:900913 to pyramid pixel coordinates in given zoom level
Parameters
Examples
metersToPixels({mx: 10000000, my: 5500000, zoom: 13})
Returns Pixels
latLngToTile
Returns Tile for given latlng coordinates
Parameters
Returns Tile latLngToTile({lat: 45, lng: 90, zoom: 5})
//=> Tile { tx: 23, ty: 20, zoom: 5 }
latLngToGoogle
Returns Google Tile for given latlng coordinates
Parameters
Examples
latLngToGoogle({lat: 45, lng: 90, zoom: 5})
Returns Google Google Tile
metersToTile
Returns Tile for given mercator coordinates
Parameters
Returns Tile metersToTile({mx: 10000000, my: 5500000, zoom: 5})
//=> Tile { tx: 23, ty: 20, zoom: 5 }
pixelsToMeters
Converts pixel coordinates in given zoom level of pyramid to EPSG:900913
Parameters
Returns Meters
pixelsToTile
Returns a Tile covering region in given pixel coordinates
Parameters
Returns Tile
tileBounds
Returns bounds of the given Tile in EPSG:900913 coordinates
Parameters
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
tileLatLonBounds
Returns bounds of the given Tile in EPSG:900913 coordinates
Parameters
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
googleBounds
Converts Google Tile system in Mercator bounds (Meters)
Parameters
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
googleLatLonBounds
Converts Google Tile system in LatLng bounds (degrees)
Parameters
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
tileGoogle
Converts TMS Tile coordinates to Google Tile coordinates
Parameters
Returns Array<number> bbox extent in [minX, minY, maxX, maxY] order
googleTile
Converts Google Tile coordinates to TMS Tile coordinates
Parameters
Returns Tile
googleQuadKey
Converts Google Tile coordinates to Microsoft QuadKey
Parameters
Returns quadkey
tileQuadKey
Converts TMS Tile coordinates to Microsoft QuadKey
Parameters
Returns quadkey
quadKeyTile
Converts QuadKey to TMS Tile coordinates
Parameters
Returns Tile
quadKeyGoogle
Converts QuadKey to Google Tile
Parameters
Returns Google
boundsLatLngToMeters
Converts bounds from LatLng to Meters
Parameters
bbox
Array<number> extent in [minX, minY, maxX, maxY] order
Returns Array<number> bounds
validateUndefined
Validate Undefined
Parameters
Examples
validateUndefined('Meters', Object)
validateTile
Validates Tile
Examples
const tile = validateTile({tx: 60, ty: 80, zoom: 5})
validateZoom
Validates Zoom
Examples
const zoom = validateZoom(12)
validatePixels
Validates Pixels
Examples
const pixels = validatePixels([-115, 44])
validateMeters
Validates Meters
Examples
const meters = validateMeters([-115, 44])
validateLatLng
Validates LatLng
Examples
validateLatLng([-115, 44])
validateLngLat
Validates LngLat
Examples
validateLngLat([-115, 44])
bounds
Validates bounds
Examples
const bounds = validateBounds([ -75, 44, -74, 45 ])