LayerOverlay¶
Namespace: ThinkGeo.UI.WebApi
Layers drawn on the server into raster tiles: a shapefile with its styles, a GeoTIFF, a WMS or a tile service through an asynchronous layer - whatever a desktop map draws. A Web API action maps a z/x/y route to LayerOverlay.GetTileImageAsync(int, long, long, CancellationToken) and returns the bytes as image/png for the browser map to lay down; Overlay.GetImageAsync(int, int, RectangleShape, CancellationToken) draws the same layers at any extent for a picture. The tiles are on the grid of Overlay.MapUnit: web mercator for meters, the two-tile world of EPSG:4326 for decimal degrees.
public class LayerOverlay : Overlay
Inheritance object → Overlay → LayerOverlay
Properties¶
Layers¶
The layers, drawn in order: a Layer and an AsyncLayer alike.
public GeoCollection<LayerBase> Layers { get; }
Property Value¶
GeoCollection<LayerBase>
TileCache¶
A cache the tiles are kept in between requests: a tile already there is returned as it is, a tile drawn is saved into it. Its tiles have to be LayerOverlay.TileWidth by LayerOverlay.TileHeight pixels. Null, the default, draws every tile asked for.
public RasterTileCache TileCache { get; set; }
Property Value¶
RasterTileCache
TileWidth¶
The width of a tile in pixels, 512 unless set.
public int TileWidth { get; set; }
Property Value¶
TileHeight¶
The height of a tile in pixels, 512 unless set.
public int TileHeight { get; set; }
Property Value¶
Id¶
The name the overlay's route goes by, given when it was made.
public string Id { get; }
Property Value¶
IsVisible¶
Whether the overlay draws. Hidden, it draws nothing and its images are transparent.
public bool IsVisible { get; set; }
Property Value¶
MapUnit¶
The unit of the coordinates the overlay is drawn in: meters for web mercator, what a browser map is in and the default; decimal degrees for data left in longitude and latitude. The extents handed to the overlay are read in it, a tile grid follows it, and so does a scale line.
public GeographyUnit MapUnit { get; set; }
Property Value¶
GeographyUnit
DrawingExceptionMode¶
What happens when drawing fails: the exception is thrown to the action, drawn into the image as a marked tile so the map still comes up, both (the default), or ignored.
public DrawingExceptionMode DrawingExceptionMode { get; set; }
Property Value¶
DrawingExceptionMode
Constructors¶
LayerOverlay()¶
Creates an overlay with a generated id and no layers yet.
public LayerOverlay()
LayerOverlay(string)¶
Creates an overlay under an id - the name its route goes by - with no layers yet.
public LayerOverlay(string id)
Parameters¶
id string
The name the application knows the overlay by.
LayerOverlay(IEnumerable<LayerBase>)¶
Creates an overlay with a generated id that draws the layers given, in order.
public LayerOverlay(IEnumerable<LayerBase> layers)
Parameters¶
layers IEnumerable<LayerBase>
The layers, drawn in this order.
LayerOverlay(string, IEnumerable<LayerBase>)¶
Creates an overlay under an id - the name its route goes by - that draws the layers given, in order.
public LayerOverlay(string id, IEnumerable<LayerBase> layers)
Parameters¶
id string
The name the application knows the overlay by.
layers IEnumerable<LayerBase>
The layers, drawn in this order.
Methods¶
GetTileImageAsync(int, long, long, CancellationToken)¶
One tile, as PNG bytes: the layers drawn at the extent of the z/x/y tile on the Overlay.MapUnit grid, LayerOverlay.TileWidth by LayerOverlay.TileHeight pixels. A LayerOverlay.TileCache answers for a tile it already holds.
public Task<Byte[]> GetTileImageAsync(int zoom, long x, long y, CancellationToken cancellationToken)
Parameters¶
zoom int
The tile's zoom level.
x long
The tile's column.
y long
The tile's row, counted from the top.
cancellationToken CancellationToken
The request's token; a browser that has moved on stops the draw.
Returns¶
DrawAsyncCore(GeoCanvas, CancellationToken)¶
Draws the layers in order. An asynchronous layer is awaited; a layer that is not safe to draw from two requests at once draws one request at a time.
protected Task DrawAsyncCore(GeoCanvas geoCanvas, CancellationToken cancellationToken)
Parameters¶
geoCanvas GeoCanvas
The canvas to draw onto.
cancellationToken CancellationToken
The request's token.
Returns¶
OnDrawingLayer(DrawingLayerOverlayEventArgs)¶
Raises the LayerOverlay.DrawingLayer event so subscribers can inspect or cancel the layer draw operation.
protected void OnDrawingLayer(DrawingLayerOverlayEventArgs e)
Parameters¶
e DrawingLayerOverlayEventArgs
Event data describing the layer that is about to be drawn.
Returns¶
OnDrawnLayer(DrawnLayerOverlayEventArgs)¶
Raises the LayerOverlay.DrawnLayer event so subscribers can react after a layer has been rendered.
protected void OnDrawnLayer(DrawnLayerOverlayEventArgs e)
Parameters¶
e DrawnLayerOverlayEventArgs
Event data describing the layer that has completed drawing.
Returns¶
Events¶
DrawingLayer¶
Raised before each layer draws; a handler can skip the layer.
public event EventHandler<DrawingLayerOverlayEventArgs> DrawingLayer;
DrawnLayer¶
Raised after each layer has drawn.
public event EventHandler<DrawnLayerOverlayEventArgs> DrawnLayer;
Drawing¶
Raised before the overlay draws; a handler can cancel the draw.
public event EventHandler<DrawingOverlayEventArgs> Drawing;
Drawn¶
Raised after the overlay has drawn.
public event EventHandler<DrawnOverlayEventArgs> Drawn;