[...]
They can be made transparent by supplying negative numbers for the R, G,
and B values.

c.label.backgroundcolor = mapscript.colorObj(-1, -1, -1)
c.label.outlinecolor = mapscript.colorObj(-1, -1, -1)

Never done must this be! Proper usage is

    c.label.backgroundcolor.setRGB(-1, -1, -1)
    c.label.outlinecolor.setRGB(-1, -1, -1)

Otherwise the previously defined colors will be dereferenced improperly and never cleaned up by Python's garbage collector. Anyhow, these attributes begin with default values (-1, -1, -1), so no need to alter them if you want the no-background default.

I (we, actually) tried your syntax, but neither the backgroundcolor nor the outlinecolor attributes on the label object are color objects, and so attempting to call the setRGB method on them fails with an AttributeError. According to the mapscript API, and introspection of a mapscript-parsed map file in a Python interpreter, those attributes must be set with mapscript color objects. Hence the code I previously listed.

I should note that the layer in question is being generated entirely from scratch with mapscript. It is not being modified from a layer that has been read in from a map file. We have learned that this means we have to set all kinds of default values that otherwise appear to be assumed. Having no background, for example, is not the default behavior for a layer generated entirely using mapscript commands. (It is, in fact, a solid black rectangle.)

Your suggestion to specify basic values for our layers in a map file and then merely modify them via mapscript commands is an excellent one, however, and definitely would simplify what we're trying to do. For workflow considerations, we hadn't considered it, let alone thought it possible.

Thanks!
--Damon

Reply via email to