Click or drag to resize

IMapRendererRender Method

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Called when this item should render itself on the map.

Namespace:  Telogis.GeoBase
Assembly:  geobase.net (in geobase.net.dll) Version: 4.86.0.0
Syntax
void Render(
	Graphics graphics,
	RenderContext rc
)

Parameters

graphics
Type: System.DrawingGraphics
The Graphics object that can be used to draw on the map.
rc
Type: Telogis.GeoBaseRenderContext
The RenderContext information for this call.
Remarks
The Render(Graphics, RenderContext) method is called every time a map it is assigned to is redrawn, including when it is zoomed or panned.

The RenderContext parameter supplies information to this method about the state of rendering, and also provides methods for:

  • Reserving space on the map for the rendering of this item.
  • Testing whether rendering this item would cause a collision or overlap with space previously reserved by another item.
The Map property can be used to convert LatLon coordinates to screen coordinates for rendering, using LatLontoXY(Int32, Int32, LatLon)

Related articles: Map Concept, Defining the Renderer.

Examples
The following example indicates how one might implement Render to draw a class 'Circle' with a given size at specified x/y co-ordinates on an IMap.
C#
public void Render(System.Drawing.Graphics graphics, RenderContext rc) {

// In this case, only draw after everything else has been drawn.
if (rc.Mode == RenderMode.Labelling) {

    // Create a pen to draw the outline of the circle.
    System.Drawing.Pen RenderPen = new System.Drawing.Pen(Color.Red,1);

    // Create a brush with which to fill in the circle.
    System.Drawing.Brush RenderBrush = new System.Drawing.SolidBrush(Color.FromArgb(80, Color.Blue));

    // Get the BoundingBox which encloses the circle.
    // We assume this has already been created by the Circle class.
    BoundingBox bb = this.BoundingBox;

    // Will store the x/y co-ordinates.
    int x1,y1,x2,y2;

    // Use the specified IMap to convert the BoundingBox's
    // LatLon co-ordinates to x/y values.
    rc.Map.LatLontoXY(out x1, out y1, bb.P1 );
    rc.Map.LatLontoXY(out x2, out y2, bb.P2 );

    // Test whether there is space available for the circle
    // to be rendered (this is not mandatory).
    if (rc.Test(bb.Rectangle, 5, 0)) {

        // Reserve space for the circle by Placing it. Note that we
        // have specified a 5 pixel buffer around the circle.
        rc.Place(bb.Rectangle, 5, 0);

        //Draw the circle outline at the co-ordinates, with the
        //specified x and y radii.
        graphics.DrawEllipse(RenderPen,x1,y1,x2-x1,y2-y1);

        //Fill the circle using the same co-ordinate parameters.
        graphics.FillEllipse(RenderBrush,x1,y1,x2-x1,y2-y1);
    }
}
}
See Also