Skip to content

StyleLayer

Namespace: ThinkGeo.Core.Styling

Building style layers in code instead of parsing them out of a style.json.

public abstract class StyleLayer

Inheritance object → StyleLayer

Remarks:

The JSON path compiles filters and zoom stops into the delegates a StyleLayer holds, so handing delegates in directly is not a second style engine - it is the same one, entered a step later. Anything a style expression can say, a lambda can say; the reverse is not true, since a lambda can read a field or call code no expression grammar has.

What a lambda gives up is being DATA: it cannot be downloaded, hot-swapped, handed to a cartographer, shared with the web build, or serialised back to a .json. It also cannot be analysed - the JSON compiler knows when a paint is zoom-only or when two layers share a step function, and batches accordingly, while a delegate must be assumed data-driven and re-evaluated per feature. So this is for the handful of layers an application draws over its own data, and style.json stays the way a basemap arrives.

A layer built here is handed to MapStyle.AddVectorTiles(IVectorTileSource, string, StyleLayerSlot, StyleLayer[]), which places it in the style's order and binds it to the source it adds: the layer names only its sourceLayer, the layer inside the tiles it draws.

The minZoom and maxZoom every factory takes are the map's zoom - an index into the MapView's ZoomScales ladder, the number MapView.CurrentZoom reports. A layer that carries its range as classic scale denominators converts them with MapUtil.GetZoom(scale, mapView.ZoomScales); see StyleLayer.MinZoom for what the ladder implies.

Properties

Id

public string Id { get; }

Property Value

string

LayerIndex

The layer's place in the style's order - lower draws first. Set when the style compiles: a layer from a Create* factory reads 0 until a style it is added to has compiled, and the compiled style's layers carry the order.

public int LayerIndex { get; }

Property Value

int

Type

public StyleLayerType Type { get; }

Property Value

StyleLayerType

SourceId

The name of the source the layer draws from. Empty for a layer from a Create* factory until the style it is added to compiles: MapStyle.AddVectorTiles(IVectorTileSource, string, StyleLayerSlot, StyleLayer[]) binds it.

public string SourceId { get; }

Property Value

string

SourceLayer

The layer inside the source's tiles the layer draws.

public string SourceLayer { get; }

Property Value

string

MinZoom

The zoom the layer starts drawing at (minzoom), or null for none. Zoom here is the map's own: the camera's zoom is MapUtil.GetZoom(scale, ZoomScales) over the MapView's ZoomScales ladder - the number MapView.CurrentZoom reports - so a classic scale denominator converts with that call and back with MapUtil.GetScale(zoom, ZoomScales), with no constant to guess. It is an index into that ladder. The default ladder of a metre-unit map, ThinkGeoCloudMapsZoomLevelSet, is the MapLibre one (512-pixel tiles, index 0 at 1:295,829,355), so a style document's minzoom means what it means in MapLibre; a 256-pixel ladder in ZoomScales shifts every zoom in this style by one.

public Nullable<double> MinZoom { get; }

Property Value

Nullable<double>

MaxZoom

The zoom the layer stops drawing at (maxzoom, exclusive), or null for none. See StyleLayer.MinZoom for the units.

public Nullable<double> MaxZoom { get; }

Property Value

Nullable<double>

Methods

A(Feature, double)

internal float A(Feature , double )

Parameters

`` Feature

`` double

Returns

float

a(int)

internal void a(int )

Parameters

`` int

Returns

void

IsVisibleAt(double)

public bool IsVisibleAt(double zoom)

Parameters

zoom double

Returns

bool

Matches(Feature, double)

public bool Matches(Feature feature, double zoom)

Parameters

feature Feature

zoom double

Returns

bool

A(double, Feature)

internal FillPaint A(double , Feature )

Parameters

`` double

`` Feature

Returns

FillPaint

a(double, Feature)

internal LinePaint a(double , Feature )

Parameters

