Skip to content

gi-nx


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

ParameterTypeDescription
options.customFilter?(feature: | RawPoint | RawMultiPoint | RawLineString | RawMultiLineString | RawPolygon | RawMultiPolygon) => booleanA custom filter function to further restrict which features are selectable.
options.filter?numberThe geometry type(s) that can be selected. Combine with bitwise OR for multiple types.
options.group?booleanHonor object grouping. If true and the user picks a grouped feature, the entire group is selected.
options.message?stringA prompt or message shown to the user.
options.minimumCount?numberMinimum number of features required before the selection can be confirmed.
options.multiselect?booleanIf true, the user can shift-click or shift-drag to select multiple features.
options.preselect?booleanAllow 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 });