Function: lngLatToMercator()
lngLatToMercator(
lng,lat): [number,number]
Defined in: cutline-bbox.ts:114
Project a single WGS84 lng/lat point (degrees) to EPSG:3857 meters.
Throws if the latitude falls outside the Web Mercator projection's valid range (±85.051129°).
This is intended to be used with the CutlineBbox module, which expects a bbox in 3857 meters. The conversion from WGS84 to 3857 is a one-time cost that can be done at bbox definition time, rather than per frame in the shader.
Parameters
lng
number
lat
number
Returns
[number, number]
Example
const [west, south] = lngLatToMercator(-120.75, 39.25);
const [east, north] = lngLatToMercator(-120.5, 39.5);
const bbox = [west, south, east, north];