You can create custom markers by defining an object that maps a CSS class for styling to an SVG slice ID for the visual shape.
Marker Object Schema
An object must contain:
class: The CSS class used to style the marker (e.g., setting stroke, opacity, etc.).slice: The id of the <g> element within sprite.svg that defines the marker's shape.
Implementation Example
To create a red circle marker, you would define a CSS class .marker-circle-red and use the existing markerCircle slice from the SVG.
/* Define the visual style */
marker.marker-circle-red {
stroke: #aa0000;
stroke-width: 3px;
opacity: 0.4;
}
// Define the custom marker type
const myMarkerType = { class: "marker-circle-red", slice: "markerCircle" };
// Use it on the board
chessboard.addMarker(myMarkerType, "e4");
// Remove specific instances
chessboard.removeMarkers(myMarkerType, "e4");
// Remove all markers of this custom type
chessboard.removeMarkers(myMarkerType);
const myMarkerType = {class: "marker-circle-red", slice: "markerCircle"}
// add
chessboard.addMarker(myMarkerType, "e4")
// remove a specific marker
chessboard.removeMarkers(myMarkerType, "e4")
// remove all "myMarkerType"
chessboard.removeMarkers(myMarkerType)
// remove all markers
chessboard.removeMarkers()