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
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- polygonrequiredArray<[number, number]>
- Array of [longitude, latitude] coordinate pairs. At least 3 pairs are required to produce a non-empty path.
- widthnumber1000
- Width of the SVG canvas in user units. Defaults to 1000.
- heightnumber500
- Height of the SVG canvas in user units. Defaults to 500.
API
Return value
The value returned by this 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
Examples
Ready-to-paste usage snippets.
Project a geographic polygon