Adds a custom GeoJSON geometry (Shape) to the map.
A valid GeoJSON feature collection containing Polygon, MultiPolygon, or LineString features.
Styling options for the geometry (see PaintStyle for polygons, LineStyle for lines).
Optionalfloor: FloorOptional floor to add the geometry to. If not specified, uses the current floor.
The created shape, or undefined if creation failed.
const polygon = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [[[lng1, lat1], [lng2, lat2], [lng3, lat3], [lng1, lat1]]]
}
}]
};
const shape = mapView.Shapes.add(polygon, { color: 'red' }, mapView.currentFloor);
const lineString = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [[lng1, lat1], [lng2, lat2]]
}
}]
};
const line = mapView.Shapes.add(lineString, { color: 'blue', width: 2 });
const shape = mapView.Shapes.add(geometry, {
color: 'green',
opacity: 0.7,
height: 2,
interactive: true
}, mapView.currentFloor);
Shapes in Mappedin JS
The Shapes class allows you to draw custom 3D geometry on the map using GeoJSON. You can create polygons, multi-polygons, and line strings to highlight areas, create custom boundaries, or add visual overlays to your indoor map.
Features
Example Usage
Styling Options
PaintStylewith color, opacity, heightLineStylewith color, width, opacityinteractive: truefor click/hover eventsAdvanced
altitudeto position shapes at specific heights.heightto create 3D extruded shapes.interactive: trueto make shapes clickable.floorparameter to place shapes on specific floors.More Information
This class is accessed using MapView.Shapes.