Skip to content

gi-nx


gi-nx / getUserDrawnPolygon

ts
function getUserDrawnPolygon(): Promise<{
  geometry: {
     coordinates: [number, number][][];
     type: "Polygon";
  };
  properties: Record<string, any>;
  type: "Feature";
}>;

Prompt the user to draw a polygon on the map. The promise resolves once the user completes the polygon, or undefined if cancelled. Hold 's' to snap to nearby features.

Returns ​

Promise<{ geometry: { coordinates: [number, number][][]; type: "Polygon"; }; properties: Record<string, any>; type: "Feature"; }>

The drawn polygon, or undefined if cancelled.

Example ​

typescript
const polygon = await rpc.invoke("getUserDrawnPolygon", []);
if (polygon) {
  console.log("Drawn polygon:", polygon.geometry.coordinates);
}