marker.js 3 Documentation
    Preparing search index...

    Concepts: Markers

    Markers are the fundamental building blocks of annotations in marker.js 3. They define both the visual appearance and styling options for annotation elements that users can add to images.

    Markers represent different types of visual annotations like:

    • Shapes (rectangles, ellipses)
    • Lines and arrows
    • Text and callout elements
    • Freehand drawings
    • Image-based markers
    • And more

    Each marker type defines:

    • How it renders visually
    • What styling properties it supports
    • How it stores its state

    Markers in marker.js 3 follow a hierarchical structure starting with (abstract) base marker classes that provide common functionality:

    marker.js 3 includes these built-in marker types for common annotation needs:

    User-driven marker creation is initiated in the MarkerArea editor component. To create a new marker, use the createMarker() method and specify the marker type:

    markerArea.createMarker(ArrowMarker);
    // or
    markerArea.createMarker('ArrowMarker');

    Each marker maintains its own state including:

    • Position and size
    • Rotation
    • Style properties (colors, stroke width, etc.)
    • Type-specific properties

    The marker states are included in the overall annotation state when saving/restoring annotations.

    Markers are part of the Core module in marker.js 3 since they are used by all main components:

    • MarkerArea (Editor) - For creating and editing markers
    • MarkerView (Viewer) - For displaying markers
    • Renderer - For rendering markers to static images

    When none of the built-in markers satisfy your needs you may want to create a custom marker. The marker should be a descendant of MarkerBase (quite likely one of the base classes above is a better candidate to inherit) and should be able to generate its visual as well as provide and restore its state.

    For mor information on creating custom markers please check this tutorial.