`` double

`` Feature

Returns

LinePaint

B(double, Feature)

internal CirclePaint B(double , Feature )

Parameters

`` double

`` Feature

Returns

CirclePaint

b(double, Feature)

internal SymbolLayout b(double , Feature )

Parameters

`` double

`` Feature

Returns

SymbolLayout

C(double, Feature)

internal SymbolPaint C(double , Feature )

Parameters

`` double

`` Feature

Returns

SymbolPaint

A(Feature, double, Gj&)

internal bool A(Feature , double , Gj& )

Parameters

`` Feature

`` double

`Gj&`

Returns

bool

A(Feature)

internal void A(Feature )

Parameters

`` Feature

Returns

void

c(double, Feature)

internal FillExtrusionPaint c(double , Feature )

Parameters

`` double

`` Feature

Returns

FillExtrusionPaint

D(double, Feature)

internal HeatmapPaint D(double , Feature )

Parameters

`` double

`` Feature

Returns

HeatmapPaint

A(double)

internal HillshadePaint A(double )

Parameters

`` double

Returns

HillshadePaint

CreateFill(string, string, Func<Feature, double, FillPaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, bool, string)

Draws polygons from .

public static FillStyleLayer CreateFill(string id, string sourceLayer, Func<Feature, double, FillPaint> paint, Func<Feature, double, bool> filter, Nullable<double> minZoom, Nullable<double> maxZoom, bool antialias, string pattern)

Parameters

id string

sourceLayer string

paint Func<Feature, double, FillPaint>
Called per feature and zoom; this is where data-driven colour lives.

filter Func<Feature, double, bool>
Which features this layer draws. Null draws them all.

minZoom Nullable<double>

maxZoom Nullable<double>

antialias bool
The fill-antialias of the whole layer, read by every renderer. The that returns is not read here.

