Reference · Framing, geometry and quiz tools
unprojectPointfunction
The longitude and latitude (in degrees) of a point on the map's canvas, as [lon, lat]; null where projectPoint is.
Import it
import { unprojectPoint } from "@johnmorrisdotca/chizu";
Definition
function unprojectPoint(map: Pick<ChizuMap, "projection">, x: number, y: number): [number, number] | null
Parameters
| Name | Type | Description |
|---|---|---|
map | Pick<ChizuMap, "projection"> | The native map or map fields required by this signature; coordinates and region codes belong to its canvas. |
x | number | The horizontal native map coordinate. |
y | number | The vertical native map coordinate. |
Returns
[number, number] | null
The [longitude, latitude] pair in degrees, or null when the map’s projection is not reversible here.
Examples
import WORLD from "@johnmorrisdotca/chizu/world";
import { projectPoint, unprojectPoint } from "@johnmorrisdotca/chizu";
const [x, y] = projectPoint(WORLD, 2.35, 48.86)!;
console.log(unprojectPoint(WORLD, x, y)!.map((value) => value.toFixed(2)).join(", "));
// 2.35, 48.862.35, 48.86What it prints (run when this page was built)