The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



OnDataRendered


Unit:SDL_geomap
Class:TGeoMap
Declaration: property OnDataRendered: TRenderEvent;
{ TRenderEvent = procedure (Sender: TObject; Canvas: TCanvas) of object; }

The event OnDataRendered provides a hook for adding user defined graphics to the map. The event OnDataRendered occurs after the map, the gridlines, and the landmarks have been drawn, but before a possible highlighted landmark will be drawn. The parameter Canvas provides access to the canvas of the data area. Please note that the state of the canvas (e.g. the color of its pen, or the fill mode of the brush) may depend on previous drawing activities.

Hint 1: The declaration of this event has been changed with the introduction of release 10.1 of the SDL Suite. Please see the corresponding type declaration and the section How to Deal with a Canvas Reference Change for details.

Hint 2: User defined graphics may be positioned either relative to the window or relative to the map image. In order to draw relative to the map image you have to use the property TopLeft and subtract it from the pixel coordinates of the canvas (see example below).

Hint 3: In order to avoid unwanted size effects regarding characters displayed on canvases of different resolution (i.e. the screen and a printer) you should never directly assign the font size within the event. Use SetCanvasFontSizeScaled instead. So, for example, the statement Canvas.Font.Size := 12; should be replaced by SetCanvasFontSizeScaled (Canvas, 12);

Example: Following is an example on how to implement user defined graphics on top of a TGeoMap named "GM". It displays two lines, the red one is at a fixed position relative to the map window, the blue one moves along with the map if the map is panned.

procedure TForm1.GMDataRendered(Sender: TObject; Canvas: TCanvas);
begin
Canvas.Pen.Color := clRed;
Canvas.MoveTo(100,100);
Canvas.LineTo(200,200);
Canvas.Pen.Color := clBlue;
Canvas.MoveTo(100-round(GM.TopLeft.X*GM.Magnification),
              100-round(GM.TopLeft.Y*GM.Magnification));
Canvas.LineTo(200-round(GM.TopLeft.X*GM.Magnification),
              200-round(GM.TopLeft.Y*GM.Magnification));
end;

Example: This event is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): movecar



Last Update: 2023-Dec-13