mercatorProject

Chart
stable

Projects WGS-84 geographic coordinates (longitude / latitude) into SVG pixel space using the Web Mercator (EPSG:3857) formula. Reference canvas: 1000 × 500 px.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

lng
required
number
Longitude in degrees, range [-180, 180].
lat
required
number
Latitude in degrees, clamped to [-85, 85] to avoid Mercator divergence at the poles.
width
number
1000
SVG canvas width in pixels.
height
number
500
SVG canvas height in pixels.

API

Return value

The value returned by this util.

[x, y] pixel coordinates in SVG space, rounded to one decimal place.

Usage

Examples

Ready-to-paste usage snippets.

Project Paris onto a 1000×500 SVG canvas

typescript