www.sdlsuite.com Forum Index www.sdlsuite.com
Discussion of technical aspects of the SDL Component Suite
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Displaying scalable text on the map

 
Post new topic   Reply to topic    www.sdlsuite.com Forum Index -> GeoPack
View previous topic :: View next topic  
Author Message
hansdb



Joined: 21 Nov 2012
Posts: 4

PostPosted: Thu Nov 22, 2012 12:12 am    Post subject: Displaying scalable text on the map Reply with quote

Hi all,

I'm looking for a way to display scalable text on a map image. I have tried to work with TCanvas.TextOut and Windows DrawText(). However I do not seem to grasp how to incorporate the map's magnification factor in order to scale the text size.

For example: starting off with text size=11 on a map with magnification=1. How do I make sure the text shrinks to its proper size when setting magnification to let's say 0,4.

Does anyone have an example on how to do this?
_________________
Hans de Bue
----------------------
Promanent b.v.
www.promanent.com
Back to top
View user's profile Send private message
hlohning



Joined: 08 Sep 2006
Posts: 277
Location: Austria

PostPosted: Sun Nov 25, 2012 7:19 am    Post subject: Reply with quote

Assuming that you know which pixel position the text has to be placed at, you could use the OnDataRendered event to display a scaled text at this position. Here's a sample code of the event handler:

Code:

procedure TForm1.GM1DataRendered(Sender: TObject; Canvas: TCanvas);

const
  FontNormSize = 12;

var
  p : TPoint;

begin
p.X := 200;    // location of text in map pixel coordinates
p.Y := 100;
p := GM1.MapImageToControl(p);
Canvas.Font.Size := round(GM1.Magnification*FontNormSize);
Canvas.TextOut(p.x,p.y,'hello');
end;


Hope this helps,

- Hans

P.S.: In order to calculate the pixel position in the map reference frame you can use the function CalcPixelCoords
_________________
Hans Lohninger
Software Development Lohninger
http://www.lohninger.com/
Back to top
View user's profile Send private message Visit poster's website
hansdb



Joined: 21 Nov 2012
Posts: 4

PostPosted: Sat Dec 15, 2012 2:48 pm    Post subject: Reply with quote

Works perfectly well, Hans. Thank you!
_________________
Hans de Bue
----------------------
Promanent b.v.
www.promanent.com
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.sdlsuite.com Forum Index -> GeoPack All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group