Skip to main content
Version: General Availability - 1.0.6.X

Shapes

Intro: Shape accessor functions let you retrieve and manipulate ad‑hoc or record‑linked shapes (polygons, lines, points) rendered in the map control.


getShapes

Retrieve all shapes associated with a given context identifier (or all if the id represents a broad scope depending on implementation).

Parameters:

FieldTypeRequiredDescription
idstringYesContext / grouping id (related entity id or predefined scope).

Usage:

const shapes = control.getShapes();
console.log(shapes.length);

addOrUpdateShape

Creates or updates an existing shape using the shape parameters. If the ShapeId passed isn't in the shapes table it will create a new shape otherwise it will update an existing

Parameters (CustomShape):

FieldTypeRequiredDescription
shapeIdstringYes (create)Unique identifier. Reuse to update existing.
shapeNamestringYesDisplay name.
geoJsonObjectFeatureCollectionOptionalGeometry + properties (omit for name-only update).
predefinedShapeIdstringOptionalReference to a predefined shape configuration.
features[].typestringYes (geoJsonObject)GeoJSON feature type (e.g. Feature).
features[].propertiesobjectOptionalStyling / metadata (stroke, fill, etc.).
geometry.typestringYes (geoJsonObject)GeoJSON geometry type (Polygon, etc.).
geometry.coordinatesnumber[][][]Yes (geoJsonObject)Coordinates matching geometry type.

Usage:

const shapeGeoJson = {
shapeId: "7e0c4b6a-9f5d-4c2d-b1c3-6a2f9d8352d1",
shapeName: "My Created Shape"
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: { stroke: "#ff0000", fill: "#555555" },
geometry: {
type: "Polygon",
coordinates: [[[115.8376,-32.1152],[115.8385,-32.1158],[115.8403,-32.1172],[115.8376,-32.1152]]]
}
}
]
};
const shapes = control.addOrUpdateShape(shapeGeoJson);
console.log(shapes.length);

note
  • Ensure coordinates are in WGS84 ([longitude, latitude]).
  • If you only have raw GeoJSON, wrap it inside a MaptaskrShape with id, name, and geoJsonObject.
  • Use unique ids when adding multiple shapes.
  • Optional fields like minLatitude, maxLatitude, etc. can be precomputed if needed (e.g., for bounding-box queries).

deleteShape

Remove a shape from the map.

Parameters:

FieldTypeRequiredDescription
shapeMaptaskrShapeYesShape reference; must include the shapeId.

Usage:

await control.deleteShape(shape);
Deleting is irreversible—confirm with the user if the shape represents authored content.

Performance: Large polygons with many vertices can impact rendering; simplify geometry client‑side if possible before calling addShape or updateShape.