An object that determines how features are visualized in a FeatureLayer.

Hierarchy (view full)

Implements

Constructors

  • Note that this is a constructor function to create a blueprint for a new custom painter. Calling this function with "new" yields a new object that can be used as a prototype for a custom painter. You will need to reassign the paintBody method since its default implementation only throws an error. This object does not have a paintLabel method as it is optional.

      const featurePainter = new FeaturePainter();
    //Use a custom paintBody implementation
    featurePainter.paintBody = function(geoCanvas, feature, shape, layer, map, paintState) {
    geoCanvas.drawShape(shape, {
    stroke: {
    color: "rgb(0,0,255)",
    width: 5
    },
    fill: {color: "rgba(0,0,255,0.5)"}
    });
    };
    // Subclassing FeaturePainter
    function CustomPainter(){
    }
    CustomPainter.prototype = new FeaturePainter();
    CustomPainter.prototype.paintBody = function(geocanvas, feature, shape, layer, map, paintState){
    //custom paint implementation goes here.
    };

    const painterInstance = new CustomPainter();

    To create a simple painter with default functionality, consider using a BasicFeaturePainter.

    Returns FeaturePainter

Accessors

  • 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(value): void
  • Parameters

    Returns void

Methods

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

    Parameters

    • Optional layer: FeatureLayer

      the layer for which the detail level scales are being requested

    • Optional map: Map

      the map for which the detail level scales are being requested

    Returns null | number[]

    the switch scales for each level of detail

    See

    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.

    Parameters

    Returns void

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

    Returns void

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

    Parameters

    Returns void

  • The method which allows you to describe how a model object has to be visualized on the map.

    The paintBody method will be invoked by the map once for every (feature,paintState) tuple. The results of the paint method may be cached which will result in the paint method being called only once. If the results of a paint method become invalid, implementation must invoke one of the invalidate methods on themselves.

    paintBody method is allowed to render differently depending on the values of the paintState parameter. Currently the following state is supported:

    • selected: a boolean indicating if the object is being rendered in selected mode or in default mode.
    • level: a non-negative integer value indicating the current level-of-detail; zero being the least detailed level.

    Parameters

    • geoCanvas: GeoCanvas

      the render target

    • feature: Feature<null | Shape, FeatureProperties>

      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

  • 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

    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

    Returns void

  • The method which allows you to describe how a model object should be labeled on the map.

    The paintLabel method will be invoked by the map once for every (feature,paintState) tuple. The results of the paint method may be cached which will result in the paint method being called only once. If the results of a paint method become invalid, implementation must invoke one of the invalidate methods on themselves.

    paintLabel method is allowed to render differently depending on the values of the paintState parameter. Currently the following state is supported:

    • selected: a boolean indicating if the object is being rendered in selected mode or in default mode.
    • level: a non-negative integer value indicating the current level-of-detail; zero being the least detailed level.

    Parameters

    Returns void

Events

"InvalidateAll" event

  • on("InvalidateAll", callback: (() => void), context?: any) : Handle
  • 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

        • (): void
        • Returns void

    • Optional context: any

      The context in which the function should be invoked.

      "InvalidateAll"

    Returns Handle

    Since

    2020.1

"Invalidate" event

  • on("Invalidate", callback: ((feature) => void), context?: any) : Handle
  • 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) => void)

      The callback function to be executed when the event is emitted

    • Optional context: any

      The context in which the function should be invoked.

      "Invalidate"

    Returns Handle

    Since

    2020.1

"InvalidateById" event

  • on("InvalidateById", callback: ((id) => void), context?: any) : Handle
  • 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) => void)

      The callback function to be executed when the event is emitted

        • (id): void
        • Parameters

          Returns void

    • Optional context: any

      The context in which the function should be invoked.

      "InvalidateById"

    Returns Handle

    Since

    2020.1