FeatureCollectionInput

Edits a GeoJSON FeatureCollection with the tools of its allowedShapes, Point, LineString and Polygon by default. Each feature keeps its own properties when another is removed. It is ShapeInput under the name of a GeoJSON type, with kind set for you.

Edits a GeoJSON FeatureCollection with the tools of its allowedShapes, Point, LineString and Polygon by default. Each feature keeps its own properties when another is removed. It is ShapeInput under the name of a GeoJSON type, with kind set for you.

Installation

import { FeatureCollectionInput } from "@chelone/react/maps/draw";

See the maps guide for the subpaths, the optional packages and MapsProvider.

Props

PropTypeDefaultDescription
allowedShapesreadonly GeometryShape[]—The shapes the user may draw. Defaults to `Point`, `LineString` and `Polygon`.
allowSelfIntersectionboolean—Set to false to flag a shape that crosses itself. Defaults to true, which checks nothing.
aspectRationumber—Width over height of a `BBox` value. The stored box grows around its centre to this ratio and never shrinks, and the rectangle on the map follows it.
classNamestring—
defaultCenterreadonly [number, number]—`[lat, lng]`. The map centre while the field is empty. Defaults to `[0, 0]`.
disabledboolean—Shows the shape and hides the toolbar; pan and zoom still work.
fitBoundsboolean—Frame the first value on the map. The user's own edits never refit. Defaults to true.
heightstring | number—In pixels, or any CSS length. Defaults to 300.
helperTextReactNode—
labelReactNode—The legend. A string is translated; `false` renders none.
mapStyleMapStyleInput—Defaults to the style from `MapsProvider`.
maxVerticesnumber—Most vertices the shape may have.
minAreaM2number—Smallest area in square metres a polygon may cover.
minVerticesnumber—Fewest vertices the shape may have; a polygon ring counts its distinct vertices. The shape is stored as drawn and the field is flagged.
onCommit(value: ShapeValue | null) => void—Called with the stored value after each drawing or edit has been written to the form, and again after `refine` writes a changed one.
refine(value: ShapeValue, options: { signal: AbortSignal }) => ShapeValue | Promise<ShapeValue | null> | null—Adjusts the value after the user's own drawing or edit, such as snapping a line to roads. It runs once the edit is in the form, never on load or reset, and a newer edit or an unmount aborts `signal`. A result that is not null and differs is written, unless the field changed meanwhile. A thrown error keeps the value as drawn. A null result is "nothing to change" unless `refineFailedMessage` is set, which a throw also notifies.
refineFailedMessagestring—Message key notified as a warning when `refine` resolves to null or throws (an abort excepted), and the value is kept as drawn. `LineStringInput` sets it for `snapToRoads`.
shapeStyleShapeStyle—Partial over `DEFAULT_SHAPE_STYLE`. Read once.
snapDistancenumber—Pixels within which the pointer grabs a vertex or snaps. Read once. Defaults to 20.
snappableboolean—Snap to existing coordinates and lines. Read once. Defaults to true.
sourcestring—The form field holding the GeoJSON value.
toolsreadonly ToolbarTool[]—The toolbar buttons, in order. Defaults to the tools that suit `kind`.
validateValidator | readonly Validator[]—Runs after the limits below.
zoomnumber—Read once at mount. Defaults to 13.