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

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

lng
requis
number
Longitude in degrees, range [-180, 180].
lat
requis
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

Valeur de retour

La valeur retournée par cet util.

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

Usage

Exemples

Extraits de code prêts à coller.

Project Paris onto a 1000×500 SVG canvas

typescript