New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →
Socket
Sign inDemoInstall
Socket

global-mercator

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-mercator

Global Mercator

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
967
decreased by-16.42%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

Using npm:

$ npm install --save global-mercator

In Node.js:

// Load all functions
import * as mercator from 'global-mercator'

// Load a single function
import { latLngToMeters } from 'global-mercator'

latLngToMeters

Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:900913

Parameters

  • lat number
  • lng number
  • zoom number (Optional)

Examples

latLngToMeters({lat: 45, lng: 90})
//=> Meters { mx: 10018754.171394622, my: 5621521.486192067 }

Returns Meters

metersToLatLng

Converts XY point from Spherical Mercator EPSG:900913 to lat/lng in WGS84 Datum

Parameters

Examples

metersToLatLng({mx: 10000000, my: 5500000})
//=> LatLng { lat: 44.2228902348575, lng: 89.83152841195214 }

Returns LatLng

metersToPixels

Converts EPSG:900913 to pyramid pixel coordinates in given zoom level

Parameters

Examples

metersToPixels({mx: 10000000, my: 5500000, zoom: 13})
//=> Pixels { px: 1571882.5818671728, py: 1336394.6200269451, zoom: 13 }

Returns Pixels

latLngToTile

Returns Tile for given latlng coordinates

Parameters

Returns Tile

latLngToGoogle

Returns Google Tile for given latlng coordinates

Parameters

Returns Google Google Tile

metersToTile

Returns Tile for given mercator coordinates

Parameters

Returns Tile

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})
//= {tx: 60, ty: 80, zoom: 5}

validateZoom

Validates Zoom

Examples

const zoom = validateZoom(12)
//= 12

validatePixels

Validates Pixels

Examples

const pixels = validatePixels([-115, 44])
//= [-115, 44]

validateMeters

Validates Meters

Examples

const meters = validateMeters([-115, 44])
//= [-115, 44]

validateLatLng

Validates LatLng

Examples

validateLatLng([-115, 44])
//= [-115, 44]

validateLngLat

Validates LngLat

Examples

validateLngLat([-115, 44])
//= [-115, 44]

bounds

Validates bounds

Examples

const bounds = validateBounds([ -75, 44, -74, 45 ])
//= [ -75, 44, -74, 45 ]

FAQs

Package last updated on 21 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc