Creates a new ParameterizedPointPainter.
//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;
Optional
options: ParameterizedPointPainterConstructorOptionsAn object literal containing the ParameterizedPointPainter's parameters.
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 parameterattributes
.
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.
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:
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:
An expression to define icons.
To create expressions, you must use ExpressionFactory. The expression must be well-formed and resolve to an icon expression. Note that any attribute used in the expressions must be specified in the constructor parameterattributes
.
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.
The expression that determines the scale factor to apply to the icons.
1
corresponds to the original size of the icon.<1
will shrink the icon.>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 parameterattributes
.
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.
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 parameterattributes
.
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.
An expression to define selected icons.
To create expressions, you must use ExpressionFactory. The expression must be well-formed and resolve to an icon expression. Note that any attribute used in the expressions must be specified in the constructor parameterattributes
.
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.
The expression that determines the scale factor to apply to the selected icons.
1
corresponds to the original size of the icon.<1
will shrink the icon.>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 parameterattributes
.
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.
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 parameterattributes
.
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 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
FeaturePainter.paintBody and
FeaturePainter.paintLabel
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
FeaturePainter.paintBody and
FeaturePainter.paintLabel will be called for all objects in
the layer during the next map render.
Note that this is called automatically whenever Map.displayScale changes.
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
FeaturePainter.paintBody and
FeaturePainter.paintLabel
will be called for the given object during the next map render.
The id of the feature. It corresponds to Feature.id.
Do not override this (as with a FeaturePainter). All parameterized point styling is configured by setting ParameterizedPointPainter's properties.
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
Optional
paintThe 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:
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 the "InvalidateAll" event, that notifies a listener that the all features are invalidated.
Always set to "InvalidateAll" 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.
"InvalidateAll"
Registers a callback function for the "Invalidate" event, that notifies a listener that a given feature is invalidated.
Always set to "Invalidate" 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.
"Invalidate"
Registers a callback function for the "InvalidateById" event, that notifies a listener that a feature with the given id is invalidated.
Always set to "InvalidateById" 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.
"InvalidateById"
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: