Overlay¶
Namespace: ThinkGeo.UI.WebApi
What a Web API action serves as an image: a LayerOverlay draws layers as tiles, an AdornmentOverlay draws a legend or a scale line over the map. An overlay is made once, when the application starts, and drawn on every request through Overlay.GetImageAsync(int, int, RectangleShape, CancellationToken) or a subclass's tile method. It is known by its Overlay.Id, the name the application gives its route.
public abstract class Overlay
Properties¶
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
Methods¶
GetImageAsync(int, int, RectangleShape, CancellationToken)¶
The overlay drawn into a transparent image of a size, at an extent in Overlay.MapUnit, as PNG bytes: what an action returns as image/png.
public Task<Byte[]> GetImageAsync(int width, int height, RectangleShape extent, CancellationToken cancellationToken)
Parameters¶
width int
The image width in pixels.
height int
The image height in pixels.
extent RectangleShape
The world extent the image shows.
cancellationToken CancellationToken
The request's token; a browser that has moved on stops the draw.
Returns¶
DrawAsync(GeoCanvas, CancellationToken)¶
Draws the overlay onto a canvas the caller has begun, for an image that holds more than this overlay. The canvas's extent and unit are used as they are.
public Task DrawAsync(GeoCanvas geoCanvas, CancellationToken cancellationToken)
Parameters¶
geoCanvas GeoCanvas
The canvas, between its BeginDrawing and EndDrawing.
cancellationToken CancellationToken
The request's token; a browser that has moved on stops the draw.
Returns¶
DrawAsyncCore(GeoCanvas, CancellationToken)¶
When overridden in a derived class, draws the overlay onto the canvas. The base implementation runs the obsolete , so an overlay written against 14.x still draws.
protected Task DrawAsyncCore(GeoCanvas geoCanvas, CancellationToken cancellationToken)
Parameters¶
geoCanvas GeoCanvas
The canvas to draw onto.
cancellationToken CancellationToken
The request's token.
Returns¶
Draw(GeoCanvas)¶
Draws the overlay onto a canvas, blocking the request thread while its asynchronous layers fetch.
public void Draw(GeoCanvas geoCanvas)
Parameters¶
geoCanvas GeoCanvas
The canvas to draw onto.
Returns¶
DrawCore(GeoCanvas)¶
The 14.x drawing hook, run by the base when a derived class has not overridden that instead.
protected void DrawCore(GeoCanvas geoCanvas)
Parameters¶
geoCanvas GeoCanvas
The canvas to draw onto.
Returns¶
DrawException(GeoCanvas, Exception)¶
Handles draw failures by delegating to .
protected void DrawException(GeoCanvas geoCanvas, Exception e)
Parameters¶
geoCanvas GeoCanvas
Canvas that should display the fallback visual.
e Exception
Exception that caused the draw operation to fail.
Returns¶
DrawExceptionCore(GeoCanvas, Exception)¶
Provides the overridable implementation that renders a diagnostic placeholder when drawing fails.
protected void DrawExceptionCore(GeoCanvas geoCanvas, Exception e)
Parameters¶
geoCanvas GeoCanvas
Canvas that should display the fallback visual.
e Exception
Exception that caused the draw operation to fail.
Returns¶
OnDrawing(DrawingOverlayEventArgs)¶
Raises the Overlay.Drawing event before drawing so subscribers can inspect or cancel rendering.
protected void OnDrawing(DrawingOverlayEventArgs e)
Parameters¶
e DrawingOverlayEventArgs
Event data describing the pending draw operation.
Returns¶
OnDrawn(DrawnOverlayEventArgs)¶
Raises the Overlay.Drawn event after drawing so subscribers can perform post-processing.
protected void OnDrawn(DrawnOverlayEventArgs e)
Parameters¶
e DrawnOverlayEventArgs
Event data that references the completed draw.
Returns¶
Events¶
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;