This project is read-only.

Strange behavior of shape and drawing layer index

Mar 14, 2014 at 4:39 PM
Edited Mar 14, 2014 at 4:46 PM

I come again to you to expose you a problem I often encounter.
I develop an application with MapWinGIS 4.8 which need to save index of shape created in shapefile and handle of drawing layers (5 or 6 drawing layers in the same time).
After many times to debug, I notice this behaviour :
  • when you delete a shape into a shapefile, all shape index after are decreased. In other words, index of shape are always a contenuous list of integer which start at 0.
  • same behaviour with drawing layers
    This behaviour is really strange because when you need to save reference to a shape in the aim to modify it after, its very difficult to keep consistency between shape index and my index.
    Moreover, for the drawing layers, I have an exemple :
  • I have one drawing layer to display scale bar. Each times the extents of axmap changed, the scale bar is redraw :
_handleDrawingLayerForScalebar = _axMap.NewDrawing(tkDrawReferenceList.dlScreenReferencedList);
  • I have one drawing layer to display result of simulation computation.
==>> In this state, drawing layers handle are respectively 0 and 1
  • I have a checkbox to hide the result of simulation computation. When user click on this checkbox, I use SetDrawingLayerVisible function to make disappear the drawing layer.
    If there was no extent change of the map, this works. But, when a change extent happen (so, clear and newdrawing for scale bar happen), its the result of simulation computation which disappear.
==>> In this state, drawing layers handlde are respectively 0 and 1 for me BUT for MapWingis 0 is the second drawing layer and 1 is the first : the clear of the drawing layer for the scale bar caused decrement of the second index.

I don't know if its a normal behaviour for you but its really hard to develop a big application with lots of data with MapWinGIS. Especially an application of simulation.

Best regards,

Dec 8, 2014 at 7:51 AM
Hi Tristan,

Do you still have these problems?

MapWinGIS v4.9.* now has a native scalebar.

About the indexes of the shapes. I'm not sure if that is the expected behavior. Can you add some of your code?
What might be a solution is the create the shapefile with Shapefile.CreateNewWithShapeID (
It will create an additional field called 'MWShapeID' this field will mimic the shape ID. You can use this field to reference the shape.

If you could outline a bit more what you want, we might be able to help you with a different workflow.

If possible you might consider upgrading to MapWinGIS v4.9.* It has several improvements and numerous bug fixes.