Adding text-features on a dynamic created inline layer

Johan Hallgren johan.e.hallgren at WMDATA.SE
Wed Aug 10 04:38:54 PDT 2005


I could figure it out my self...

I had to set some more variables on the labelObj-class.
**************************
oClassObj = new classObj(null);
labelObj oLabelObj = new labelObj();
oLabelObj.type = MS_FONT_TYPE.MS_TRUETYPE;
oLabelObj.font = "verdanab";
oLabelObj.color = oColorObj;
oLabelObj.backgroundcolor = getColor("-1,-1,-1");
oLabelObj.backgroundshadowcolor = getColor("-1,-1,-1");
oLabelObj.shadowcolor = getColor("-1,-1,-1");
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";
oLabelObj.maxsize = 256;
oLabelObj.minsize = 4;
oLabelObj.partials = mapscript.MS_TRUE;
oLabelObj.shadowsizex = 1;
oClassObj.label = oLabelObj;
iClassIndex = oLayerObj.insertClass(oClassObj, -1);
**************************

Regards
Johan

On Tue, 9 Aug 2005 09:07:44 -0500, Johan Hallgren
<johan.e.hallgren at WMDATA.SE> wrote:

>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