[mapserver-dev] removing dynamically created layer in mapscript

mapsab sabuvk at gmail.com
Wed Jul 14 05:27:31 EDT 2010

As part of implementing a website using mapscript,I have created a function 
that draws  lines  in the map.
It draws the line ,but when I want to redraw the line using some other
points,the first drawn line is still appearing on the map,even after I
removed the layer which I drew earlier for the line.Can any one  suggests me
how to remove the earlier layer from the map,so that the last  drawn line is
only visible?
The code for drawing the line is given below

Public Sub dra_li(ByVal pointary() As pointObj, ByVal count As Integer)
        Dim oTempLayer As layerObj = New layerObj(Util.MSMap)
        Dim lno As Integer = Util.MSMap.numlayers
        lno = lno
            oTempLayer.name = "Userlines"
            oTempLayer.status = 1 'change to 1
            oTempLayer.type = MS_LAYER_TYPE.MS_LAYER_LINE
        Util.MSMap.insertLayer(oTempLayer, lno) '18
            Dim i As Integer
            Dim oShp As shapeObj = New shapeObj(MS_SHAPE_TYPE.MS_SHAPE_LINE)
            For i = 0 To count - 2
                Dim oLine As lineObj = New lineObj()
                'Dim startpoint1 As New pointObj(58.5818, 23.6011, 0, 0)
                'Dim endpoint1 As New pointObj(54.09818, 17.0011, 0, 0)

                oLine.add(pointary(i + 1))


            Dim oTempClass As classObj = New classObj(oTempLayer)
            Dim oStyle As styleObj = New styleObj(oTempClass)
            oStyle.color.setRGB(0, 0, 0)


            Dim oimg As imageObj = Util.MSMap.draw()

            oTempLayer.draw(Util.MSMap, oimg) '''un comment to draw this

            Util.MapIsDirty = True

    End Sub

for removing layer i use

Dim tl As layerObj = Util.MSMap.getLayerByName("Userlines")

View this message in context: http://osgeo-org.1803224.n2.nabble.com/removing-dynamically-created-layer-in-mapscript-tp5291745p5291745.html
Sent from the Mapserver - Dev mailing list archive at Nabble.com.

More information about the mapserver-dev mailing list