milsymbol was designed from the ground up to be extensible. Every visual feature of a rendered symbol — from the icon to text field layout to direction arrows — is implemented as a modular symbol part, and the same mechanism is exposed publicly so you can inject custom parts, override built-in icons, register entirely new SIDC codes, and reshape label positioning without ever forking the library. All extension functions return theDocumentation 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.
ms namespace object, so calls can be chained.
ms.addSymbolPart()
Registers a new symbol function that participates in every symbol’s rendering pipeline. A symbol part is called once per symbol render and can contribute draw instructions that are painted before (pre) or after (post) all other parts, along with a bounding box that informs milsymbol how much extra space the additions need.
A function called with
this bound to the current Symbol instance and the ms namespace passed as the first argument. It must return an object with pre (draw instructions rendered before everything else), post (draw instructions rendered after everything else), and bbox (the combined bounding box of those instructions).ms namespace object (chainable).
Inside the extension function, use
this.getOptions() to read the symbol’s current options and this.getMetadata() to access computed metadata such as affiliation, echelon, and dimension. Both are available because this is the live Symbol instance.Pre vs. post draw arrays
| Array | When it is painted |
|---|---|
pre | Before the symbol frame, fill, and icon — useful for background layers or halos. |
post | After the symbol frame, fill, and icon — useful for overlays, annotations, or decorators. |
Example
ms.addIconParts()
Registers a function that can add or override entries in the shared icon parts dictionary — the lookup table that maps icon-part keys (like"TP.HARBOR") to DrawInstruction values. Multiple icon parts are combined to build a single symbol icon, which keeps the library lean by reusing common shapes across many SIDCs.
A function called with
this bound to the current Symbol instance. Receives the mutable iconParts dictionary, the symbol’s computed metadata, and the resolved colors object. Modify iconParts in place — no return value is needed.ms namespace object (chainable).
Parameters received by IconPartsFunction
| Parameter | Type | Description |
|---|---|---|
iconParts | Record<string, DrawInstruction | DrawInstruction[]> | The live dictionary of all registered icon parts. Set a key to add or override a part. |
metadata | SymbolMetadata | Computed metadata for the current symbol (affiliation, echelon, dimension, etc.). |
colors | SymbolColors | Resolved color values for the current symbol and color mode. |
Example — adding a custom tactical point harbor icon
ms.addSIDCicons()
Registers a function that maps SIDC codes to icon parts and bounding boxes. Use this to add custom SIDC codes whose icons are assembled from entries in the icon parts dictionary, or to override how existing SIDCs are rendered.ms.addSIDCicons() is a JavaScript-only API. It is not included in the TypeScript type declarations (index.d.ts). It is available at runtime on the ms namespace but TypeScript will not recognise it without a custom declaration augmentation.A function called with four arguments:
sidc (the mutable SIDC-to-icon-parts mapping), bbox (the mutable SIDC-to-bounding-box mapping), iconParts (the full icon parts dictionary), and std2525 (boolean — true if the active standard is 2525). Modify sidc and bbox in place; no return value is needed. If you omit a bounding box entry for a SIDC, milsymbol falls back to the bounds of the icon octagon.Whether the SIDCs being registered use the letter-based format (e.g.
"G-T-D-----") or the number-based format.ms namespace object (chainable).
Example — registering two custom tactical graphic SIDCs
ms.addLabelOverrides()
Registers a function that customizes how text-field labels are positioned for specific SIDC codes. By default, milsymbol places all label fields (unique designation, higher formation, DTG, etc.) at fixed positions relative to the symbol frame. For tactical graphics and other non-standard symbols, those default positions may be wrong —addLabelOverrides lets you specify exact placement per field per SIDC.
ms.addLabelOverrides() is a JavaScript-only API. It is not included in the TypeScript type declarations (index.d.ts). It is available at runtime on the ms namespace but TypeScript will not recognise it without a custom declaration augmentation.A function that receives the mutable
sidc label-override object. For each SIDC key you want to override, set a value that is itself an object keyed by field name (e.g. "uniqueDesignation", "hostile", "dtg"), where each field value is an object of draw-instruction properties to merge into that label’s text instruction (x, y, textanchor, fontsize, stroke, etc.). Modify sidc in place — no return value is needed.Whether the SIDCs being overridden use the letter-based or number-based format.
ms namespace object (chainable).
Example — repositioning labels for a control point SIDC
ms.getSymbolParts() / ms.setSymbolParts()
These functions provide direct access to the internal array of all registered symbol functions — both the built-in milsymbol parts and any you have added viams.addSymbolPart().
ms.getSymbolParts() and ms.setSymbolParts() are JavaScript-only APIs. They are not included in the TypeScript type declarations (index.d.ts). Both are available at runtime on the ms namespace but TypeScript will not recognise them without a custom declaration augmentation.ms.getSymbolParts()
Returns a copy of the current array of all symbol part functions.Array of symbol part functions in the order they will be executed during rendering.
ms.setSymbolParts()
Replaces the entire array of symbol part functions with a new one.The complete replacement array of symbol part functions.
ms namespace object (chainable).
