Feature<T extends Geometry> constructor

const Feature<T extends Geometry>({
  1. Object? id,
  2. T? geometry,
  3. Map<String, dynamic>? properties,
  4. Box? bounds,
  5. Map<String, dynamic>? custom,
})

A feature of id, geometry and properties.

An optional id, when given, should be either a string or an integer number.

An optional geometry of T, when given, is the primary geometry of the feature.

An optional properties defines feature properties as a map with data similar to a JSON Object.

An optional bounds can used set a minimum bounding box for a feature.

Use an optional custom parameter to set any custom or "foreign member" properties.

Examples:

// a feature with an id and a point geometry (2D coordinates)
Feature(
  id: '1',
  geometry: Point([10.0, 20.0].xy),
);

// a feature with properties and a line string geometry (3D coordinates)
Feature(
  geometry: LineString(
    // three (x, y, z) positions
    [10.0, 20.0, 30.0, 12.5, 22.5, 32.5, 15.0, 25.0, 35.0]
        .positions(Coords.xyz),
  ),
  // properties for a feature containing JSON Object like data
  properties: {
    'textProp': 'this is property value',
    'intProp': 10,
    'doubleProp': 29.5,
    'arrayProp': ['foo', 'bar'],
  },
);

Implementation

const Feature({
  Object? id,
  T? geometry,
  Map<String, dynamic>? properties,
  super.bounds,
  super.custom,
})  : _id = id,
      _properties = properties ?? const {},
      _geometry = geometry;