TatukGIS menu

Knowledge Base

KB10494 - Using the DK to custom draw labels.

Question from a DK customer: "How can I use the DK to draw labels that are backed by a bitmap aligned with the label location following a line? I need to draw the highway markers behind the highway numbers, all aligned properly with the direction of the highway".

The DK (as of the v. 8.0) does not provide a specific function to do this, but this is very easy to implement. Just override the OnPaintShape handler and draw the symbol "manually", with:

mylayer.OnPaintShape := doPaintShape ; ...

procedure TForm1.doPaintShape( const _sender : TOBject; const _shape :
TGIS_Shape );
ptg : TGIS_Point ;  
pt : TPoint ;
// calculate center point of the line;
ptg := shp.Centroid ;
pt := GIS.MapToScreen( ptg ) ;

// draw the shape itself
_shape.Draw ;

// draw the bitmap symbol on the top
GIS.Canvas.Draw( pt.x, pt,y, mybitmap ) ;
end ;
Created: March 12, 2004, Modified: July 30, 2015