VectorTileSource¶
Namespace: ThinkGeo.Core
The standard IVectorTileSource: fetches, caches and decodes Mapbox vector tiles for the GPU renderer from a style.json document's sources or a tiles URL template.
public class VectorTileSource : IVectorTileSource, IRawVectorTileSource, System.IDisposable
Inheritance object → VectorTileSource
Implements IVectorTileSource, IRawVectorTileSource, IDisposable
Remarks:
This type only supplies tiles; it draws nothing and holds no styles. Rendering belongs to the GPU map (GpuBasemap on screen, GpuTileRenderer for images). It stands alone: the style document is read by the Core style loader, tiles come through its own HTTP client (VectorTileSource.SendingHttpRequest rewrites a request for keyed or signed endpoints), and a tiles entry that is a local .mbtiles path reads the archive directly. Inline geojson data a document declares is NOT served here - the GPU map materializes those declarations through Core's GeoJsonFeatureSource, so serving them again would draw everything twice.
Properties¶
VectorTileCache¶
Gets or sets the disk cache for downloaded tiles. Null means every tile is fetched from its source on demand.
public FileTileCache VectorTileCache { get; set; }
Property Value¶
UserAgent¶
Gets or sets the User-Agent header sent with tile requests. Some public tile servers refuse requests without one.
public string UserAgent { get; set; }
Property Value¶
WebProxy¶
Gets or sets the proxy tile requests go through, or null for none.
public IWebProxy WebProxy { get; set; }
Property Value¶
TimeoutInSeconds¶
Gets or sets the per-request timeout in seconds.
public int TimeoutInSeconds { get; set; }
Property Value¶
TileMatrixSet¶
public TileMatrixSet TileMatrixSet { get; }
Property Value¶
MinDataZoom¶
public int MinDataZoom { get; }
Property Value¶
Remarks:
Zero: this source serves whatever its style document declares and reports no floor of its own, so nothing is skipped on its behalf.
MaxDataZoom¶
public int MaxDataZoom { get; private set; }
Property Value¶
Remarks:
Starts at 14 (the hosted scheme's depth) and rises to the deepest maxzoom any of the document's sources publishes, so deeper tiles are fetched rather than overzoomed away.
IsOpen¶
public bool IsOpen { get; }
Property Value¶
Constructors¶
VectorTileSource(string)¶
Initializes a source that reads the style.json document (or tiles URL template) at and serves tiles from the sources it declares. Pass an empty string for a source that publishes the standard Web Mercator grid but never returns features - the placeholder a raster-only composition needs.
public VectorTileSource(string styleJsonUri)
Parameters¶
styleJsonUri string
The style.json or tiles URI, or an empty string.
Methods¶
OpenAsync(CancellationToken)¶
public Task OpenAsync(CancellationToken cancellationToken)
Parameters¶
cancellationToken CancellationToken
Returns¶
Dispose()¶
Releases the HTTP client the source made for its tiles and closes it for good: VectorTileSource.OpenAsync(CancellationToken) afterwards does nothing, VectorTileSource.IsOpen is false and a tile read throws ObjectDisposedException; a read under way finishes or throws the same. Calling it again does nothing. A source given to a map is the map's to dispose for as long as the map holds it: the map disposes every source it still has when it is itself disposed, and disposes nothing a restyle drops - a source that SetStyleAsync replaced is yours to dispose once the new style is applied. A source a style made from its own document is disposed the same way, by the map drawing that style. The sources a map makes for itself - the empty one under a raster-only style, the one behind its style address - it disposes when it is disposed, whether or not a restyle has replaced them.
public void Dispose()
Returns¶
GetFeaturesFromTileAsync(int, long, long, CancellationToken)¶
public Task<Dictionary<string, Collection<Feature>>> GetFeaturesFromTileAsync(int zoom, long x, long y, CancellationToken cancellationToken)
Parameters¶
zoom int
x long
y long
cancellationToken CancellationToken
Returns¶
Task<Dictionary<string, Collection<Feature>>>
A(Exception, CancellationToken)¶
internal static bool A(Exception , CancellationToken )
Parameters¶
`` Exception
Returns¶
Events¶
SendingHttpRequest¶
Raised before each tile request is sent. Rewrite the request to inject an API key, a signed URL or authentication headers; set Cancel to skip the request. This is how keyed providers plug in without a dedicated class.
public event EventHandler<SendingHttpRequestMessageEventArgs> SendingHttpRequest;
ReceivedHttpResponse¶
Raised when a tile response has arrived, before its status is read: a look at the headers, the status and the timing of every request.
public event EventHandler<ReceivedHttpResponseMessageEventArgs> ReceivedHttpResponse;