ParameterizedPointPainter allows you to visualize point data sets.

This painter uses the graphics hardware to efficiently switch styling and filtering.

Note that this painter does not allow overriding of paintBody, unlike the usual FeaturePainter. All styling is configured by setting the properties on this painter. This painter can also be combined with regular density painting. Note that in this case, the alpha value of the final color is used as a weight in the density. The color itself is discarded.

This painter supports labels, which take the visibility expression into account. To do so, implement FeaturePainters. However, the labels are evaluated and drawn using the normal cpu-based algorithms.

Limitations:

  • Only numeric attributes are supported.
  • This painter can only be used on a WebGLMap.
  • Any labels are evaluated and drawn using the normal cpu-based algorithms.
  • This painter does not support models that have a above terrain height reference. If you use this painter for such a model, the painter will throw an exception the first time it needs to paint.

Hierarchy (View Summary)

Constructors

  • Creates a new ParameterizedPointPainter.

    Examples

    Specifying filtering and styling based on feature properties

    You can specify expressions to determine the color, icon, scale or visibility of a point. These expressions can be based on feature properties.
    //Create a painter.
    //Use a green color for regular points.
    //Filter points based on the "speed" attribute. Only show points if their "speed" is greater than 200.
    //The 200 value is the current value of a parameter.
    //Parameters can be updated very efficiently so the threshold can be updated later on very quickly.
    //Specify that we will (at some point) use attributes "speed" and "calculated".
    //The values of the "speed" attribute will correspond to the "velocity" feature property,
    //i.e. to feature.properties["velocity"];
    //The values for the "calculated" attribute will be the values returned by the given function.
    var _ = ExpressionFactory;
    var speedThreshold = _.numberParameter(200);
    var parameterizedPointPainter = new ParameterizedPointPainter({
    regular: {
    colorExpression: color("rgb(0, 255, 0, 1)")
    },
    visibilityExpression: _.gt(_.attribute("speed"), speedThreshold),
    attributes: {
    speed: "velocity",
    calculated: function(feature, shape) {
    //calculate the attribute value here.
    return ...;
    }
    }
    });

    //At runtime, immediately change styling and filtering.
    parameterizedPointPainter.colorExpression = color("rgb(255, 0, 0, 1)");
    parameterizedPointPainter.visibilityExpression = boolean(false);
    //If you want to update the styling very often, e.g. based on a slider, consider using parameters in your expressions.
    //Changing the values of parameters is more efficient than changing expressions.
    //So, for example, updating the speed threshold:
    speedThreshold.value = 300;

    Parameters

    Returns ParameterizedPointPainter

Accessors

  • get colorExpression(): Expression<string>

    An expression to specify what colors to apply to points.

    To create expressions, you must use ExpressionFactory. The expression must be well-formed and resolve to a color.

    Note that any attribute used in the expressions must be specified in the constructor parameter attributes.

    If you want to update the styling very often, consider using parameters in your expressions. Changing the values of parameters is more efficient than changing expressions.

    Returns Expression<string>

    <code>rgb(255, 255, 255)</code> (Opaque white)
    
  • set colorExpression(colorExpression: Expression<string>): void

    Parameters

    Returns void

  • get density(): null | DensitySettings

    Set or get the density painting settings on this painter. Use null to disable density painting.

    The setting affects all features in the layer associated with this painter.

    The density settings object has one property: 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.
    Example:

      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:

    • Density painting works for all kinds of objects: points/icons, lines and areas.
    • The color aspect of the styling provided in paintBody is ignored. The alpha value of the color is used as a per-feature weight.
    • If you paint icons, you can leave out the icon image. You will automatically get a gradient icon. You can still adapt the size with the width and height style properties.

    This property is only supported on a WebGLMap, and is ignored otherwise.

    Returns null | DensitySettings

  • set density(densityMap: null | DensitySettings): void

    Set or get the density painting settings on this painter. Use null to disable density painting.

    The setting affects all features in the layer associated with this painter.

    The density settings object has one property: 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.
    Example:

      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:

    • Density painting works for all kinds of objects: points/icons, lines and areas.
    • The color aspect of the styling provided in paintBody is ignored. The alpha value of the color is used as a per-feature weight.
    • If you paint icons, you can leave out the icon image. You will automatically get a gradient icon. You can still adapt the size with the width and height style properties.

    This property is only supported on a WebGLMap, and is ignored otherwise.

    Parameters

    Returns void

  • get scaleExpression(): Expression<number>

    The expression that determines the scale factor to apply to the icons.

    • Scale 1 corresponds to the original size of the icon.
    • Scale <1 will shrink the icon.
    • Scale >1 will enlarge the icon.

    If not set, icons are never re-scaled.

    To create expressions, you must use ExpressionFactory. The expression must be well-formed and resolve to a number.

    Note that any attribute used in the expressions must be specified in the constructor parameter attributes.

    If you want to update the styling very often, consider using parameters in your expressions. Changing the values of parameters is more efficient than changing expressions.

    Returns Expression<number>

    1
    
  • set scaleExpression(scaleExpression: Expression<number>): void

    Parameters

    Returns void

  • get selectedColorExpression(): Expression<string>

    An expression to specify what colors to apply to selected points.

    To create expressions, you must use ExpressionFactory. The expression must be well-formed and resolve to a color.

    Note that any attribute used in the expressions must be specified in the constructor parameter attributes.

    If you want to update the styling very often, consider using parameters in your expressions. Changing the values of parameters is more efficient than changing expressions.

    Returns Expression<string>

    <code>rgb(0, 0, 255)</code> (Opaque blue)
    
  • set selectedColorExpression(selectedColorExpression: Expression<string>): void

    Parameters

    Returns void

  • get selectedScaleExpression(): Expression<number>

    The expression that determines the scale factor to apply to the selected icons.

    • Scale 1 corresponds to the original size of the icon.
    • Scale <1 will shrink the icon.
    • Scale >1 will enlarge the icon.

    If not set, icons are never re-scaled.

    To create expressions, you must use ExpressionFactory. The expression must be well-formed and resolve to a number.

    Note that any attribute used in the expressions must be specified in the constructor parameter attributes.

    If you want to update the styling very often, consider using parameters in your expressions. Changing the values of parameters is more efficient than changing expressions.

    Returns Expression<number>

    1
    
  • set selectedScaleExpression(scaleExpression: Expression<number>): void

    Parameters

    Returns void

  • get visibilityExpression(): Expression<boolean>

    An expression to filter points.

    To create expressions, you must use ExpressionFactory. The expression must be well-formed and resolve to a boolean.

    Note that any attribute used in the expressions must be specified in the constructor parameter attributes.

    If you want to update the styling very often, consider using parameters in your expressions. Changing the values of parameters is more efficient than changing expressions.

    Returns Expression<boolean>

    true
    
  • set visibilityExpression(visibilityExpression: Expression<boolean>): void

    Parameters

    Returns void

