Skip to content

MapStyle

Namespace: ThinkGeo.Core.Styling

A map style as a document: the sources, the layers in the order they draw, the sprite and glyphs they name, the sky, light and terrain - composed in code, from style JSON text, or from a style's address, and read back as one style JSON document.

public sealed class MapStyle

Inheritance object → MapStyle

Remarks:

This is the style the way every renderer of the style specification reads it: MapLibre in a browser, the GPU renderer on the desktop, the vector tile drawer on a server. What they each do with it is theirs; this holds only the document, and the document is the one thing they share. A source here is a name and what the document says about it - a tile address, a type; which tiles actually answer to that name is for the renderer that binds it.

Composition is by layer order. Each piece added goes on top of what is there, at StyleLayerSlot.Top, unless a slot says otherwise; a style document added by address is fetched when the document is resolved, and keeps the place it was given until then.

The Add methods follow two rules. What the data is: AddKind(source object, …) registers a source and adds the layer that draws it - MapStyle.AddRaster(RasterTileSource, Nullable<RasterPaint>, string, StyleLayerSlot), MapStyle.AddHillshade(RasterDemSource, Nullable<HillshadePaint>, StyleLayerSlot), MapStyle.AddImage(GeoImage, RectangleShape, Projection, Nullable<RasterPaint>, string, StyleLayerSlot), MapStyle.AddVectorTiles(IVectorTileSource, string, StyleLayerSlot, StyleLayer[]), MapStyle.AddFeatureLayer(FeatureLayerTranslation, StyleLayerSlot) - while AddKindLayer(id, sourceId, …) adds one more layer over a source the document already has - MapStyle.AddRasterLayer(string, string, Nullable<RasterPaint>, StyleLayerSlot), MapStyle.AddHillshadeLayer(string, string, Nullable<HillshadePaint>, StyleLayerSlot), MapStyle.AddFillLayer(string, string, string, FillPaint, string, JsonNode, Nullable<double>, Nullable<double>, StyleLayerSlot) and the other typed layers. How the style is said: a JSON node or a typed layer method writes a document layer, which carries and a browser can draw; a StyleLayer factory writes a code layer, whose paint is a delegate that can read a feature but cannot leave the process. MapStyle.AddStyle(string, IVectorTileSource, StyleLayerType[]) merges a whole document; MapStyle.AddLayer(JsonObject, StyleLayerSlot) and MapStyle.AddSource(string, JsonObject) take raw JSON for what no typed method covers. Every Add of a layer takes a StyleLayerSlot for where in the stack it goes; on top when it is left out.

The data overlays are the exception to tiles. MapStyle.AddVectorField(VectorFieldSource, VectorFieldStyle) and MapStyle.AddParticleFlow(VectorFieldSource, ParticleFlowStyle) here, and AddDynamic, AddGridFill and AddIsolines - extension methods in ThinkGeo.Gpu, since only the GPU map draws what they add - take an in-memory source (VectorFieldSource, GridSource, ThinkGeo.Gpu's DynamicSource and PointValueSource) whose whole snapshot goes to the GPU as it is - nothing is cut into tiles, and a change to the source is on screen the next frame. They suit data that is small and alive: vehicles, a sketch, a live field. They are not layers of the stack, so they take no slot: they draw over the style's layers and under its labels, in the order they were added - a dynamic source's own labels excepted, which draw over everything. Each has a Remove of its own; a tiled layer is removed by id with MapStyle.RemoveLayer(string).

Properties

IsCompiled

Whether the style has been compiled - by a map that draws it, or by MapStyle.OpenAsync(CancellationToken) - so that MapStyle.StyleLayers can be read. A style composed and not yet given to anything has not been. Compiling is not only parsing: the sprite sheet is fetched, raster and elevation sources named by address are resolved, and every paint expression becomes a delegate - which is why it is asynchronous while MapStyle.StyleLayers is not.

public bool IsCompiled { get; }

Property Value

bool

VectorTileSources

The vector tile sources this style was composed with, by the name its layers give as "source": the ones handed to MapStyle.AddStyle(string, IVectorTileSource, StyleLayerType[]) and AddVectorTiles, and the ones a feature layer is cut into. A source the document names by address alone - a TileJSON URL - is not here; it is the document's, and whoever draws the style reads it from there. A source handed in with a document fetched by address appears once that document has been read.

public IReadOnlyDictionary<string, IVectorTileSource> VectorTileSources { get; }

Property Value

IReadOnlyDictionary<string, IVectorTileSource>

StyleLayers

Every style layer this document compiled to, in no particular order across sources but in document order within one. Background and sky are not style layers and are not here. The GPU renderer never needs this - it asks per source-layer as it builds each tile - but a consumer projecting the whole document at once does, and so does anything looking a layer up by id. It is empty until the style is compiled; MapStyle.IsCompiled says whether it has been, and MapStyle.OpenAsync(CancellationToken) compiles it.

public IEnumerable<StyleLayer> StyleLayers { get; }

Property Value

IEnumerable<StyleLayer>

DataOverlays

The data-overlay registrations, in the order they were added - which is the order they stack. A renderer reads them; an application has no reason to.

public IReadOnlyList<DataOverlayRegistration> DataOverlays { get; }

Property Value

IReadOnlyList<DataOverlayRegistration>

ParticleFlows

The particle flows this style carries, in the order they were added. A renderer asks for these to draw them; an application that only ever calls MapStyle.AddParticleFlow(VectorFieldSource, ParticleFlowStyle) has no reason to.

public IEnumerable<ValueTuple<VectorFieldSource, ParticleFlowStyle>> ParticleFlows { get; }

Property Value

IEnumerable<ValueTuple<VectorFieldSource, ParticleFlowStyle>>

VectorFields

The vector fields this style draws as arrows.

public IEnumerable<ValueTuple<VectorFieldSource, VectorFieldStyle>> VectorFields { get; }

Property Value

IEnumerable<ValueTuple<VectorFieldSource, VectorFieldStyle>>

StyleUri

Gets the address the first style added by address came from, which relative addresses inside it - the sprite, the glyphs - are resolved against. Null when every piece came in as text or code.

public string StyleUri { get; private set; }

Property Value

string

Glyphs

Gets the glyphs address template the document names, or null when it names none. A style that names one draws its text as SDF glyphs from that server, letter shapes and widths alike; a style that names none draws its text from local fonts.

public string Glyphs { get; }

Property Value

string

Sprite

Gets the sprite address the document names, or null when it names none.

public string Sprite { get; }

Property Value

string

Images

Gets the images the document carries by name, drawn from code rather than fetched from a sprite: a symbol's picture, a fill's pattern.

public StyleImages Images { get; }

Property Value

StyleImages

Constructors

MapStyle()

An empty style - the from-scratch start of a pure-code one. Fill it with and the StyleLayer Create* factories. A style built this way declares no sources, so the map it is handed to needs its tile sources supplied explicitly.

public MapStyle()

MapStyle(string, IVectorTileSource)

A style from one document - inline JSON or a URL - optionally bound to the tile source that serves its data. The one-call form of ; compose more documents, rasters or code layers on top with the Add* methods.

public MapStyle(string styleJsonOrUri, IVectorTileSource source)

Parameters

styleJsonOrUri string

source IVectorTileSource

Methods

A(string, GeoImage, float, GP)

internal void A(string , GeoImage , float , GP stretch)

Parameters

`` string

`` GeoImage

`` float

stretch GP

Returns

void

SetFeatureState(string, string, string)

Sets one piece of state on one feature - MapLibre's setFeatureState. A paint reads it back with ["feature-state", "<key>"], so a style can paint the selected room differently without the selection being in the data.

public MapStyle SetFeatureState(string featureId, string key, string value)

Parameters

featureId string
The feature's id, as the data gives it.

key string
The state's name, e.g. "selected".

value string
Its value; null removes it.

Returns

MapStyle

Remarks:

State is not data, so nothing is refetched - but the paint of the features that read it has to be resolved again, which the map does by restyling from the tiles it already holds. That is cheap enough for a click; it is not a per-frame channel.

ClearFeatureState(string)

Drops the state of one feature, or of every feature when given null.

public MapStyle ClearFeatureState(string featureId)

Parameters

featureId string

Returns

MapStyle

a(string)

internal Dictionary<string, string> a(string )

Parameters

`` string

Returns

Dictionary<string, string>

SetFillExtrusionOffset(string, double)

Moves one fill-extrusion layer up or down at runtime, without touching its base, its height or its tiles. Like the other runtime knobs this is a style property, so it lives here; an attached map applies it live.

public MapStyle SetFillExtrusionOffset(string layerId, double metersAboveGround)

Parameters

layerId string
The fill-extrusion layer's id in the style.

metersAboveGround double
How far to lift it. Negative lowers it; 0 puts it back.

Returns

MapStyle

Remarks:

The style spec has no such property - a fill-extrusion sits where its fill-extrusion-base puts it - and moving it through the base would re-tessellate every tile the layer appears in, because base and height are baked into the vertices. This shifts the drawn geometry instead, which is cheap enough to drive from a slider: an exploded floor plan, a layer lifted clear of the one beneath it.

SetFillExtrusionOffset(string, double, double)

Lifts a fill-extrusion layer's base and top by different distances, so the extrusion stretches (or shrinks) between them at draw time.

public MapStyle SetFillExtrusionOffset(string layerId, double baseMetersAboveGround, double topMetersAboveGround)

Parameters

layerId string
The fill-extrusion layer's id in the style.

baseMetersAboveGround double
How far to lift the base. Negative lowers it; 0 puts it back.

topMetersAboveGround double
How far to lift the top.

Returns

MapStyle

Remarks:

What an exploded view needs for the things that join two layers: a via lifted with the metal under it at its base and with the metal over it at its top still connects the two after they are pulled apart. Equal distances are the rigid move of MapStyle.SetFillExtrusionOffset(string, double).

RemoveLayer(string)

Shows or hides a layer of the document by id.

public MapStyle RemoveLayer(string layerId)

Parameters

layerId string
The layer's id in the style.

Returns

MapStyle

Remarks:

A runtime state, like feature state: the layer stays in the compiled style and the renderer skips it by index, so neither hiding nor showing recompiles, and a compile that happens for another reason - a feature-state change, a new light - keeps the layer hidden. It used to be written into the document's layout as visibility: none, which the next compile honoured by leaving the layer OUT; the hidden set then had nothing to hide, and the tiles built before that compile drew the layer again. still writes a hidden layer as hidden. Showing a layer the DOCUMENT itself hides does need a compile, and asks for it.

MoveLayer(string, string)

Moves a layer to just under another - MapLibre's moveLayer - or to the top. This is how a layer goes to an exact place in the stack, by the layers around it rather than by a position that shifts as layers come and go: add it, then move it under the basemap's "road-label". Anything made from the style is made again.

public MapStyle MoveLayer(string layerId, string beforeLayerId)

Parameters

layerId string
The layer to move: a document layer, or a layer built in code, by the id it was given.

beforeLayerId string
The layer it goes under, or null for the top of the stack.

Returns

MapStyle

Exceptions

ArgumentException
The style has no layer with one of the ids.

Remarks:

The layers of a style added by address are there once it is resolved; until then a layer can only be moved relative to the ones already in the document.

SetLayerVisibility(string, bool)

public MapStyle SetLayerVisibility(string layerId, bool visible)

Parameters

layerId string

visible bool

Returns

MapStyle

E()

internal IEnumerable<int> E()

Returns

IEnumerable<int>

SetHeatmapPaint(string, Nullable<float>, Nullable<float>, Nullable<float>, IReadOnlyList<ColorStop>)

Changes a heatmap layer's paint at runtime: any of the radius, the intensity, the opacity and the colour ramp, leaving the rest as they are. Nothing is recompiled; the renderer takes the change on its next frame.

public MapStyle SetHeatmapPaint(string layerId, Nullable<float> radius, Nullable<float> intensity, Nullable<float> opacity, IReadOnlyList<ColorStop> colorStops)

Parameters

layerId string

radius Nullable<float>

intensity Nullable<float>

opacity Nullable<float>

colorStops IReadOnlyList<ColorStop>

Returns

MapStyle

Remarks:

The style keeps what it is told: called before the style is on a map, or followed by a recompile, the paint still holds. A layer removed from the style forgets it, so a layer added again under the id draws its own paint.

e()

internal IEnumerable<ValueTuple<int, HeatmapPaintChangedEventArgs>> e()

Returns

IEnumerable<ValueTuple<int, HeatmapPaintChangedEventArgs>>

f()

internal bool f()

Returns

bool

AddRaster(RasterTileSource, Nullable<RasterPaint>, string, StyleLayerSlot)

Adds raster tiles on top - imagery, any tiles that are pictures - and the layer that draws them. MapStyle.AddImage(GeoImage, RectangleShape, Projection, Nullable<RasterPaint>, string, StyleLayerSlot) is the one-picture form; MapStyle.AddRasterLayer(string, string, Nullable<RasterPaint>, StyleLayerSlot) adds one more layer over tiles the document already has.

public MapStyle AddRaster(RasterTileSource source, Nullable<RasterPaint> paint, string sourceId, StyleLayerSlot slot)

Parameters

source RasterTileSource
The tiles.

paint Nullable<RasterPaint>
How the tiles are drawn: opacity, fade, resampling, the colour adjustments. Null is the specification's defaults - opaque, a 300 ms fade.

sourceId string
The name the tiles go under, or null for one made up.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle

AddStyle(string, IVectorTileSource, StyleLayerType[])

Appends every layer of a style, in the style's own order, untouched. This is how a basemap goes in: the cartography is the author's, and nothing here reorders it.

public MapStyle AddStyle(string styleJsonOrUri, IVectorTileSource source, StyleLayerType[] onlyLayerTypes)

Parameters

styleJsonOrUri string
The style document text, or its address.

source IVectorTileSource

        The tiles its layers read from, registered under the vector source name the style
        declares. Null leaves the style's own source declaration to speak for itself.

onlyLayerTypes StyleLayerType[]

        When given, only the layers of these types come in - StyleLayerType.Line,
        StyleLayerType.Symbol to drop the opaque land base that would hide imagery under
        it; with no source of your own, pass null for it: AddStyle(json, null, StyleLayerType.Line). Filtering, not re-sorting: what survives keeps the order the author gave it. The
        document's background is not a layer type and does not come in when filtering.

Returns

MapStyle

OpenAsync(CancellationToken)

Resolves every document added by address, then compiles the style. Adding more afterwards marks it to be compiled again. The map does this itself when the style is handed to it, so an application calls this only to read the compiled style - its layers, its images - before then.

public Task<MapStyle> OpenAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken
A cancellation token.

Returns

Task<MapStyle>
This style, opened.

AddVectorTiles(IVectorTileSource, string, StyleLayerSlot, StyleLayer[])

Adds vector tiles and style layers built in code that draw them: the tiles go in as a source, the layers on top unless says otherwise.

public MapStyle AddVectorTiles(IVectorTileSource source, string sourceId, StyleLayerSlot slot, StyleLayer[] layers)

Parameters

source IVectorTileSource
The tiles the layers draw from.

sourceId string
The name the tiles go under, or null for one made up.

slot StyleLayerSlot
Where in the stack the layers go.

layers StyleLayer[]

        The layers, built by the  factories: StyleLayer.CreateFill("parks", "parks", …).
        Each is placed in the style's order here and bound to .
        With none, the tiles draw in the default look, the one a classic vector tile layer
        without a style.json draws: every source-layer by its geometry, polygons in a light
        orange with a darker outline, lines in a muted red and points as orange dots. It adds
        no background: where the tiles have nothing, what is beneath the map shows through.

Returns

MapStyle

Exceptions

ArgumentException
A layer was not built by a factory - one read out of a compiled style, say.

Remarks:

A layer draws from the source it names, so each factory is handed the name the tiles went under and passes it straight through as the layer's source - the name is written once, here, whether the caller chose it or the style made one up. A layer that names some other source is refused when the style compiles. https://community.thinkgeo.com/t/multiple-featuresourcevectortilesources-in-mapstyle/12478

AddVectorTiles(IVectorTileSource, string, StyleLayer[])

public MapStyle AddVectorTiles(IVectorTileSource source, string sourceId, StyleLayer[] layers)

Parameters

source IVectorTileSource

sourceId string

layers StyleLayer[]

Returns

MapStyle

SetLight(double, double, double, GeoColor, StyleAnchor)

public MapStyle SetLight(double azimuthDegrees, double polarDegrees, double intensity, GeoColor color, StyleAnchor anchor)

Parameters

azimuthDegrees double

polarDegrees double

intensity double

color GeoColor

anchor StyleAnchor

Returns

MapStyle

Remarks:

A change to the light alone is applied on the next frame without recompiling the style, unless something else changed too.

SetTerrain(RasterDemSource, double)

Sets the terrain from a DEM: the source goes in under a name of its own, and the map is draped over it. A style has one DEM, shared by its terrain and every hillshade layer; a different one than it already has is an error.

public MapStyle SetTerrain(RasterDemSource dem, double exaggeration)

Parameters

dem RasterDemSource

exaggeration double

Returns

MapStyle

AddHillshade(RasterDemSource, Nullable<HillshadePaint>, StyleLayerSlot)

Adds a hillshade layer shading a DEM, on top: the source goes in under the same name MapStyle.SetTerrain(RasterDemSource, double) uses, so one DEM serves both the terrain and its shading, and the relief is shaded whether or not the ground is lifted. One DEM serves the style: add several hillshade layers over it - a light from the north-west and a softer one from above - by passing the same source again; a different DEM than the style already has is an error.

public MapStyle AddHillshade(RasterDemSource dem, Nullable<HillshadePaint> paint, StyleLayerSlot slot)

Parameters

dem RasterDemSource
The elevation tiles.

paint Nullable<HillshadePaint>
How the relief is shaded; null for the spec defaults.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle

RemoveTerrain()

public MapStyle RemoveTerrain()

Returns

MapStyle

A(float, IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>, CancellationToken, IEnumerable<string>)

internal Task<bool> A(float , IReadOnlyDictionary<string, ValueTuple<GeoImage, float>> hostImages, CancellationToken , IEnumerable<string> suppliedSourceNames)

Parameters

`` float

hostImages IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>

`` CancellationToken

suppliedSourceNames IEnumerable<string>

Returns

Task<bool>

A(IEnumerable<IVectorTileSource>)

internal static List<string> A(IEnumerable<IVectorTileSource> )

Parameters

`` IEnumerable<IVectorTileSource>

Returns

List<string>

g()

internal string g()

Returns

string

A(string, string)

internal void A(string , string styleUri)

Parameters

`` string

styleUri string

Returns

void

LoadAsync(string, CancellationToken)

The address the style document was loaded from, or null for inline text and code-built styles. What lets a map materialize the document's own vector source without being handed the URI a second time.

public static Task<MapStyle> LoadAsync(string uriOrPath, CancellationToken cancellationToken)

Parameters

uriOrPath string
Address of the style.json document.

cancellationToken CancellationToken
Cancels the download and the compile.

Returns

Task<MapStyle>

A(string, float, IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>, CancellationToken)

internal static Task<MapStyle> A(string , float , IReadOnlyDictionary<string, ValueTuple<GeoImage, float>> additionalImages, CancellationToken )

Parameters

`` string

`` float

additionalImages IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>

`` CancellationToken

Returns

Task<MapStyle>

a(string, float, IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>, CancellationToken)

internal static Task<MapStyle> a(string , float , IReadOnlyDictionary<string, ValueTuple<GeoImage, float>> additionalImages, CancellationToken )

Parameters

`` string

`` float

additionalImages IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>

`` CancellationToken

Returns

Task<MapStyle>

A(string, string, float, IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>, CancellationToken, IReadOnlyDictionary<string, GP>)

internal static Task<MapStyle> A(string , string , float , IReadOnlyDictionary<string, ValueTuple<GeoImage, float>> additionalImages, CancellationToken , IReadOnlyDictionary<string, GP> )

Parameters

`` string

`` string

`` float

additionalImages IReadOnlyDictionary<string, ValueTuple<GeoImage, float>>

`` CancellationToken

`` IReadOnlyDictionary<string, GP>

Returns

Task<MapStyle>

A(fW, string, float, CancellationToken)

internal static Task<MapStyle> A(fW , string , float , CancellationToken )

Parameters

`fW`

`` string

`` float

`` CancellationToken

Returns

Task<MapStyle>

a(string, string)

internal IReadOnlyList<StyleLayer> a(string , string )

Parameters

`` string

`` string

Returns

IReadOnlyList<StyleLayer>

B(string, string)

internal bool B(string , string )

Parameters

`` string

`` string

Returns

bool

c(string)

internal IReadOnlyList<StyleLayer> c(string )

Parameters

`` string

Returns

IReadOnlyList<StyleLayer>

b(string, string)

internal IReadOnlyList<GL> b(string , string )

Parameters

`` string

`` string

Returns

IReadOnlyList<GL>

D(string)

internal IReadOnlyList<GL> D(string )

Parameters

`` string

Returns

IReadOnlyList<GL>

A(string, string, int)

internal IReadOnlyList<Gl> A(string , string , int )

Parameters

`` string

`` string

`` int

Returns

IReadOnlyList<Gl>

A(string, int)

internal IReadOnlyList<Gl> A(string , int )

Parameters

`` string

`` int

Returns

IReadOnlyList<Gl>

A(double)

internal GJ A(double )

Parameters

`` double

Returns

GJ

A(Nullable<JsonElement>)

internal static Func<double, GJ> A(Nullable<JsonElement> )

Parameters

`` Nullable<JsonElement>

Returns

Func<double, GJ>

A(double, Gi&)

internal bool A(double , Gi& )

Parameters

`` double

`Gi&`

Returns

bool

A(SymbolLayout, float)

internal static SymbolLayout A(SymbolLayout , float )

Parameters

`` SymbolLayout

`` float

Returns

SymbolLayout

AddVectorField(VectorFieldSource, VectorFieldStyle)

Draws the field as oriented arrows - one per sampled cell, coloured and scaled by magnitude - over the map, under the labels, stacking with the other marker overlays in the order they are added. The data is the source object's: each Set* re-renders without a recompile.

public MapStyle AddVectorField(VectorFieldSource source, VectorFieldStyle style)

Parameters

source VectorFieldSource
The field.

style VectorFieldStyle
How the arrows draw; null draws with the defaults.

Returns

MapStyle

Exceptions

ArgumentException
The source already has a vector field in this style.

Remarks:

Not a layer of the stack, so no slot: see the class remarks for where data overlays draw.

RemoveVectorField(VectorFieldSource)

Removes this source's arrows from the style.

public MapStyle RemoveVectorField(VectorFieldSource source)

Parameters

source VectorFieldSource

Returns

MapStyle

AddParticleFlow(VectorFieldSource, ParticleFlowStyle)

The field's animated rendering: tens of thousands of tracer particles advected through it on the GPU, leaving fading trails. The whole simulation lives on the GPU; the map animates continuously while one is registered, and a Set* on the source redirects the particles without restarting them. May be combined with MapStyle.AddVectorField(VectorFieldSource, VectorFieldStyle) on the same source.

public MapStyle AddParticleFlow(VectorFieldSource source, ParticleFlowStyle style)

Parameters

source VectorFieldSource
The field.

style ParticleFlowStyle
How the flow draws; null animates with the defaults.

Returns

MapStyle

Exceptions

ArgumentException
The source already has a particle flow in this style.

Remarks:

Not a layer of the stack, so no slot: see the class remarks for where data overlays draw. One flow animates today; additional registrations are recorded in order but logged and skipped until the renderer catches up.

RemoveParticleFlow(VectorFieldSource)

Removes this source's flow from the style.

public MapStyle RemoveParticleFlow(VectorFieldSource source)

Parameters

source VectorFieldSource

Returns

MapStyle

AddDataOverlay(DataOverlayRegistration)

Appends a registration: what ThinkGeo.Gpu's AddDynamic, AddIsolines and AddGridFill do, from the assembly that draws them. An application calls those, not this.

public MapStyle AddDataOverlay(DataOverlayRegistration registration)

Parameters

registration DataOverlayRegistration

Returns

MapStyle

RemoveDataOverlays(Func<DataOverlayRegistration, bool>)

Removes every registration the predicate matches: what ThinkGeo.Gpu's Remove methods do.

public MapStyle RemoveDataOverlays(Func<DataOverlayRegistration, bool> matches)

Parameters

matches Func<DataOverlayRegistration, bool>

Returns

MapStyle

a(fW)

internal static IReadOnlyList<GM> a(fW )

Parameters

`fW`

Returns

IReadOnlyList<GM>

A(fW, IReadOnlyList<GM>)

internal static Gm A(fW , IReadOnlyList<GM> )

Parameters

`fW`

`` IReadOnlyList<GM>

Returns

Gm

A(IReadOnlyList<GM>, string, CancellationToken)

internal static Task<IReadOnlyList<GM>> A(IReadOnlyList<GM> , string , CancellationToken )

Parameters

`` IReadOnlyList<GM>

`` string

`` CancellationToken

Returns

Task<IReadOnlyList<GM>>

ResolveAsync(CancellationToken)

Fetches every style document added by address and merges each into its place. Documents given as text are merged too. Nothing to do when none is waiting. The map resolves a style itself when it opens it, so an application calls this only to read the merged document before then.

public Task ResolveAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken
A cancellation token.

Returns

Task
A task that represents the asynchronous operation.

F(string, string)

internal void F(string , string styleUri)

Parameters

`` string

styleUri string

Returns

void

AddSource(string, JsonObject)

Adds a source under a name, as the document describes it - a type, a tile address. A name the style already has is an error.

public MapStyle AddSource(string id, JsonObject source)

Parameters

id string
The name layers reference the source by.

source JsonObject
The source node, as the style specification writes it.

Returns

MapStyle
This document.

AddLayer(JsonObject, StyleLayerSlot)

Adds a layer as the style specification writes it, on top unless says otherwise. The layer needs an id, and one the style already has is an error.

public MapStyle AddLayer(JsonObject layer, StyleLayerSlot slot)

Parameters

layer JsonObject
The layer node.

slot StyleLayerSlot
Where in the stack it goes.

Returns

MapStyle
This document.

AddRasterLayer(string, string, Nullable<RasterPaint>, StyleLayerSlot)

Adds a raster layer drawing a source the document already has, on top unless says otherwise.

public MapStyle AddRasterLayer(string id, string sourceId, Nullable<RasterPaint> paint, StyleLayerSlot slot)

Parameters

id string
The layer's id, which and find it by; one the style already has is an error.

sourceId string
The raster source, added with or .

paint Nullable<RasterPaint>
How the tiles are drawn: opacity, fade, resampling, the colour adjustments. Null is the specification's defaults - opaque, a 300 ms fade.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle
This document.

AddHillshadeLayer(string, string, Nullable<HillshadePaint>, StyleLayerSlot)

Adds a hillshade layer shading a raster-dem source, on top unless says otherwise.

public MapStyle AddHillshadeLayer(string id, string sourceId, Nullable<HillshadePaint> paint, StyleLayerSlot slot)

Parameters

id string
The layer's id, which and find it by; one the style already has is an error.

sourceId string

        The raster-dem source: the one  or
         registered, or one added with .

paint Nullable<HillshadePaint>
How the relief is shaded; null for the specification's defaults.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle
This document.

SetBackground(GeoColor, float)

Sets the background: the colour under everything. A background layer already in the document is repainted; otherwise one goes in at the bottom.

public MapStyle SetBackground(GeoColor color, float opacity)

Parameters

color GeoColor

opacity float

Returns

MapStyle

SetSky(GeoColor, GeoColor, double)

Sets the sky drawn above a tilted map.

public MapStyle SetSky(GeoColor skyColor, GeoColor horizonColor, double skyHorizonBlend)

Parameters

skyColor GeoColor

horizonColor GeoColor

skyHorizonBlend double

Returns

MapStyle

SetTerrain(string, double)

Sets the terrain: the raster-dem source the map is draped over, and how much its heights are exaggerated.

public MapStyle SetTerrain(string sourceId, double exaggeration)

Parameters

sourceId string

exaggeration double

Returns

MapStyle

SetGlyphs(string)

Sets the glyph server labels take their letters from: a URL template with {fontstack} and {range} placeholders. With one, text is drawn as SDF glyphs from that server; without one, from local fonts. Null or blank removes it.

public MapStyle SetGlyphs(string uriTemplate)

Parameters

uriTemplate string

Returns

MapStyle

SetSprite(string)

Sets the sprite address symbols take their pictures from.

public MapStyle SetSprite(string uri)

Parameters

uri string

Returns

MapStyle

ToJson()

The document as style JSON text, version 8: everything composed so far, in order.

public string ToJson()

Returns

string
The style JSON.

a(bool)

internal string a(bool )

Parameters

`` bool

Returns

string

s()

internal void s()

Returns

void

a(string, Int32&, Int32&, Single&)

internal bool a(string , Int32& , Int32& , Single& )

Parameters

`` string

`` Int32&

`` Int32&

`` Single&

Returns

bool

I(string)

internal void I(string )

Parameters

`` string

Returns

void

AddFillLayer(string, string, string, FillPaint, string, JsonNode, Nullable<double>, Nullable<double>, StyleLayerSlot)

Adds a document layer that fills areas, painted as says - the same FillPaint a code layer takes, written into the document.

public MapStyle AddFillLayer(string id, string sourceId, string sourceLayer, FillPaint paint, string pattern, JsonNode filter, Nullable<double> minZoom, Nullable<double> maxZoom, StyleLayerSlot slot)

Parameters

id string
The layer's id; one the style already has is an error.

sourceId string
The id of the source the areas come from, as or an Add that registers a source named it.

sourceLayer string
The layer within the source, for a source that is tiles; null for a GeoJSON source.

paint FillPaint
The fill: colour, opacity, outline, antialias, translate.

pattern string
The fill-pattern: the name of an image in tiled across every area in place of the colour, or null.

filter JsonNode
Which features, as a style expression - see - or null for all.

minZoom Nullable<double>
The zoom the layer appears at, or null for any.

maxZoom Nullable<double>
The zoom the layer disappears at, or null for none.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle
This document.

AddLineLayer(string, string, string, LinePaint, Nullable<LineLayout>, string, JsonNode, Nullable<double>, Nullable<double>, StyleLayerSlot)

Adds a document layer that strokes lines, painted as says and laid out as says - the LinePaint and LineLayout a code layer takes, written into the document.

public MapStyle AddLineLayer(string id, string sourceId, string sourceLayer, LinePaint paint, Nullable<LineLayout> layout, string pattern, JsonNode filter, Nullable<double> minZoom, Nullable<double> maxZoom, StyleLayerSlot slot)

Parameters

id string
The layer's id; one the style already has is an error.

sourceId string
The id of the source the lines come from, as or an Add that registers a source named it.

sourceLayer string
The layer within the source, for a source that is tiles; null for a GeoJSON source.

paint LinePaint
The stroke: colour, width, opacity, dash, blur, gap, offset, translate.

layout Nullable<LineLayout>
Cap and join; null is the specification's butt and miter.

pattern string
The line-pattern: the name of an image in repeated along the line in place of the colour, or null. Not drawn yet by the GPU map, GpuTileRenderer or CpuTileRenderer, which stroke the line with its colour and log a StyleJsonParsing warning; MapLibre in the browser draws it.

filter JsonNode
Which features, as a style expression, or null for all.

minZoom Nullable<double>
The zoom the layer appears at, or null for any.

maxZoom Nullable<double>
The zoom the layer disappears at, or null for none.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle
This document.

AddCircleLayer(string, string, string, CirclePaint, JsonNode, Nullable<double>, Nullable<double>, StyleLayerSlot)

Adds a document layer that draws points as circles, painted as says - the CirclePaint a code layer takes, written into the document.

public MapStyle AddCircleLayer(string id, string sourceId, string sourceLayer, CirclePaint paint, JsonNode filter, Nullable<double> minZoom, Nullable<double> maxZoom, StyleLayerSlot slot)

Parameters

id string
The layer's id; one the style already has is an error.

sourceId string
The id of the source the points come from, as or an Add that registers a source named it.

sourceLayer string
The layer within the source, for a source that is tiles; null for a GeoJSON source.

paint CirclePaint
The circle: fill, stroke, radius, the two opacities.

filter JsonNode
Which features, as a style expression, or null for all.

minZoom Nullable<double>
The zoom the layer appears at, or null for any.

maxZoom Nullable<double>
The zoom the layer disappears at, or null for none.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle
This document.

AddSymbolLayer(string, string, string, SymbolLayout, SymbolPaint, string, string, JsonNode, Nullable<double>, Nullable<double>, StyleLayerSlot)

Adds a document layer that labels features with words from a column, a picture by name, or both - laid out as and painted as say, the SymbolLayout and SymbolPaint a code layer takes, written into the document.

public MapStyle AddSymbolLayer(string id, string sourceId, string sourceLayer, SymbolLayout layout, SymbolPaint paint, string textColumn, string imageName, JsonNode filter, Nullable<double> minZoom, Nullable<double> maxZoom, StyleLayerSlot slot)

Parameters

id string
The layer's id; one the style already has is an error.

sourceId string
The id of the source the features come from, as or an Add that registers a source named it.

sourceLayer string
The layer within the source, for a source that is tiles; null for a GeoJSON source.

layout SymbolLayout
Font, size, anchor, placement, offsets, spacing, the icon size.

paint SymbolPaint
Text colour, halo, the opacities.

textColumn string
The column the words come from, or null for no text.

imageName string
The picture, by its name in or the sprite, or null for none.

filter JsonNode
Which features, as a style expression, or null for all.

minZoom Nullable<double>
The zoom the layer appears at, or null for any.

maxZoom Nullable<double>
The zoom the layer disappears at, or null for none.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle
This document.

AddImage(GeoImage, RectangleShape, Projection, Nullable<RasterPaint>, string, StyleLayerSlot)

Adds one picture laid on the ground: the specification's image source, pinned to the corners of an extent, and a raster layer that draws it. This is how a document carries what the specification has no layer for - a radial gradient, a chart - drawn as it is, scaled with the ground it covers. MapStyle.AddRaster(RasterTileSource, Nullable<RasterPaint>, string, StyleLayerSlot) is the tiled form of a raster; MapStyle.Images holds the icons a symbol layer names, which is the other thing "image" means in the specification.

public MapStyle AddImage(GeoImage image, RectangleShape extent, Projection extentProjection, Nullable<RasterPaint> paint, string id, StyleLayerSlot slot)

Parameters

image GeoImage
The picture.

extent RectangleShape
The ground it covers, in .

extentProjection Projection

        The coordinate system  is in; null for Web Mercator metres. Each
        corner is converted on its own, so an extent in a projected system is pinned at its four
        true corners - a rectangle there is a slightly turned quadrilateral on the map.

paint Nullable<RasterPaint>
How the picture is drawn: opacity, the colour adjustments, resampling. Null draws it opaque and at once, with no fade-in.

id string
The layer's id; null takes "image", numbered when a layer has it already. An id the style already has is an error. The source takes it too, with "-source" after.

slot StyleLayerSlot
Where in the stack the layer goes.

Returns

MapStyle
This document.

Remarks:

Only the browser draws image sources today: a style handed to MapLibre - the Blazor map's - shows the picture. The in-process renderers, the GPU map (GpuBasemap, GpuTileRenderer) and CpuTileRenderer, do not draw it yet.

A(GeoFont)

internal static string A(GeoFont font)

Parameters

font GeoFont

Returns

string

A(fw)

internal static Gn A(fw )

Parameters

`fw`

Returns

Gn

AddFeatureLayer(FeatureLayerTranslation, StyleLayerSlot)

Adds a classic FeatureLayer translated for the GPU - its feature source as tiles, the styles on its zoom levels as code-built layers - at the end of the layer order. The translation comes from FeatureLayerTranslator.Translate(FeatureLayer, Collection<double>, string) (or its asynchronous-layer form), and it is a separate step on purpose: a classic style does not always have a GPU counterpart, and what did not translate is in the translation's FeatureLayerTranslation.Warnings, where the caller can read it before adding. The warnings are also logged under ThinkGeoLogType.Gpu, and the images the layers name are registered.

public MapStyle AddFeatureLayer(FeatureLayerTranslation translation, StyleLayerSlot slot)

Parameters

translation FeatureLayerTranslation
The translation to add.

slot StyleLayerSlot
Where in the stack the layers go - a parcel layer belongs at , under the basemap's roads and labels.

Returns

MapStyle

A(IReadOnlyList<ColorStop>)

internal static GeoColor[] A(IReadOnlyList<ColorStop> )

Parameters

`` IReadOnlyList<ColorStop>

Returns

GeoColor[]

u()

internal IReadOnlyList<StyleLayer> u()

Returns

IReadOnlyList<StyleLayer>

i(Nullable<JsonElement>)

internal static Func<double, HillshadePaint> i(Nullable<JsonElement> )

Parameters

`` Nullable<JsonElement>

Returns

Func<double, HillshadePaint>

A(IEnumerable<StyleLayer>)

internal void A(IEnumerable<StyleLayer> )

Parameters

`` IEnumerable<StyleLayer>

Returns

void

B(fW)

internal static IReadOnlyList<GO> B(fW )

Parameters

`fW`

Returns

IReadOnlyList<GO>

A(IReadOnlyList<GO>, string, CancellationToken)

internal static Task<IReadOnlyList<GO>> A(IReadOnlyList<GO> , string , CancellationToken )

Parameters

`` IReadOnlyList<GO>

`` string

`` CancellationToken

Returns

Task<IReadOnlyList<GO>>

v()

internal IReadOnlyList<StyleLayer> v()

Returns

IReadOnlyList<StyleLayer>

j(Nullable<JsonElement>)

internal static Func<double, RasterPaint> j(Nullable<JsonElement> )

Parameters

`` Nullable<JsonElement>

Returns

Func<double, RasterPaint>

A(byte, byte, double)

internal static byte A(byte , byte , double )

Parameters

`` byte

`` byte

`` double

Returns

byte

Events

HeatmapPaintChanged

Raised when a heatmap layer's paint is changed at runtime through MapStyle.SetHeatmapPaint(string, Nullable<float>, Nullable<float>, Nullable<float>, IReadOnlyList<ColorStop>).

public event EventHandler<HeatmapPaintChangedEventArgs> HeatmapPaintChanged;

DocumentChanged

Raised whenever the document changes: a piece added, a colour set, an image given.

public event EventHandler DocumentChanged;

FillExtrusionOffsetChanged

Raised when an extrusion layer is moved vertically at runtime.

public event EventHandler<FillExtrusionOffsetChangedEventArgs> FillExtrusionOffsetChanged;

LayerVisibilityChanged

Raised when a layer is shown or hidden through MapStyle.SetLayerVisibility(string, bool).

public event EventHandler<StyleLayerVisibilityChangedEventArgs> LayerVisibilityChanged;