[Mapserver-users] Getting Position of the Label text as MS will place it
Lowell Filak
lfilak at medinaco.org
Thu Apr 29 12:53:43 PDT 2004
If you incorporate mapscript you can loop through each label in the
labelcache and pickup the polygon (shapeobj) for each of them.
The following code is a quick cut from a 3.6 app but I believe it should
work with 4 & remember to alter the code to use the label
(labelcachememberobject) polygon instead of the point.
#
# Loop through each label in the cache and print string and point x,y.
while ( $label = $map->nextLabel() ) {
if ( $label->{status} ) {
my $point = $label->{point};
#
# Create the imagemap box for the label.
$bminx[$spncnt] = $point->{x} - 15;
$bminy[$spncnt] = $point->{y} - 10;
$bmaxx[$spncnt] = $point->{x} + 15;
$bmaxy[$spncnt] = $point->{y} + 10;
$ppn[$spncnt] = $label->{shapeidx};
$spncnt = $spncnt + 1;
}
}
HTH
Lowell
The following message was sent by "PATTERSON KENNETH ALLEN"
<kapatter at srpnet.com> on Thu, 29 Apr 2004 11:11:39 -0700.
>
> In our app we create a HTML map used to position popup information
when the cursor is positions at a specific place on the image. The user
can hover the cursor over a point and information will display. We use
Perl to program the site.
>
> It would be very useful for us if we can query the position that MS
draws the labels at. Use the following layer definition as the example:
How can we get each bounding box of the text label that is drawn (i.e.
TEXT "Col_label_nm")?
>
> We are able to get the shape index from the query result set etc..
I'm guessing that since we can't find anything exposed we will need to
do the same calculations that MS is doing to get the text bounding box.
Is this going to get way to tricky? Should we find another UI
solution? Anybody done this before? Suggestions?
>
> Thanks,
> Ken
>
>
> LAYER
> NAME "Stuff"
> GROUP Geographical
> TYPE POLYGON
> STATUS on
> template "dummy"
> DATA "/.../stuff.shp"
> CLASS
> NAME 'aclass'
> OUTLINECOLOR 200 200 200
> TEXT ([Col_label_nm])
> LABEL
> TYPE TRUETYPE
> FONT helmetBI
> antialias off
> COLOR 255 0 0
> MINSIZE 10
> MAXSIZE 14
> POSITION AUTO
> PARTIALS FALSE
> END # Label
> END # Class
> END # Stuff Layer
>
>
>
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list