Q&A - Question

Force label to be visible for geo or any shape?

ScoL asked on July 02, 2019, keyword: Developer Kernel

Wondering what is the best way to force a label to be visible for one or more geos. And even for some of our symbols on another layer with geos underneath.

Inside our CustomDrawGeoShape, we have tried both:

if ShapeUIDInForceDrawList(Shp.UID) then GisDrawArcLabel(shp, shp, 0, 'test label', true); 

if ShapeUIDInForceDrawList(Shp.UID) then Shp.DrawLabel;

We have also tried setting Shp.Params.Labels.Visible := true when that shape is selected.

What is the best way to force the label to be drawn? We want the font and color to match what is specified in the tat config file for that layer even if we draw it manually ourselves.

Thank you,
Scott Lynn

Tomasz Kosinski (TatukGIS) replied June 26, 2019
Layer.Params.Labels.Allocator := False;
See also KB10775.
ScoL replied June 27, 2019
I am getting closer. I can add a label fairly well using the code below, but turning the layer label allocator off also changes some existing labels in the map display. This could still work, but we want a way to suppress some labels from displaying. So we have some code firing from a Popup Menu for adding or removing street labels.

Add is working pretty well. Remove Street Label is not working using the code below. How do we hide a single currently visible label and keep all the other current labels as visible?

Thank you,

// Snippet to add label from popup menu
shp := layerGeos.GetShape(SelectedShapeUID);
layerGeos.Params.Labels.Allocator := false;
shp.Params.Labels.Visible := true;
shp.Params.Labels.Allocator := false;
shp.Params.Labels.Value := ShapeStreetName(shp);

// Snippet to remove a label NOT WORKING YET
shp := layerGeos.GetShape(SelectedShapeUID);
shp.Params.Labels.Visible := false;
shp.Params.Labels.Allocator := false;
iPos := GeoForceLabelList.IndexOf(IntToStr(Shp.Uid));
// Well, we do not want it in the override draw list...
if (iPos > -1) then

// Inside my CustomDrawGeoShape
// Which we already call for showing some
// extra information for some geos
if GeoForceLabelList.IndexOf(IntToStr(Shp.Uid)) <> -1 then
  GisDrawArcLabel(shp, shp, 0, ShapeStreetName(shp), true);

ScoL replied July 02, 2019
Any help appreciated on this question. I am still looking for a better way to add a visible label and specifically to hide other labels that are visible as mentioned above.

Thank you!
Tomasz Kosinski (TatukGIS) replied July 02, 2019
This is user-2-user board. If you need regular support hel please contact support@ directly.
Tomasz Kosinski (TatukGIS) replied July 04, 2019
Also, consider using PaintShapeLabelEvent demonstrated in PaintLabel sample to perform custom drawing.
procedure TForm1.PaintLabel( 
  _sender : TOBject ;
  _shape  : TGIS_Shape 
) ;
  _shape.DrawLabel ; // call this line or not based on your criteria
If you would like to answer the question please Sign In.
Please review our recent Privacy Policy.
If you have any questions or requests, please contact us.
The Questions and Answers (Q & A) is intended to provide a means of communication between TatukGIS customers.
  1. Licensed users (with active maintenance play) of TatukGIS products may contribute to the Q & A content. Read-only access is available to anyone.
  2. Keep the content positive and professional.
  3. Be courteous to others by posting information when a question or issue asked on the Q & A is answered or resolved by other means (such as with help from TatukGIS technical support). Offer others at least a hint how the posted question was answered or the issue was resolved.
  4. The Q & A is not a replacement for TatukGIS technical support. TatukGIS team may or may not regularly follow or contribute content.