Adding a layer/Removing a layer - C#
Szekeres Tamás
szekeres.tamas at FREEMAIL.HU
Tue Apr 4 16:48:13 PDT 2006
Ian,
1. I don't think if you should explicitly remove the classes
and layers one by one.
Simply call msMap.Dispose(), so as to let msFreeMap() do the
work for you.
2. You should not use the external layerIndex for iterating
the layers. Instead use
layerObj layer;
for (int i = 0; i < msMap.numlayers; i++)
{
layer = msMap.getLayer(i);
...
}
or if you want to iterate by the layer order.
layerObj layer;
using (intarray ar = msMap.getLayersDrawingOrder())
{
for (int i = msMap.numlayers - 1; i >= 0; i--)
{
layer = msMap.getLayer(ar.getitem(i));
...
}
}
3. For rendering the map I would prefer:
using(imageObj image = msMap.draw())
{
byte[] img = image.getBytes();
using (MemoryStream ms = new MemoryStream(img))
{
Image mapimage = Image.FromStream(ms);
if (mapImage.Image != null)
{
mapImage.Image.Dispose();
mapImage.Image = null;
mapImage.Image = mapimage;
}
}
}
Best Regards
Tamas Szekeres
More information about the MapServer-users
mailing list