pattern string

        The fill-pattern: the name of an image registered with
        (or carried by the style's sprite), tiled across every polygon of the layer in
        place of the paint's colour - Images.Add("hatch", AreaStyle.CreateHatchStyle(...))
        is how a classic hatch gets here. One name for the whole layer, as the engine
        draws it: a pattern is a texture bound per layer, not chosen per feature, and
        a document layer has the same limit. A name nothing is registered under falls
        back to the paint's colour. Null for a plain fill.

Returns

FillStyleLayer

A(string, int, string, string, Func<Feature, double, FillPaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, bool, string)

internal static FillStyleLayer A(string , int , string , string , Func<Feature, double, FillPaint> , Func<Feature, double, bool> , Nullable<double> , Nullable<double> , bool , string )

Parameters

`` string

`` int

`` string

`` string

`` Func<Feature, double, FillPaint>

`` Func<Feature, double, bool>

`` Nullable<double>

`` Nullable<double>

`` bool

`` string

Returns

FillStyleLayer

CreateLine(string, string, Func<Feature, double, LinePaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, LineCap, LineJoin, double, double, string)

Draws lines from .

public static LineStyleLayer CreateLine(string id, string sourceLayer, Func<Feature, double, LinePaint> paint, Func<Feature, double, bool> filter, Nullable<double> minZoom, Nullable<double> maxZoom, LineCap cap, LineJoin join, double miterLimit, double roundLimit, string pattern)

Parameters

id string

sourceLayer string

paint Func<Feature, double, LinePaint>

filter Func<Feature, double, bool>

minZoom Nullable<double>

maxZoom Nullable<double>

cap LineCap

join LineJoin

miterLimit double

roundLimit double

pattern string

Returns

LineStyleLayer

A(string, int, string, string, Func<Feature, double, LinePaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, LineCap, LineJoin, double, double, string)

internal static LineStyleLayer A(string , int , string , string , Func<Feature, double, LinePaint> , Func<Feature, double, bool> , Nullable<double> , Nullable<double> , LineCap , LineJoin , double , double , string )

Parameters

`` string

`` int

`` string

`` string

`` Func<Feature, double, LinePaint>

`` Func<Feature, double, bool>

`` Nullable<double>

`` Nullable<double>

`` LineCap

`` LineJoin

`` double

`` double

`` string

Returns

LineStyleLayer

CreateCircle(string, string, Func<Feature, double, CirclePaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>)

Draws points from as circles.

public static CircleStyleLayer CreateCircle(string id, string sourceLayer, Func<Feature, double, CirclePaint> paint, Func<Feature, double, bool> filter, Nullable<double> minZoom, Nullable<double> maxZoom)

Parameters

id string

sourceLayer string

paint Func<Feature, double, CirclePaint>

        Called per feature and zoom, like the fill and line paints: a graduated-symbol map
        - dots sized by a magnitude, coloured by a category - is most of what a circle
        layer is for, and reading the feature here is how that is expressed. Radius and
        stroke width are in screen pixels.

filter Func<Feature, double, bool>

minZoom Nullable<double>

maxZoom Nullable<double>

Returns

CircleStyleLayer

A(string, int, string, string, Func<Feature, double, CirclePaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>)

internal static CircleStyleLayer A(string , int , string , string , Func<Feature, double, CirclePaint> , Func<Feature, double, bool> , Nullable<double> , Nullable<double> )

Parameters

`` string

`` int

`` string

`` string

`` Func<Feature, double, CirclePaint>

`` Func<Feature, double, bool>

`` Nullable<double>

`` Nullable<double>

Returns

CircleStyleLayer

CreateSymbol(string, string, Func<Feature, double, string>, Func<Feature, double, SymbolPaint>, Func<Feature, double, SymbolLayout>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, Func<Feature, double, float>, Func<Feature, double, string>)

Draws text labels, icons, or both for features from . The symbols join the same placement pass as the basemap's, so they collide with them rather than printing over the top.

public static SymbolStyleLayer CreateSymbol(string id, string sourceLayer, Func<Feature, double, string> text, Func<Feature, double, SymbolPaint> paint, Func<Feature, double, SymbolLayout> layout, Func<Feature, double, bool> filter, Nullable<double> minZoom, Nullable<double> maxZoom, Func<Feature, double, float> sortKey, Func<Feature, double, string> icon)

Parameters

id string

sourceLayer string

text Func<Feature, double, string>
The string to draw; return null or empty for no text.

paint Func<Feature, double, SymbolPaint>

layout Func<Feature, double, SymbolLayout>

filter Func<Feature, double, bool>

minZoom Nullable<double>

maxZoom Nullable<double>

sortKey Func<Feature, double, float>

icon Func<Feature, double, string>

        The icon-image: the name of an image registered with
        (or carried by the style's sprite), read per feature - a category column can
        pick the symbol. Return null or empty for no icon; a name nothing is registered
        under draws no icon either. Null leaves the layer text-only. A feature with
        neither text nor icon is skipped. The icon's anchor, offset and size come from
        , as for a document layer.

Returns

SymbolStyleLayer

A(string, int, string, string, Func<Feature, double, string>, Func<Feature, double, SymbolPaint>, Func<Feature, double, SymbolLayout>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, Func<Feature, double, float>, Func<Feature, double, string>)

internal static SymbolStyleLayer A(string , int , string , string , Func<Feature, double, string> , Func<Feature, double, SymbolPaint> , Func<Feature, double, SymbolLayout> , Func<Feature, double, bool> , Nullable<double> , Nullable<double> , Func<Feature, double, float> , Func<Feature, double, string> )

Parameters

`` string

`` int

`` string

`` string

`` Func<Feature, double, string>

`` Func<Feature, double, SymbolPaint>

`` Func<Feature, double, SymbolLayout>

`` Func<Feature, double, bool>

`` Nullable<double>

`` Nullable<double>

`` Func<Feature, double, float>

`` Func<Feature, double, string>

Returns

SymbolStyleLayer

CreateFillExtrusion(string, string, Func<Feature, double, FillExtrusionPaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, string)

Extrudes polygons from into 3D volumes.

public static FillExtrusionStyleLayer CreateFillExtrusion(string id, string sourceLayer, Func<Feature, double, FillExtrusionPaint> paint, Func<Feature, double, bool> filter, Nullable<double> minZoom, Nullable<double> maxZoom, string pattern)

Parameters

id string

sourceLayer string

paint Func<Feature, double, FillExtrusionPaint>

        Called per feature and zoom. Height and base are in METRES above the ground,
        not pixels - the camera foreshortens them like anything else in the world -
        so a building's own height column goes straight in.

filter Func<Feature, double, bool>

minZoom Nullable<double>

maxZoom Nullable<double>

pattern string

        The fill-extrusion-pattern: the name of an image registered with
         (or carried by the style's sprite), tiled over the
        walls and roofs in place of the paint's colour. One name for the whole layer, as
        with 's pattern; a name nothing is registered
        under falls back to the paint's colour. Null for solid volumes.

Returns

FillExtrusionStyleLayer

Remarks:

Extrusions draw in their own depth-tested pass, so which building hides which is settled by the depth buffer rather than by the layer order. The order still places the layer against the flat ones around it.

A(string, int, string, string, Func<Feature, double, FillExtrusionPaint>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>, string)

internal static FillExtrusionStyleLayer A(string , int , string , string , Func<Feature, double, FillExtrusionPaint> , Func<Feature, double, bool> , Nullable<double> , Nullable<double> , string )

Parameters

`` string

`` int

`` string

`` string

`` Func<Feature, double, FillExtrusionPaint>

`` Func<Feature, double, bool>

`` Nullable<double>

`` Nullable<double>

`` string

Returns

FillExtrusionStyleLayer

CreateHeatmap(string, string, Func<Feature, double, HeatmapPaint>, IReadOnlyList<ColorStop>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>)

Accumulates points from into a heatmap.

public static HeatmapStyleLayer CreateHeatmap(string id, string sourceLayer, Func<Feature, double, HeatmapPaint> paint, IReadOnlyList<ColorStop> colorStops, Func<Feature, double, bool> filter, Nullable<double> minZoom, Nullable<double> maxZoom)

Parameters

id string

sourceLayer string

paint Func<Feature, double, HeatmapPaint>

        Called per feature and zoom. Radius is in screen pixels; weight is what one
        point contributes to the density, which is where a magnitude column belongs.

colorStops IReadOnlyList<ColorStop>

        The colours the accumulated density is drawn through, as stops of density 0..1 -
        (0, transparent), (0.5, yellow), (1, red) - blended between stops and held
        beyond the first and the last; the stops
        takes. Null or empty takes the style spec's default ramp. Unlike the paint this
        is not per feature: the density is summed across points before any colour is
        chosen, so the ramp belongs to the layer.

filter Func<Feature, double, bool>

minZoom Nullable<double>

maxZoom Nullable<double>

Returns

HeatmapStyleLayer

A(string, int, string, string, Func<Feature, double, HeatmapPaint>, IReadOnlyList<ColorStop>, Func<Feature, double, bool>, Nullable<double>, Nullable<double>)

internal static HeatmapStyleLayer A(string , int , string , string , Func<Feature, double, HeatmapPaint> , IReadOnlyList<ColorStop> , Func<Feature, double, bool> , Nullable<double> , Nullable<double> )

Parameters

`` string

`` int

`` string

`` string

`` Func<Feature, double, HeatmapPaint>

`` IReadOnlyList<ColorStop>

`` Func<Feature, double, bool>

`` Nullable<double>

`` Nullable<double>

Returns

HeatmapStyleLayer

a(double)

internal RasterPaint a(double )

Parameters

`` double

Returns

RasterPaint