Skip to content

GpuBasemap

Namespace: ThinkGeo.UI.Maui

The GPU-rendered basemap: a ThinkGeo.Core.Styling.MapStyle rendered by the perspective-capable GL engine. The style is the single input - load one from a document with MapStyle.LoadAsync, compose one with its Add* methods, or build one in code - and JSON ends at the style, never reaching the map.

Deliberately NOT an Overlay: the basemap is the ground every overlay sits on, not one of the things sitting on it. Assign it to MapView.Basemap; the map composites it beneath the whole Overlays collection and drives its lifecycle.

Zoom, wherever the style speaks of it - a layer's minzoom, a zoom stop - is the MapView's own, over the map's ZoomScales ladder. The default ladder of a metre-unit map is the MapLibre one, so a style document reads as it would in MapLibre.

public sealed class GpuBasemap : System.IDisposable

Inheritance object → GpuBasemap
Implements IDisposable

Properties

TileSources

The vector tile sources this map draws from.

public GeoCollection<IVectorTileSource> TileSources { get; }

Property Value

GeoCollection<IVectorTileSource>

RasterTileSources

The raster tile sources laid into the style.

public GeoCollection<RasterTileSource> RasterTileSources { get; }

Property Value

GeoCollection<RasterTileSource>

IsBackgroundTransparent

Draws the map over whatever is behind it rather than over the style's background colour.

public bool IsBackgroundTransparent { get; set; }

Property Value

bool

RenderWorldCopies

Repeats the world east and west of the dateline instead of ending it.

public bool RenderWorldCopies { get; set; }

Property Value

bool

IsSceneStableForCapture

True when every tile and label the view needs is drawn and nothing is still animating, so a screenshot would be complete.

public bool IsSceneStableForCapture { get; }

Property Value

bool

IsExtrusionDrawingEnabled

Draws or skips the style's fill-extrusion layers - the cheap "3D buildings" switch. A renderer flag, not a restyle: nothing is rebuilt.

public bool IsExtrusionDrawingEnabled { get; set; }

Property Value

bool

IsLabelDrawingEnabled

Draws or skips every label. A renderer flag, not a restyle.

public bool IsLabelDrawingEnabled { get; set; }

Property Value

bool

LabelFadeDurationInMilliseconds

How long labels fade in and out over, in milliseconds; 0 disables the fade. 300 by default. A renderer setting, not a restyle.

public float LabelFadeDurationInMilliseconds { get; set; }

Property Value

float

DisplayProjection

The shape the world is drawn in - a globe, web mercator, or any proj string. Setting it snaps; GpuBasemap.AnimateDisplayProjectionAsync(DisplayProjection, TimeSpan, CancellationToken) morphs.

public DisplayProjection DisplayProjection { get; set; }

Property Value

DisplayProjection

Constructors

GpuBasemap(MapStyle)

The usual construction path: a ThinkGeo.Core.Styling.MapStyle, whatever built it - a document, composition, or pure code. The style's own source declarations supply the tiles; a style with none needs GpuBasemap.TileSources filled before the map is shown.

public GpuBasemap(MapStyle style)

Parameters

style MapStyle

Remarks:

The style's sources stay where they came from: the ones the application added are the application's and are never disposed by the basemap. The same style can be handed to the next basemap.

GpuBasemap(IVectorTileSource, MapStyle)

Imperative construction with an explicit tile source: the style is used exactly as compiled.

public GpuBasemap(IVectorTileSource tileSource, MapStyle style)

Parameters

tileSource IVectorTileSource

style MapStyle

Remarks:

The source stays yours: disposing the basemap leaves it open, so it can be handed to the next one. Dispose it when nothing draws from it any more.

GpuBasemap(IReadOnlyList<IVectorTileSource>, MapStyle)

The several-source form: each source keeps its own tile pipeline, so a slow one cannot hold the others off the screen.

public GpuBasemap(IReadOnlyList<IVectorTileSource> tileSources, MapStyle style)

Parameters

tileSources IReadOnlyList<IVectorTileSource>

style MapStyle

Methods

SetStyleAsync(MapStyle)

Replaces the style the map draws, keeping the camera where it is.

public Task SetStyleAsync(MapStyle style)

Parameters

style MapStyle

Returns

Task

SetStyleAsync(MapStyle, CancellationToken)

public Task SetStyleAsync(MapStyle style, CancellationToken cancellationToken)

Parameters

style MapStyle

cancellationToken CancellationToken

Returns

Task

GetElevationAsync(double, double, CancellationToken)

The elevation under a longitude/latitude, or null where the terrain source has no data.

public Task<Nullable<double>> GetElevationAsync(double longitude, double latitude, CancellationToken cancellationToken)

Parameters

longitude double

latitude double

cancellationToken CancellationToken

Returns

Task<Nullable<double>>

AnimateDisplayProjectionAsync(DisplayProjection, TimeSpan, CancellationToken)

Morphs from the current shape of the world to another over a duration.

public Task AnimateDisplayProjectionAsync(DisplayProjection target, TimeSpan duration, CancellationToken cancellationToken)

Parameters

target DisplayProjection

duration TimeSpan

cancellationToken CancellationToken

Returns

Task

Dispose()

Releases the render surface and the pipeline. The map does this when it is disposed. A basemap that MapView.Basemap replaced is not disposed: it is the application's again, to put back on the map or to dispose. The tile sources the application gave this basemap stay open, so the same source - or the same style - can go into the next one.

public void Dispose()

Events

TileLoadFailed

Raised when a tile of one of this map's sources could not be loaded: the request failed, timed out or returned an error, the feature source threw while the tile was cut, or the bytes would not decode. The tile is left out and what lies underneath it shows; the map does not throw, and a handler that wants an exception raises its own.

public event EventHandler<TileLoadFailedEventArgs> TileLoadFailed;