Methods

  • Returns an array of map scales that define when to switch between levels of detail.

    This method allows the painter to support multiple visual representations (levels-of-detail, or LOD) for the same feature depending on the map's current scale. The map determines the active level and passes it to the painter via the paintState.level property during rendering. If the level changes due to map navigation (such as zooming, panning, or fitting), the map will call the paintBody and paintLabel methods with the corresponding level.

    By default, this method returns null, indicating that level-of-detail is not used. Override this method to enable scale-based LOD behavior.

    Parameters

    • Optionallayer: FeatureLayer

      The feature layer for which level-of-detail scales are requested.

    • Optionalmap: Map

      The map instance for which the scales apply.

    Returns null | number[]

    An array of scales at which to switch to the next detail level, or null if LOD is not used.

      // The example below illustrates how switching scales map to paint levels.
    // It uses 3 switching points, resulting in 4 distinct paint levels:
    //
    // Scale: 1 : 100 000 1 : 10 000 1 : 1000
    // (zoomed out) --- | ------------- | ------------- | --- (zoomed in)
    // level 0 | level 1 | level 2 | level 3

    painter.getDetailLevelScales = (): number[] => {
    return [ 1 / 100_000, 1 / 10_000, 1 / 1_000 ];
    }
  • Invalidates this painter for a specific feature. Call this method when any state that affects the rendering of the given feature has changed. This method refreshes the associated layer and ensures that FeaturePainter.paintBody and FeaturePainter.paintLabel will be called for the specified feature during the next map render.

    Note: If the layer is currently invisible, the invalidation is deferred and will be applied when the layer becomes visible again.

    Parameters

    • feature: Feature

      the model feature whose representation has changed

    Returns void

  • Invalidates this painter for all features. Call this method when any state that affects the rendering of features has changed. This method refreshes the associated layer and ensures that FeaturePainter.paintBody and FeaturePainter.paintLabel will be called for all features in the layer during the next map render.

    Note: If the layer is currently invisible, the invalidation is deferred and will be applied when the layer becomes visible again.

    Note that this is called automatically whenever Map.displayScale changes.

    Returns void

  • Invalidates this painter for a specific feature identified by its id. Call this method when any state that affects the rendering of the given feature has changed. This method refreshes the associated layer and ensures that FeaturePainter.paintBody and FeaturePainter.paintLabel will be called for the specified feature during the next map render.

    Note: If the layer is currently invisible, the invalidation is deferred and will be applied when the layer becomes visible again.

    Parameters

    Returns void

  • The 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.

    Parameters

    • borderGeoCanvas: BorderGeoCanvas

      the render target

    • feature: Feature

      the feature that is being rendered

    • shape: Shape

      the shape to render

    • layer: Layer

      the layer containing the given feature

    • map: Map

      the map containing the layer

    • paintState: BorderPaintState

      an object describing the current paint state

    Returns void

  • The 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.

    Parameters

    • borderLabelCanvas: BorderLabelCanvas

      the render target

    • feature: Feature

      the feature that is being rendered

    • shape: Shape

      the shape to render

    • layer: Layer

      the layer containing the given feature

    • map: Map

      the map containing the layer

    • paintState: BorderPaintState

      an object describing the current paint state

    Returns void

  • Renders a label for a model object on the map.

    This method is invoked by the map for each (feature, paintState) combination. The result is cached by the system, so the method is called only once per combination unless explicitly invalidated.

    To invalidate a cached result, call one of the invalidate methods on the painter instance.

    Rendering can vary depending on the paintState, which includes

    • selected: a boolean value indicating whether the feature is currently selected.
    • hovered: a boolean value indicating whether the feature is currently hovered over
    • level: the current level of detail, where `0` is the least detailed

    Note: This method is not implemented by default. If label rendering is required, you must provide a custom implementation.

    Parameters

    • labelCanvas: LabelCanvas

      the render target

    • feature: Feature

      the feature that is being rendered

    • shape: Shape

      the shape to render

    • layer: Layer

      the layer containing the given feature

    • map: Map

      the map containing the layer

    • paintState: PaintState

      an object describing the current paint state

    Returns void

Events

  • Registers a callback function for the "InvalidateAll" event, that notifies a listener that the all features are invalidated.

    Parameters

    • event: "InvalidateAll"

      Always set to "InvalidateAll" for this event type.

    • callback: () => void

      The callback function to be executed when the event is emitted

    • Optionalcontext: any

      The context in which the function should be invoked.

      "InvalidateAll"

    Returns Handle

    2020.1

  • Registers a callback function for the "Invalidate" event, that notifies a listener that a given feature is invalidated.

    Parameters

    • event: "Invalidate"

      Always set to "Invalidate" for this event type.

    • callback: (feature: Feature) => void

      The callback function to be executed when the event is emitted

    • Optionalcontext: any

      The context in which the function should be invoked.

      "Invalidate"

    Returns Handle

    2020.1

  • Registers a callback function for the "InvalidateById" event, that notifies a listener that a feature with the given id is invalidated.

    Parameters

    • event: "InvalidateById"

      Always set to "InvalidateById" for this event type.

    • callback: (id: FeatureId) => void

      The callback function to be executed when the event is emitted

    • Optionalcontext: any

      The context in which the function should be invoked.

      "InvalidateById"

    Returns Handle

    2020.1