Once aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/spatialillusions/milsymbol/llms.txt
Use this file to discover all available pages before exploring further.
Symbol instance is created, its methods let you render the symbol in multiple formats, interrogate the decoded SIDC metadata, retrieve or update options, and validate the symbol code. All rendering methods reflect the current state of the symbol — calling setOptions before any render method gives you the updated output. Methods that return this can be chained directly.
Rendering Methods
asSVG()
Returns the symbol rendered as an SVG markup string. This is the lightest-weight rendering path and works in any environment (browser, Node.js, Deno).
A complete
<svg> element as a string, ready to be injected into the DOM or
written to a file.asCanvas(factor?)
Returns the symbol rendered onto an HTMLCanvasElement. An optional resolution factor multiplies the pixel dimensions of the canvas, which is useful for high-DPI (Retina) displays.
Optional resolution multiplier. A value of
2 produces a canvas that is
twice as wide and tall in pixels, giving a sharper image on HiDPI screens.
Does not affect the values returned by getSize(), getAnchor(), or
getOctagonAnchor().A canvas element with the symbol painted onto it at the requested resolution.
factor scales the raw canvas pixel buffer only. The logical dimensions
reported by getSize() and the anchor coordinates from getAnchor() /
getOctagonAnchor() are always based on the unscaled size.asDOM()
Returns the symbol as a live SVG Element in the browser’s DOM. Suitable for direct insertion into an HTML document or further DOM manipulation.
An SVG DOM element representing the symbol.
asOffscreenCanvas(factor?)
Returns the symbol rendered onto an OffscreenCanvas. Intended for use in Web Workers, where HTMLCanvasElement is unavailable.
Optional resolution multiplier — identical semantics to the
factor
parameter in asCanvas(). Does not affect the values returned by
getSize(), getAnchor(), or getOctagonAnchor().An
OffscreenCanvas with the symbol painted onto it.toDataURL()
Returns the SVG of the symbol encoded as a Base64 data URL (data:image/svg+xml;base64,...). Useful for assigning the symbol as the src of an <img> element.
A Base64-encoded SVG data URL string.
Geometry & Size Methods
getAnchor()
Returns the anchor point — the position within the symbol image that should be pinned to the map coordinate. Measured in pixels from the top-left corner of the symbol bounding box.
getOctagonAnchor()
Returns the center of the symbol’s octagon (the core tactical symbol shape), measured in pixels from the top-left corner of the bounding box. Use this when you want to align two symbols by their octagon centers, rather than by the anchor pin point.
getSize()
Returns the pixel dimensions of the rendered symbol bounding box. The dimensions include all drawn parts: the frame, any modifiers, text labels, the direction arrow, and any extra padding.
getSize() always reflects the logical size regardless of the factor
passed to asCanvas() or asOffscreenCanvas().Color & Style Methods
getColors()
Returns the full set of resolved colors used to render the symbol, reflecting the current colorMode, fillColor, monoColor, and related style options.
ColorMode object has the shape:
Metadata Method
getMetadata()
Returns an object containing all metadata computed from the symbol’s SIDC. This is the primary way to introspect what milsymbol understood about the code — affiliation, dimension, echelon, special modifiers, and so on.
Options Methods
getOptions(includeStyle?)
Returns the options currently set on the symbol. By default the returned object includes both modifier and style options.
When
true (or omitted), style options are included in the returned object.
When false, only non-style options (e.g. SIDC, modifiers) are returned.
Defaults to true.The current options object. See the Symbol Constructor
for the full list of available option keys.
getStyle()
Returns only the style portion of the symbol’s current options. Equivalent to calling getOptions(true) and keeping only the style keys.
An object containing only the style-related options (e.g.
size, fill,
colorMode, outlineWidth, etc.).setOptions(...args)
Updates the symbol’s options and triggers a full re-render. Accepts any number of options objects, merged in order — identical in semantics to passing multiple options objects to the constructor. A new SIDC can be supplied via the sidc property in any of the argument objects.
Returns this, so calls can be chained.
One or more options objects to merge into the current symbol options. Pass a
sidc key to change the symbol code. All keys are optional — only the
supplied keys are updated.The symbol instance (
this), enabling method chaining.Validation Method
isValid(extended?)
Validates the symbol’s SIDC. Without an argument (or with extended set to false) returns a simple boolean indicating whether milsymbol was able to find an icon for the provided SIDC. With extended set to true, returns a detailed object describing the validity of individual SIDC parts.
When
false or omitted, returns a boolean — true if a valid icon was
found for the SIDC, false otherwise. When true, returns an object
describing the validity of each part of the SIDC code.A
boolean when extended is false or omitted; a validity detail object
when extended is true.Method Chaining
BecausesetOptions returns this, you can build a fully configured symbol and render it in a single expression:
