Dynamic map title

Eric Bridger eric at GOMOOS.ORG
Thu Aug 26 10:11:11 EDT 2004


On Mon, 2004-08-23 at 08:02, Stefanie Weykam wrote:
> Hi again,
> last week, I asked the list how to get a dynamic title on the map. The title
> string depends on the currently displayed theme.
> I got a message back (see below, thanks Sean) but I didn't get any further
> and am still running around in circles. Apparently it is not possible to
> change the feature text.
> I must add, that the string will be passed by a variable, it is not a
> queriable value that belongs to the layer.
>
> As an alternative I have been thinking in keeping a static head line and add
> a dynamic title just above the legend.
> But the look is not too convincing either (limitations in style and most of
> all - string length!).
>
> I also want the title to be embedded in the image object, not just HTML text
> written on top.
>
> Does anybody have a good idea how to work around this limitation?
>
> thanks,
> Stefanie
>
>
> On Aug 16, 2004, at 11:17 AM, Stefanie Weykam wrote:
>
> > Hi all,
> > I have an annotation layer, it contains a point (feature) and a string
> > to
> > label this point.
> > Actually, the string is the title of the map and I want to change it
> > according to the currently displayed theme.
> > Is there any feature object which can be set by MapScript? The Class
> > Reference doesn't mention any. And, how do I change the color of the
> > label?
> > I always get error messages saying that the property (both color and
> > text)
> > don't exist or that the function setRGB() is undefined....???
> > Which objects do have these properties - do I nedd colorObjects?
> > styleObjects?? How do I create them?
> > Thanks,
> > Stefanie
> >
> >  LAYER
> >      NAME       "subtit"
> >      STATUS     ON
> >      TRANSFORM  FALSE
> >      TYPE       ANNOTATION
> >      FEATURE
> >         POINTS  635 10  END
> >         TEXT    "Species Richness"      # "a species name"
> >      END
> >      CLASS
> >         LABEL
> >            TYPE      TRUETYPE
> >            FONT      verdana            # verdana-italic
> >            SIZE      12
> >            POSITION  LL
> >            COLOR     80 130 0           # 160 90 0
> >         END
> >      END
> >  END
> >
> >
>
> Stephanie,
>
> Support for inline features is currently limited.  You cannot
> access a feature once it is in the feature "set".
>
> The thing to do is to leave out the FEATURE block in your map
> file, and insert a new feature as needed:
>
>      p = mapscript.pointObj(635, 10)     # the point
>      s = mapscript.shapeObj(layer.type)  # new shape to hold point
>      l = mapscript.lineObj()             # point must be in a line
>      l.add(p)                            # add point to line
>      s.add(l)                            # add line to shape
>
>      s.text = 'Species Richness'         # label for point
>      layer.addFeature(s)
>
>      layer.draw(map, image)
Stephanie,

I add labels to my maps all the time using addFeature() with no
problems.  First you should make sure that your LAYER works. Set the
status to DEFAULT or make sure you script turns it on or use shp2img on
your map file to see if it shows up.

I think you are missing a STYLE in your CLASS. Try adding STYLE END in
your CLASS block.  Then try removing the FEATURE section.

It does work.

Eric



More information about the mapserver-users mailing list