milsymbol makes it straightforward to go from a Symbol Identification Code (SIDC) to a rendered military unit symbol. This guide walks you through installing the library, creating your first symbol object, rendering it as SVG or Canvas output, and adding modifiers and style options to customize the result.Documentation 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.
Install milsymbol
Install milsymbol from the npm registry using your preferred package manager.Alternatively, you can include it directly in an HTML page via the bundled browser script — see the Installation guide for the script tag and CDN options.
Import and create a symbol
Import milsymbol and call The first argument is the SIDC — a Symbol Identification Code that encodes the symbol’s affiliation, dimension, status, icon, echelon, and modifiers. milsymbol supports both the 30-character number-based format used by MIL-STD-2525D/E and APP-6 D/E (as above) and the 15-character letter-based format used by older standard versions (e.g.
new ms.Symbol(sidc, options) to create a symbol object."SFG-UCI----D---"). The format is detected automatically.The second argument is an optional options object containing style settings and text modifiers. Options can also be applied later via sym.setOptions(options).Render the symbol
Call Methods can be chained directly onto the constructor call for a more concise form:
.asSVG() to get an SVG string you can inject into the DOM, or .asCanvas() to get an HTMLCanvasElement ready to append to a page..asSVG() returns a plain XML string. .asCanvas() returns an HTMLCanvasElement and requires a browser environment. In Node.js, use .asSVG() or the SVG DOM method .asDOM() instead.Add options and text modifiers
Pass an options object as the second argument to control the symbol’s appearance and attach standard text modifier fields. Options can also be updated at any time with Options can also be applied or updated after creation:Use
setOptions.sym.getAnchor() to get the { x, y } offset for correct placement on a map or canvas, and sym.getSize() to retrieve the rendered symbol’s { width, height } dimensions.Full Working Example
The following example creates a symbol for a friendly infantry platoon using the MIL-STD-2525D/E number-based SIDC"130310001412110000000000000000". It sets a custom size, attaches a unique designation text modifier, and renders the result both as an SVG string and as a Canvas element.
Next Steps
SIDC Codes
Learn how to read and construct letter-based and number-based SIDCs.
Symbol Options
Explore the complete set of style options: fill, frame, color modes, outlines, and more.
Text Modifiers
Reference all standard text modifier fields (unique designation, quantity, DTG, location, etc.).
Symbol Constructor API
Full API reference for
ms.Symbol, including all methods and return types.