Creates a new ParameterizedLinePainter.
null
color to hide features.
// Create a painter, specify that we will filter on "airline" and "destination"
const linePainter = new ParameterizedLinePainter({
properties: ["airline", "destination"],
defaultColor: "rgb(255, 255, 255)"
});
// At runtime, immediately change styling and filtering
linePainter.propertyColorExpressions = [
{property: "destination", value: "Brussels", color: "rgb(255, 0, 0")}, // Destination Brussels = red
{property: "destination", value: "London", color: "rgb(0, 255, 0")} // Destination London = green
];
linePainter.defaultColor = null; // Hide all the rest
// At runtime, immediately change styling and filtering
linePainter.propertyColorExpressions = [
{property: "airline", value: "Brussels Airlines", color: "rgb(255, 0, 0")}, // Brussels Airlines = red
];
linePainter.defaultColor = "rgb(0, 0, 255)"; // All the rest = blue
// Create a painter, specify a provider that can calculate a value per point of a line
const linePainter = new ParameterizedLinePainter({
lineWidth: 2,
rangePropertyProvider: function(feature, shape, pointIndex) {
return feature.properties.fuelconsumptions[pointIndex];
},
rangeColorMap: ColorMap.createGradientColorMap([
{level: 0, color: "rgba(0, 0, 255, 0.0)"}, // 0..100: blue
{level: 100, color: "rgba(0, 0, 255, 1)"}, // 100..500: blue to green
{level: 500, color: "rgba(0, 255, 0, 1)"}, // 500..1000: green to red
{level: 1000, color: "rgba(255, 0, 0, 1)"}]), // 1000+: red
rangeWindow: [0, 5000]
});
// Update the painter when the user updates the min/max fuel consumption window in the UI (e.g. on slider drag)
fuelConsumptionSlider.onChange(function(min, max) {
linePainter.rangeWindow = [min, max];
});
An object literal containing the ParameterizedLinePainter's parameters.
The default line color, represented as a CSS color string. If no color can be determined using the propertyColorExpressions, this color is used.
<code>rgb(0, 0, 255)</code> (Opaque blue)
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 array of objects describing a mapping of property values to colors. The mapping can be read as: if property x equals value y, use color z. Else if property p equals value v use color c.... When multiple entries result in a color for an object, the first entry of the possible entries in the array will be used.
<code>[]</code>
The ColorMap that for each pixel in a line maps its range value to a color.
This allows you to change the color along the line based on a varying property, such a fuel consumption. The resulting color is a modulation color: it is "multiplied" with the defaultColor, or color based on the propertyColorExpressions. Typically, either the normal color is white and the range color is not, or vice-versa:<code>null</code>
The start / end values for the window of the range property filter.
Parts of a line whose range values are outside this range window are not painted. This must be an array with two values. The end value should be larger than the start value.<code>[0, Number.MAX_VALUE]</code>
The color to paint selected lines with, represented as a CSS color string. For selected objects, selectionColor overrides the color determined by the propertyColorExpressions.
<code>rgb(255, 0, 0)</code> (Opaque red)
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.
Do not override this method.
Optional
paintNot applicable for ParameterizedLinePainter
Optional
paintNot applicable for ParameterizedLinePainter
Optional
paintNot applicable for ParameterizedLinePainter
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"
2020.1
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"
2020.1
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"
2020.1
A ParameterizedLinePainter allows you to visualize line datasets with dynamic styling and filtering, as well as per-pixel styling.
This painter uses the graphics hardware to efficiently switch styling and filtering.Highlights
Limitations: