Skip to content

gi-nx


gi-nx / drawPoint

ts
function drawPoint(options?: {
  message?: string;
  preselect?: boolean;
}): Promise<[number, number]>;

Prompts the user to click on the map to place a point. The promise resolves with the geographic coordinate once the user clicks, or null if cancelled. Hold 's' to snap to nearby features.

Parameters ​

ParameterTypeDescription
options.message?stringA prompt or message shown to the user.
options.preselect?booleanIf true and a point feature is already selected, return its coordinates without prompting. Defaults to true.

Returns ​

Promise<[number, number]>

Example ​

ts
// Get a point from the user
const point = await rpc.invoke("drawPoint");
if (point) console.log(`Clicked at ${point[0]}, ${point[1]}`);

// With a custom message
const origin = await rpc.invoke("drawPoint", [{ message: 'Click to place the origin' }]);

// Skip pre-selected point features
const fresh = await rpc.invoke("drawPoint", [{ preselect: false }]);