This manual describes all the drawing modes available in TerraDraw for MapGL. Each mode provides different functionality for creating and editing geometric shapes on the map.
TerraDraw provides a comprehensive set of drawing tools for creating various geometric shapes and features on maps. The library supports both drawing new features and editing existing ones with advanced selection capabilities.
The select mode allows you to interact with existing features on the map.
Features:
- Selection: Click on any feature to select it
- Dragging: Move selected features by dragging them
- Rotation: Rotate polygons and linestrings using rotation handles
- Scaling: Resize features using scale handles
- Coordinate Editing:
- Drag individual coordinates to reshape features
- Add new coordinates at midpoints (for polygons and linestrings)
- Delete coordinates by selecting and pressing delete
- Snapping: Snap coordinates to nearby features while editing
Usage:
- Click the select tool to activate selection mode
- Click on any feature to select it
- Use the handles that appear to manipulate the feature
- Click elsewhere to deselect
Create individual point markers on the map.
Features:
- Single-click to place points
- Editable after creation when selected
- Draggable points
- Customizable point appearance (round, square, or minimal)
Usage:
- Select the point tool
- Click anywhere on the map to place a point
- Switch to select mode to edit or move points
Draw connected line segments to create paths, routes, or boundaries.
Features:
- Click to add points along the line
- Click on the last point (highlighted with a cap) to finish the line
- Coordinate snapping for precise alignment
- Editable coordinates with midpoint insertion
- Draggable and rotatable when selected
Usage:
- Select the linestring tool
- Click to place the first point
- Continue clicking to add more points
- Click on the last point (highlighted with a cap) to complete the line
Create closed shapes with multiple sides.
Features:
- Click to add vertices around the perimeter
- Click on one of the boundary points (highlighted with a cap) to close the polygon
- Self-intersection validation to prevent invalid shapes
- Pointer distance threshold for easier drawing (20px default)
- Advanced editing capabilities when selected
- Coordinate snapping support
Usage:
- Select the polygon tool
- Click to place the first vertex
- Continue clicking to add more vertices
- Click on one of the boundary points (highlighted with a cap) to close the polygon
Draw rectangular shapes quickly and precisely.
Features:
- Click and drag to define the rectangle
- Perfect for creating building footprints or area selections
- Resizable from center or corners when selected
- Maintains aspect ratio during creation
Usage:
- Select the rectangle tool
- Click and drag from one corner to the opposite corner
- Release to complete the rectangle
Create perfect circular shapes.
Features:
- Click and drag to define radius
- Center-fixed resizing when selected
- Useful for buffer zones or circular areas of interest
Usage:
- Select the circle tool
- Click to set the center point
- Drag outward to define the radius
- Release to complete the circle
Draw organic, hand-drawn style shapes.
Features:
- Natural drawing experience with mouse/touch
- Automatic shape closure for enclosed areas
- Minimum distance filtering (10px) for smoother curves
- Pointer distance threshold for better performance
- Ideal for sketching irregular boundaries
Usage:
- Select the freehand tool
- Click and drag to draw continuously
- Release to complete the shape (automatically closes if drawing forms an enclosed area)
Create rectangles that can be rotated to any angle.
Features:
- More flexible than standard rectangles
- Can be oriented to match features like buildings or property lines
- Rotatable and scalable when selected
Usage:
- Select the angled rectangle tool
- Click and drag to define one side of the rectangle
- Move to define the width
- Click to complete
Draw pie-slice or sector shapes.
Features:
- Useful for representing directional areas or zones
- Adjustable radius and angle
- Perfect for radar coverage, lighting cones, or vision fields
Usage:
- Select the sector tool
- Click to set the center point
- Define the direction and angle of the sector
- Set the radius
Create specialized sensor or detection area shapes.
Features:
- Designed for representing sensor coverage areas
- Complex geometric shapes for technical applications
- Customizable parameters for different sensor types
Usage:
- Select the sensor tool
- Follow the prompts to define sensor parameters
- Adjust coverage area as needed
Display and interact with pre-existing GeoJSON features.
Features:
- Load external GeoJSON data
- Custom styling for imported features
- Read-only display mode for reference data
- Styled with blue fill (#4357AD) and teal outline (#48A9A6)
- Click the color indicator to open a color picker
- Choose any color for outlines and fills
- Applies to new features and can update selected features
- Adjust line thickness from 1-10 pixels
- Use the slider control for quick adjustments
- Affects all linear elements (outlines, lines)
- Round: Circular points (default)
- Square: Square-shaped points
- None: Minimal dot points
- Export all drawn features as GeoJSON
- Downloads as
features.jsonfile - Compatible with GIS software and web mapping libraries
- Remove all features from the map
- Includes confirmation prompt to prevent accidental clearing
- Cannot be undone, so use with caution
- LineString: Click on the last point (highlighted with a visual cap) to finish drawing
- Polygon: Click on one of the boundary points (highlighted with caps) to close the shape
- Other shapes: Most other modes complete automatically when you finish the drawing gesture
- Highlighted caps: Show clickable points for completing features
- Midpoints: Appear as white dots on selected features for adding new coordinates
- Selection handles: Allow rotation, scaling, and coordinate manipulation
- Use snapping when precision is important
- Start with select mode to interact with existing features
- Use appropriate modes for your use case (e.g., rectangle for buildings, freehand for organic shapes)
- Regularly save/download your work to prevent data loss
- Test different point cap styles to match your visual requirements
- Polygons automatically validate against self-intersection
- Minimum distance thresholds prevent overly complex shapes
- Coordinate precision is maintained for accuracy
- Features can be edited extensively after creation
This drawing system integrates with MapGL and provides full TerraDraw functionality. All features are stored as valid GeoJSON and can be exported or integrated with other mapping systems.