[mapserver-dev] removing dynamically created layer in mapscript

Tamas Szekeres szekerest at gmail.com
Wed Jul 14 07:02:54 EDT 2010


Hi,

Looks like you've added the layer to the map twice. The layerObj constructor
impicitly adds the layer to the map passed as the parameter, so there's no
need to call insertLayer afterwards.

Best regards,

Tamas



2010/7/14 mapsab <sabuvk at gmail.com>

>
> Hi
> 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))
>                oLine.add(pointary(i + 1))
>                oShp.add(oLine)
>
>            Next
>
>
>            Dim oTempClass As classObj = New classObj(oTempLayer)
>            Dim oStyle As styleObj = New styleObj(oTempClass)
>
>            oStyle.color.setRGB(0, 0, 0)
>
>            oTempLayer.addFeature(oShp)
>
>
>            Dim oimg As imageObj = Util.MSMap.draw()
>
>            oTempLayer.draw(Util.MSMap, oimg) '''un comment to draw this
> line
>
>            Util.MapIsDirty = True
>
>    End Sub
>
>
> for removing layer i use
>
> Dim tl As layerObj = Util.MSMap.getLayerByName("Userlines")
> Util.MSMap.removeLayer(tl.index)
>
>
>                        Thanks,
>                               Sam
> --
> 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.
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20100714/84d12af4/attachment.html


More information about the mapserver-dev mailing list