polygonToSvgPath

Chart
stable

Project an array of geographic [lng, lat] pairs to a Mercator-projected, closed SVG path string. Returns an empty string when fewer than 3 points are provided.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

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

polygon
requis
Array<[number, number]>
Array of [longitude, latitude] coordinate pairs. At least 3 pairs are required to produce a non-empty path.
width
number
1000
Width of the SVG canvas in user units. Defaults to 1000.
height
number
500
Height of the SVG canvas in user units. Defaults to 500.

API

Valeur de retour

La valeur retournée par cet util.

A closed SVG path `d` string (M…L…Z) with Mercator-projected coordinates, or an empty string when fewer than 3 points are given.

Usage

Exemples

Extraits de code prêts à coller.

Project a geographic polygon

typescript