gi-nx / pickRawSections
ts
function pickRawSections(options?: {
customFilter?: (feature:
| RawPoint
| RawMultiPoint
| RawLineString
| RawMultiLineString
| RawPolygon
| RawMultiPolygon) => boolean;
filter?: number;
group?: boolean;
message?: string;
minimumCount?: number;
multiselect?: boolean;
preselect?: boolean;
}): Promise<(
| RawPoint
| RawMultiPoint
| RawLineString
| RawMultiLineString
| RawPolygon
| RawMultiPolygon)[]>;Prompts the user to pick one or more raw sections from the map. The promise resolves once the user confirms their selection (click or Enter).
Parameters
| Parameter | Type | Description |
|---|---|---|
options.customFilter? | (feature: | RawPoint | RawMultiPoint | RawLineString | RawMultiLineString | RawPolygon | RawMultiPolygon) => boolean | A custom filter function to further restrict which features are selectable. |
options.filter? | number | The geometry type(s) that can be selected. Combine with bitwise OR for multiple types. |
options.group? | boolean | Honor object grouping. If true and the user picks a grouped feature, the entire group is selected. |
options.message? | string | A prompt or message shown to the user. |
options.minimumCount? | number | Minimum number of features required before the selection can be confirmed. |
options.multiselect? | boolean | If true, the user can shift-click or shift-drag to select multiple features. |
options.preselect? | boolean | Allow pre-selected features to be returned without prompting. Defaults to true. |
Returns
Promise<( | RawPoint | RawMultiPoint | RawLineString | RawMultiLineString | RawPolygon | RawMultiPolygon)[]>
The selected raw sections, or an empty array if cancelled.
Example
ts
// Pick any feature
const features = await pickRawSections();
// Pick only polygons
const polygons = await pickRawSections({ filter: PickFilter.Polygon });
// Pick points or lines
const pointsOrLines = await pickRawSections({ filter: PickFilter.Point | PickFilter.LineString });
// Pick with a custom message and minimum count
const selected = await pickRawSections({ message: 'Select at least 2 buildings', minimumCount: 2 });