Adding text-features on a dynamic created inline layer
Johan Hallgren
johan.e.hallgren at WMDATA.SE
Tue Aug 9 07:07:44 PDT 2005
Hello
I tries to create at inline layer dynamicly with mapscript. Adding a label-
class and then add inline textfeatures on that layer.
The code for creating the layer is below.
***************************************
oLayerObj = new layerObj(oMapObj);
oLayerObj.name = strName;
oLayerObj.type = oMS_LAYER_TYPE;
oLayerObj.connectiontype = MS_CONNECTION_TYPE.MS_INLINE;
oLayerObj.status = 1;
oClassObj = new classObj(oLayerObj);
labelObj oLabelObj = new labelObj();
oLabelObj.type = MS_FONT_TYPE.MS_TRUETYPE;
oLabelObj.font = "verdanab";
oLabelObj.color = oColorObj;
oLabelObj.size = iSize;
oLabelObj.outlinecolor = getColor("255,255,255");
oLabelObj.position = (int)MS_LABEL_POSITIONS.MS_UC;
oLabelObj.antialias = mapscript.MS_TRUE;
oLabelObj.encoding = "CP437";
oClassObj.label = oLabelObj;
iClassIndex = oLayerObj.insertClass(oClassObj, -1);
****************************************
Adding features lookes like this
****************************************
lineObj oLineObj = new lineObj();
oLineObj.add(getPointObj(textNode.Attributes["coords"].Value,
isDatabaseCoord));
shapeObj oShapeObj = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_POINT);
oShapeObj.add(oLineObj);
oShapeObj.classindex = iClassIndex;
oShapeObj.text = textNode.Attributes["label"].Value;
oLayerObj.addFeature(oShapeObj);
oLayerObj.draw(oMapObj, i_obj);
****************************************
When I draws the text-features they dont show up on the map. If I'm
instead using a predefiend layer in the mapfile it works fine.
****************************************
LAYER
NAME TTTEXT
STATUS ON
TYPE ANNOTATION
FEATURE
END
CLASS
LABEL
TYPE TRUETYPE
FONT verdanab
SIZE 18
ANTIALIAS TRUE
OUTLINECOLOR 255 255 255
COLOR 0 0 0
POSITION UC
END
END
END
****************************************
Does anyone have a clue what can be wrong?
Regards
Johan
More information about the MapServer-users
mailing list