[mapserver-users] show label text in class object

sharad fine_sharad at hotmail.com
Tue Aug 21 03:19:11 PDT 2012


 I have create dynamic layer in mapObject and set class  properties as
following

        mapObj bMap=        Session["baseMap"] as mapObj;
        //create dynamic layer
        layerObj lyrObj = new layerObj(bMap);
        lyrObj.status = mapscript.MS_ON;
        lyrObj.connectiontype = MS_CONNECTION_TYPE.MS_OGR;
        lyrObj.connection = "roadline.shp";
        lyrObj.name = "testDynLayer";
        lyrObj.type = MS_LAYER_TYPE.MS_LAYER_LINE;
        lyrObj.data = "SELECT * FROM roadline LEFT JOIN
'D:\\TEST\\MapFile\\test.csv'.test ON roadline.KMCROAD_ID =
test.SELECTEDCODE";
        lyrObj.labelitem = "RESPONDENTNAME";    
       
      //create first class
       classObj newclass = new classObj(lyrObj);
        newclass.name = "Dynamic Layer";         
        newclass.setText("'[DESCRIPTIO]'");
        newclass.label.color = new colorObj(100, 100, 100, 20);

        styleObj style = new styleObj(newclass);
        colorObj clrObj = new colorObj(255, 0, 255, 20);
        style.color = clrObj;

      //create second class using expression
        classObj newclass1 = new classObj(lyrObj);
        newclass1.name = "Dynamic Layer1";
        newclass1.setExpression("[QNRCODE]=137");
        newclass1.setText("'[QNRCODE]'");         //this doesnot work
        newclass1.label.color = new colorObj(100, 100, 100, 20);       
        styleObj style1 = new styleObj(newclass1);      
        style1.color = new colorObj(0, 225, 255, 20);

        labelObj lablObj1 = newclass1.label;
        lablObj1.type = MS_FONT_TYPE.MS_TRUETYPE;
        lablObj1.font = "verdana";
        lablObj1.color = new colorObj(150, 150, 150, 20);
        lablObj1.size = 6;
        lablObj1.position = (int)MS_POSITIONS_ENUM.MS_AUTO;
        lablObj1.buffer = 4;

        imageObj img = bMap.draw();

        string session_Id = Session.SessionID;
        String loginDateString = (String)Session["LOGINDATE"];

        img.save(Server.MapPath("MapImages/" + loginDateString + "/bM_" +
session_Id + ".png"), bMap);
        //display maps 
        ibMap.ImageUrl = "MapImages/" + loginDateString + "/bM_" +
session_Id + ".png?id=" + DateTime.Now.Ticks;
        //legTest.ImageUrl = "MapImages/" + loginDateString + "/lg_" +
session_Id + ".png";

        SetLayerSelectionTree(bMap);

        Session["baseMap"] = bMap;


this code generates the dynamic layer  and adddt into the base map. all
other setting works perfectly but no layer label is displayed. what is the
problem? please suggest.

regards
sharad



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/show-label-text-in-class-object-tp4996605.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list