The basic constructor for MilitarySymbologyPainter. This constructor allows you to define a few functions to retrieve specific properties (such as modifiers and styling) for a given feature. An example of how this works is given in the class documentation. Each function defined in the "options" parameter of this constructor will receive the feature as a parameter, and will expect to get some object literal as output (in the return value). This allows you to either use the feature itself for feature-specific properties, or to refer to a global variable to retrieve certain properties.
The example in the class documentation uses a global style object literal for all feature, but uses feature-specific modifiers.
A symbology object, as created by the SymbologyProvider.
A set of optional parameters and functions to help you customize the visualization of military icons and symbols.
Set or get the density painting settings on this painter. Use null
to disable density painting.
colorMap
, the color map
used to map density values to color.
The density at a particular location is the sum of the value of alpha channel for all overlapping objects. So for
a single opaque object you would get a density value of 1.0, for 2 opaque objects 2.0, etc.
var painter = new FeaturePainter();
painter.paintBody = ... // customize painter as usual
painter.density = {
colorMap: ColorMap.createGradientColorMap([
{level: 0, color: "rgba( 0, 0, 0, 0.0)"}, // no objects -> Transparent
{level: 1, color: "rgba( 0, 255, 0, 0.5)"}, // 1 opaque object -> Transparent green
{level: 10, color: "rgba(255, 255, 255, 1.0)"} //10 opaque objects -> White
])
};
Notes when using density painting:
A method that generates an image for the given feature with the given size. The feature needs a symbology and code property const properties = { code: symbologyNode.code, symbology: symbology, } The feature also needs a valid (template) shape. (Use SymbologyNode.createTemplates)
You will get an image as HTMLImageElement.
This can be used to generate a UI preview image for your symbols as is done in our Symbology sample in the CreationPanel to clarify the creation instructions.
feature containing a shape and symbol properties
width and height of the preview
2022.0
A utility method to get the actual symbol bounds, that can then be used for fitting on that symbol.
The feature needs a symbology and code property
const properties = { code: symbologyNode.code, symbology: symbology, }
The feature also needs a valid (template) shape. (Use SymbologyNode.createTemplates)
The visualization of a military symbol might differ significantly of the polyline that contains the symbol's anchor points. In the most extreme case, two anchor points are used to draw a full circle. The bounds of the shape inside the feature will be the bounds of the two points, this method will return the bounds of the circle. Please note that only the actual shapes are taken into account to calculate the bounds, specific styling, labels and icons are not taken into account. Therefor it is probably a good idea to fit with a MapNavigatorFitOptions.fitMargin
the feature representing a military symbol
2024.0
Returns an array of map scales that determine when this painter should switch from one level-of-detail to the next.
This can be used to advertise that this painter supports multiple level-of-details for a given object. The current
level-of-detail that is used is determined by the map and is passed back to this FeaturePainter via the state.level
property that is passed to the paint methods.
The default implementation of this method returns null
indicating the level-of-detail is not supported.
Optional
layer: FeatureLayerthe layer for which the detail level scales are being requested
Optional
map: Mapthe map for which the detail level scales are being requested
the switch scales for each level of detail
A visual example of the relation between the scale switching points and the paint levels. The example uses 3 different switching scales, hence resulting with 4 paint levels.
// Scale: 1 : 100 000 1 : 10 000 1 : 1000
// (zoomed out) -------- | ----------------- | ----------------- | -------- (zoomed in)
// level 0 | level 1 | level 2 | level 3
getDetailLevelScales(): number[] {
return [1 / 100000, 1 / 10000, 1 / 1000];
}
Invalidates this painter for a specific feature. Call this method when any state that determines the rendering of
a specific feature has been changed. Calling this method refreshes this FeaturePainter
's
layer and guarantees that
() and
()
will be called for the given feature during the next map render.
the model feature whose representation has changed
Invalidates this painter for all objects. Call this method when any state that determines the rendering of
objects has been changed. Calling this method refreshes the FeaturePainter
's
layer and guarantees that
() and
() will be called for all objects in
the layer during the next map render.
Invalidates this painter for a specific object by id. Call this method when any state that determines the rendering of
a specific object has been changed. Calling this method refreshes this FeaturePainter
's
layer and guarantees that
() and
()
will be called for the given object during the next map render.
The id of the feature. It corresponds to Feature.id.
A method that paints military icons and tactical graphics on a map.
Override this method to add custom decorations on top of the military icons and tactical graphics. (Example: Painting flags next to icons, based on the country)
the render target
the feature that is being rendered
the shape to render
the layer containing the given feature
the map containing the layer
an object describing the current paint state
Optional
paintThe method to describe how a model object has to be visualized in bottom and left border of the vertical view map. The map must first be configured with axis.
Only the bottom border decorations are painted by default. The Left border decorations must be enabled explicitly on the layer using LEFT_BORDER_BODY paint representation.
This is an optional method.
the render target
the feature that is being rendered
the shape to render
the layer containing the given feature
the map containing the layer
an object describing the current paint state
Optional
paintThe method to describe how a model object has to be labeled on the bottom and left border of the vertical view map.
Only the bottom border labels are painted by default. The Left border labels must be enabled explicitly on the layer using LEFT_BORDER_LABEL paint representation.
This is an optional method.
the render target
the feature that is being rendered
the shape to render
the layer containing the given feature
the map containing the layer
an object describing the current paint state
A method that paints labels for military icons.
Override this method to customize labeling, or to add additional labels to existing military symbols (Example: Put the name of the country as a text label near the military icon)
You can modify the style of the labels by changing the CSS style of the label. This class is called
.luciad .lcdSymbologyLabel
See samples/symbology/common/ui/milsym-common-styles.css for an example usage of this selector.
.luciad .lcdSymbologyLabel {
font-family: Arial, monospace;
font-weight: normal;
color: white;
font-size: 10px;
text-shadow: 0 0 5px #000000;
}
You can also modify the style of the "glow" applied to the label when a bloomStyle is applied to the symbol.
The class to do so is called lcdSymbologyLabelGlow
text-shadow: 0 0 2px #000, 0 0 4px #fff,
0 0 5px #efefef, 0 0 6px #efefef,
0 0 7px #bbbbbb, 0 0 8px #bbbbbb, 0 0 9px #bbbbbb;
the render target
the feature that is being rendered
the shape to render
the layer containing the given feature
the map containing the layer
an object describing the current paint state
Registers a callback function for a given event type.
the event type to register on
the callback function to register
Rest
...args: any[]Optional
context: anythe context in which the callback function should be invoked implementation dependent.
a handle to the registered callback with a single function 'remove'. This function can be used to unregister the callback function.
FeaturePainter.on "Invalidate"
FeaturePainter.on "InvalidateAll"
FeaturePainter.on "InvalidateById"
Registers a callback function for the "SymbologyServiceOnline" event, that notifies a listener that the symbology service is online.
Always set to "SymbologyServiceOnline" for this event type.
The callback function to be executed when the event is emitted
Optional
context: anyThe context in which the function should be invoked.
"SymbologyServiceOnline"
2021.0
is no longer emitted since we no longer use a service for the icons
Registers a callback function for the "SymbologyServiceOffline" event, that notifies a listener that the symbology service is offline.
Always set to "SymbologyServiceOffline" for this event type.
The callback function to be executed when the event is emitted
Optional
context: anyThe context in which the function should be invoked.
"SymbologyServiceOffline"
2021.0
is no longer emitted since we no longer use a service for the icons
A painter for military icons and tactical graphics. This painter extends the FeaturePainter with functionality to visualize icons and symbols found in the MIL-STD 2525b, MIL-STD 2525c, , MIL-STD 2525d, APP-6A, APP-6B, APP-6C and APP-6D military standards.
Everything for this painter is configured at construction time, using functions that retrieve object literals for a given feature. This allows for flexibility for both feature-based properties, as well as global properties (that apply to all features).
Here's an overview of the keys for a few of the properties.
The following affiliation values can be colored with the affiliationColors map. Note that these values are not camel-case. This is because they are typically used as display values as well.
Movement direction arrows
This painter also paints movement direction arrows for moving symbols. Ground units will have an arrow starting from a vertical stem, except in 3D.
The following modifiers affect the arrows:
The length of the arrow is determined by the existing style property "iconSize" in combination with the "speedLabel" modifier if available. The line-width of the arrow is determined by the existing style properties "lineWidth".
Example how to create a military feature and a painter