Hi,<br><br>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.<br><br>Best regards,<br>
<br>Tamas<br> <br><br><div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}</style><br>
<div class="gmail_quote">2010/7/14 mapsab <span dir="ltr"><<a href="mailto:sabuvk@gmail.com">sabuvk@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi<br>
As part of implementing a website using mapscript,I have created a function<br>
that draws lines in the map.<br>
It draws the line ,but when I want to redraw the line using some other<br>
points,the first drawn line is still appearing on the map,even after I<br>
removed the layer which I drew earlier for the line.Can any one suggests me<br>
how to remove the earlier layer from the map,so that the last drawn line is<br>
only visible?<br>
The code for drawing the line is given below<br>
<br>
Public Sub dra_li(ByVal pointary() As pointObj, ByVal count As Integer)<br>
<br>
Dim oTempLayer As layerObj = New layerObj(Util.MSMap)<br>
Dim lno As Integer = Util.MSMap.numlayers<br>
lno = lno<br>
oTempLayer.name = "Userlines"<br>
oTempLayer.status = 1 'change to 1<br>
oTempLayer.type = MS_LAYER_TYPE.MS_LAYER_LINE<br>
Util.MSMap.insertLayer(oTempLayer, lno) '18<br>
Dim i As Integer<br>
Dim oShp As shapeObj = New shapeObj(MS_SHAPE_TYPE.MS_SHAPE_LINE)<br>
For i = 0 To count - 2<br>
Dim oLine As lineObj = New lineObj()<br>
'Dim startpoint1 As New pointObj(58.5818, 23.6011, 0, 0)<br>
'Dim endpoint1 As New pointObj(54.09818, 17.0011, 0, 0)<br>
<br>
oLine.add(pointary(i))<br>
oLine.add(pointary(i + 1))<br>
oShp.add(oLine)<br>
<br>
Next<br>
<br>
<br>
Dim oTempClass As classObj = New classObj(oTempLayer)<br>
Dim oStyle As styleObj = New styleObj(oTempClass)<br>
<br>
oStyle.color.setRGB(0, 0, 0)<br>
<br>
oTempLayer.addFeature(oShp)<br>
<br>
<br>
Dim oimg As imageObj = Util.MSMap.draw()<br>
<br>
oTempLayer.draw(Util.MSMap, oimg) '''un comment to draw this<br>
line<br>
<br>
Util.MapIsDirty = True<br>
<br>
End Sub<br>
<br>
<br>
for removing layer i use<br>
<br>
Dim tl As layerObj = Util.MSMap.getLayerByName("Userlines")<br>
Util.MSMap.removeLayer(tl.index)<br>
<br>
<br>
Thanks,<br>
Sam<br>
<font color="#888888">--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/removing-dynamically-created-layer-in-mapscript-tp5291745p5291745.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/removing-dynamically-created-layer-in-mapscript-tp5291745p5291745.html</a><br>
Sent from the Mapserver - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
mapserver-dev mailing list<br>
<a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-dev</a><br>
</font></blockquote></div><br>