Skip to main content
Version: Release 1 - 1.1.3.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.
geoJsonObject.features[].typestringYes (geoJsonObject)GeoJSON feature type (e.g. Feature).
geoJsonObject.features[].propertiesobjectOptional (geoJsonObject)Styling / metadata (stroke, fill, etc.).
geoJsonObject.features[].geometry.typestringYes (geoJsonObject)GeoJSON geometry type (Polygon, etc.).
geoJsonObject.features[].geometry.coordinatesnumber[][][]Yes (geoJsonObject)Coordinates matching geometry type.

Usage:

const shapeGeoJson = {
geoJsonObject: {
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]
]
]
}
}]
}
predefinedShapeId: undefined
shapeId: "deaaffa5-651b-f111-8341-002248156da6"
shapeName: "Layer2"
}

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.